Showing the changes to java/pkg2/java (494 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,593 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. | |
| 4 | + * | |
| 5 | + * | |
| 6 | + * | |
| 7 | + * | |
| 8 | + * | |
| 9 | + * | |
| 10 | + * | |
| 11 | + * | |
| 12 | + * | |
| 13 | + * | |
| 14 | + * | |
| 15 | + * | |
| 16 | + * | |
| 17 | + * | |
| 18 | + * | |
| 19 | + * | |
| 20 | + * | |
| 21 | + * | |
| 22 | + * | |
| 23 | + * | |
| 24 | + */ | |
| 25 | +package java.applet; | |
| 26 | + | |
| 27 | +import java.awt.*; | |
| 28 | +import java.awt.image.ColorModel; | |
| 29 | +import java.io.IOException; | |
| 30 | +import java.io.ObjectInputStream; | |
| 31 | +import java.net.URL; | |
| 32 | +import java.net.MalformedURLException; | |
| 33 | +import java.util.Hashtable; | |
| 34 | +import java.util.Locale; | |
| 35 | +import javax.accessibility.*; | |
| 36 | + | |
| 37 | +/** | |
| 38 | + * An applet is a small program that is intended not to be run on | |
| 39 | + * its own, but rather to be embedded inside another application. | |
| 40 | + * <p> | |
| 41 | + * The <code>Applet</code> class must be the superclass of any | |
| 42 | + * applet that is to be embedded in a Web page or viewed by the Java | |
| 43 | + * Applet Viewer. The <code>Applet</code> class provides a standard | |
| 44 | + * interface between applets and their environment. | |
| 45 | + * | |
| 46 | + * @author Arthur van Hoff | |
| 47 | + * @author Chris Warth | |
| 48 | + * @since JDK1.0 | |
| 49 | + */ | |
| 50 | +public class Applet extends Panel { | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Constructs a new Applet. | |
| 54 | + * <p> | |
| 55 | + * Note: Many methods in <code>java.applet.Applet</code> | |
| 56 | + * may be invoked by the applet only after the applet is | |
| 57 | + * fully constructed; applet should avoid calling methods | |
| 58 | + * in <code>java.applet.Applet</code> in the constructor. | |
| 59 | + * | |
| 60 | + * @exception HeadlessException if GraphicsEnvironment.isHeadless() | |
| 61 | + * returns true. | |
| 62 | + * @see java.awt.GraphicsEnvironment#isHeadless | |
| 63 | + * @since 1.4 | |
| 64 | + */ | |
| 65 | + public Applet() throws HeadlessException { | |
| 66 | + if (GraphicsEnvironment.isHeadless()) { | |
| 67 | + throw new HeadlessException(); | |
| 68 | + } | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Applets can be serialized but the following conventions MUST be followed: | |
| 73 | + * | |
| 74 | + * Before Serialization: | |
| 75 | + * An applet must be in STOPPED state. | |
| 76 | + * | |
| 77 | + * After Deserialization: | |
| 78 | + * The applet will be restored in STOPPED state (and most clients will | |
| 79 | + * likely move it into RUNNING state). | |
| 80 | + * The stub field will be restored by the reader. | |
| 81 | + */ | |
| 82 | + transient private AppletStub stub; | |
| 83 | + | |
| 84 | + /* version ID for serialized form. */ | |
| 85 | + private static final long serialVersionUID = -5836846270535785031L; | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * Read an applet from an object input stream. | |
| 89 | + * @exception HeadlessException if | |
| 90 | + * <code>GraphicsEnvironment.isHeadless()</code> returns | |
| 91 | + * <code>true</code> | |
| 92 | + * @serial | |
| 93 | + * @see java.awt.GraphicsEnvironment#isHeadless | |
| 94 | + * @since 1.4 | |
| 95 | + */ | |
| 96 | + private void readObject(ObjectInputStream s) | |
| 97 | + throws ClassNotFoundException, IOException, HeadlessException { | |
| 98 | + if (GraphicsEnvironment.isHeadless()) { | |
| 99 | + throw new HeadlessException(); | |
| 100 | + } | |
| 101 | + s.defaultReadObject(); | |
| 102 | + } | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * Sets this applet's stub. This is done automatically by the system. | |
| 106 | + * <p>If there is a security manager, its <code> checkPermission </code> | |
| 107 | + * method is called with the | |
| 108 | + * <code>AWTPermission("setAppletStub")</code> | |
| 109 | + * permission if a stub has already been set. | |
| 110 | + * @param stub the new stub. | |
| 111 | + * @exception SecurityException if the caller cannot set the stub | |
| 112 | + */ | |
| 113 | + public final void setStub(AppletStub stub) { | |
| 114 | + if (this.stub != null) { | |
| 115 | + SecurityManager s = System.getSecurityManager(); | |
| 116 | + if (s != null) { | |
| 117 | + s.checkPermission(new AWTPermission("setAppletStub")); | |
| 118 | + } | |
| 119 | + } | |
| 120 | + this.stub = (AppletStub)stub; | |
| 121 | + } | |
| 122 | + | |
| 123 | + /** | |
| 124 | + * Determines if this applet is active. An applet is marked active | |
| 125 | + * just before its <code>start</code> method is called. It becomes | |
| 126 | + * inactive just before its <code>stop</code> method is called. | |
| 127 | + * | |
| 128 | + * @return <code>true</code> if the applet is active; | |
| 129 | + * <code>false</code> otherwise. | |
| 130 | + * @see java.applet.Applet#start() | |
| 131 | + * @see java.applet.Applet#stop() | |
| 132 | + */ | |
| 133 | + public boolean isActive() { | |
| 134 | + if (stub != null) { | |
| 135 | + return stub.isActive(); | |
| 136 | + } else { // If stub field not filled in, applet never active | |
| 137 | + return false; | |
| 138 | + } | |
| 139 | + } | |
| 140 | + | |
| 141 | + /** | |
| 142 | + * Gets the URL of the document in which this applet is embedded. | |
| 143 | + * For example, suppose an applet is contained | |
| 144 | + * within the document: | |
| 145 | + * <blockquote><pre> | |
| 146 | + * http://java.sun.com/products/jdk/1.2/index.html | |
| 147 | + * </pre></blockquote> | |
| 148 | + * The document base is: | |
| 149 | + * <blockquote><pre> | |
| 150 | + * http://java.sun.com/products/jdk/1.2/index.html | |
| 151 | + * </pre></blockquote> | |
| 152 | + * | |
| 153 | + * @return the {@link java.net.URL} of the document that contains this | |
| 154 | + * applet. | |
| 155 | + * @see java.applet.Applet#getCodeBase() | |
| 156 | + */ | |
| 157 | + public URL getDocumentBase() { | |
| 158 | + return stub.getDocumentBase(); | |
| 159 | + } | |
| 160 | + | |
| 161 | + /** | |
| 162 | + * Gets the base URL. This is the URL of the directory which contains this applet. | |
| 163 | + * | |
| 164 | + * @return the base {@link java.net.URL} of | |
| 165 | + * the directory which contains this applet. | |
| 166 | + * @see java.applet.Applet#getDocumentBase() | |
| 167 | + */ | |
| 168 | + public URL getCodeBase() { | |
| 169 | + return stub.getCodeBase(); | |
| 170 | + } | |
| 171 | + | |
| 172 | + /** | |
| 173 | + * Returns the value of the named parameter in the HTML tag. For | |
| 174 | + * example, if this applet is specified as | |
| 175 | + * <blockquote><pre> | |
| 176 | + * <applet code="Clock" width=50 height=50> | |
| 177 | + * <param name=Color value="blue"> | |
| 178 | + * </applet> | |
| 179 | + * </pre></blockquote> | |
| 180 | + * <p> | |
| 181 | + * then a call to <code>getParameter("Color")</code> returns the | |
| 182 | + * value <code>"blue"</code>. | |
| 183 | + * <p> | |
| 184 | + * The <code>name</code> argument is case insensitive. | |
| 185 | + * | |
| 186 | + * @param name a parameter name. | |
| 187 | + * @return the value of the named parameter, | |
| 188 | + * or <code>null</code> if not set. | |
| 189 | + */ | |
| 190 | + public String getParameter(String name) { | |
| 191 | + return stub.getParameter(name); | |
| 192 | + } | |
| 193 | + | |
| 194 | + /** | |
| 195 | + * Determines this applet's context, which allows the applet to | |
| 196 | + * query and affect the environment in which it runs. | |
| 197 | + * <p> | |
| 198 | + * This environment of an applet represents the document that | |
| 199 | + * contains the applet. | |
| 200 | + * | |
| 201 | + * @return the applet's context. | |
| 202 | + */ | |
| 203 | + public AppletContext getAppletContext() { | |
| 204 | + return stub.getAppletContext(); | |
| 205 | + } | |
| 206 | + | |
| 207 | + /** | |
| 208 | + * Requests that this applet be resized. | |
| 209 | + * | |
| 210 | + * @param width the new requested width for the applet. | |
| 211 | + * @param height the new requested height for the applet. | |
| 212 | + */ | |
| 213 | + public void resize(int width, int height) { | |
| 214 | + Dimension d = size(); | |
| 215 | + if ((d.width != width) || (d.height != height)) { | |
| 216 | + super.resize(width, height); | |
| 217 | + if (stub != null) { | |
| 218 | + stub.appletResize(width, height); | |
| 219 | + } | |
| 220 | + } | |
| 221 | + } | |
| 222 | + | |
| 223 | + /** | |
| 224 | + * Requests that this applet be resized. | |
| 225 | + * | |
| 226 | + * @param d an object giving the new width and height. | |
| 227 | + */ | |
| 228 | + public void resize(Dimension d) { | |
| 229 | + resize(d.width, d.height); | |
| 230 | + } | |
| 231 | + | |
| 232 | + /** | |
| 233 | + * Indicates if this container is a validate root. | |
| 234 | + * <p> | |
| 235 | + * {@code Applet} objects are the validate roots, and, therefore, they | |
| 236 | + * override this method to return {@code true}. | |
| 237 | + * | |
| 238 | + * @return {@code true} | |
| 239 | + * @since 1.7 | |
| 240 | + * @see java.awt.Container#isValidateRoot | |
| 241 | + */ | |
| 242 | + @Override | |
| 243 | + public boolean isValidateRoot() { | |
| 244 | + return true; | |
| 245 | + } | |
| 246 | + | |
| 247 | + /** | |
| 248 | + * Requests that the argument string be displayed in the | |
| 249 | + * "status window". Many browsers and applet viewers | |
| 250 | + * provide such a window, where the application can inform users of | |
| 251 | + * its current state. | |
| 252 | + * | |
| 253 | + * @param msg a string to display in the status window. | |
| 254 | + */ | |
| 255 | + public void showStatus(String msg) { | |
| 256 | + getAppletContext().showStatus(msg); | |
| 257 | + } | |
| 258 | + | |
| 259 | + /** | |
| 260 | + * Returns an <code>Image</code> object that can then be painted on | |
| 261 | + * the screen. The <code>url</code> that is passed as an argument | |
| 262 | + * must specify an absolute URL. | |
| 263 | + * <p> | |
| 264 | + * This method always returns immediately, whether or not the image | |
| 265 | + * exists. When this applet attempts to draw the image on the screen, | |
| 266 | + * the data will be loaded. The graphics primitives that draw the | |
| 267 | + * image will incrementally paint on the screen. | |
| 268 | + * | |
| 269 | + * @param url an absolute URL giving the location of the image. | |
| 270 | + * @return the image at the specified URL. | |
| 271 | + * @see java.awt.Image | |
| 272 | + */ | |
| 273 | + public Image getImage(URL url) { | |
| 274 | + return getAppletContext().getImage(url); | |
| 275 | + } | |
| 276 | + | |
| 277 | + /** | |
| 278 | + * Returns an <code>Image</code> object that can then be painted on | |
| 279 | + * the screen. The <code>url</code> argument must specify an absolute | |
| 280 | + * URL. The <code>name</code> argument is a specifier that is | |
| 281 | + * relative to the <code>url</code> argument. | |
| 282 | + * <p> | |
| 283 | + * This method always returns immediately, whether or not the image | |
| 284 | + * exists. When this applet attempts to draw the image on the screen, | |
| 285 | + * the data will be loaded. The graphics primitives that draw the | |
| 286 | + * image will incrementally paint on the screen. | |
| 287 | + * | |
| 288 | + * @param url an absolute URL giving the base location of the image. | |
| 289 | + * @param name the location of the image, relative to the | |
| 290 | + * <code>url</code> argument. | |
| 291 | + * @return the image at the specified URL. | |
| 292 | + * @see java.awt.Image | |
| 293 | + */ | |
| 294 | + public Image getImage(URL url, String name) { | |
| 295 | + try { | |
| 296 | + return getImage(new URL(url, name)); | |
| 297 | + } catch (MalformedURLException e) { | |
| 298 | + return null; | |
| 299 | + } | |
| 300 | + } | |
| 301 | + | |
| 302 | + /** | |
| 303 | + * Get an audio clip from the given URL. | |
| 304 | + * | |
| 305 | + * @param url points to the audio clip | |
| 306 | + * @return the audio clip at the specified URL. | |
| 307 | + * | |
| 308 | + * @since 1.2 | |
| 309 | + */ | |
| 310 | + public final static AudioClip newAudioClip(URL url) { | |
| 311 | + return new sun.applet.AppletAudioClip(url); | |
| 312 | + } | |
| 313 | + | |
| 314 | + /** | |
| 315 | + * Returns the <code>AudioClip</code> object specified by the | |
| 316 | + * <code>URL</code> argument. | |
| 317 | + * <p> | |
| 318 | + * This method always returns immediately, whether or not the audio | |
| 319 | + * clip exists. When this applet attempts to play the audio clip, the | |
| 320 | + * data will be loaded. | |
| 321 | + * | |
| 322 | + * @param url an absolute URL giving the location of the audio clip. | |
| 323 | + * @return the audio clip at the specified URL. | |
| 324 | + * @see java.applet.AudioClip | |
| 325 | + */ | |
| 326 | + public AudioClip getAudioClip(URL url) { | |
| 327 | + return getAppletContext().getAudioClip(url); | |
| 328 | + } | |
| 329 | + | |
| 330 | + /** | |
| 331 | + * Returns the <code>AudioClip</code> object specified by the | |
| 332 | + * <code>URL</code> and <code>name</code> arguments. | |
| 333 | + * <p> | |
| 334 | + * This method always returns immediately, whether or not the audio | |
| 335 | + * clip exists. When this applet attempts to play the audio clip, the | |
| 336 | + * data will be loaded. | |
| 337 | + * | |
| 338 | + * @param url an absolute URL giving the base location of the | |
| 339 | + * audio clip. | |
| 340 | + * @param name the location of the audio clip, relative to the | |
| 341 | + * <code>url</code> argument. | |
| 342 | + * @return the audio clip at the specified URL. | |
| 343 | + * @see java.applet.AudioClip | |
| 344 | + */ | |
| 345 | + public AudioClip getAudioClip(URL url, String name) { | |
| 346 | + try { | |
| 347 | + return getAudioClip(new URL(url, name)); | |
| 348 | + } catch (MalformedURLException e) { | |
| 349 | + return null; | |
| 350 | + } | |
| 351 | + } | |
| 352 | + | |
| 353 | + /** | |
| 354 | + * Returns information about this applet. An applet should override | |
| 355 | + * this method to return a <code>String</code> containing information | |
| 356 | + * about the author, version, and copyright of the applet. | |
| 357 | + * <p> | |
| 358 | + * The implementation of this method provided by the | |
| 359 | + * <code>Applet</code> class returns <code>null</code>. | |
| 360 | + * | |
| 361 | + * @return a string containing information about the author, version, and | |
| 362 | + * copyright of the applet. | |
| 363 | + */ | |
| 364 | + public String getAppletInfo() { | |
| 365 | + return null; | |
| 366 | + } | |
| 367 | + | |
| 368 | + /** | |
| 369 | + * Gets the locale of the applet. It allows the applet | |
| 370 | + * to maintain its own locale separated from the locale | |
| 371 | + * of the browser or appletviewer. | |
| 372 | + * | |
| 373 | + * @return the locale of the applet; if no locale has | |
| 374 | + * been set, the default locale is returned. | |
| 375 | + * @since JDK1.1 | |
| 376 | + */ | |
| 377 | + public Locale getLocale() { | |
| 378 | + Locale locale = super.getLocale(); | |
| 379 | + if (locale == null) { | |
| 380 | + return Locale.getDefault(); | |
| 381 | + } | |
| 382 | + return locale; | |
| 383 | + } | |
| 384 | + | |
| 385 | + /** | |
| 386 | + * Returns information about the parameters that are understood by | |
| 387 | + * this applet. An applet should override this method to return an | |
| 388 | + * array of <code>Strings</code> describing these parameters. | |
| 389 | + * <p> | |
| 390 | + * Each element of the array should be a set of three | |
| 391 | + * <code>Strings</code> containing the name, the type, and a | |
| 392 | + * description. For example: | |
| 393 | + * <p><blockquote><pre> | |
| 394 | + * String pinfo[][] = { | |
| 395 | + * {"fps", "1-10", "frames per second"}, | |
| 396 | + * {"repeat", "boolean", "repeat image loop"}, | |
| 397 | + * {"imgs", "url", "images directory"} | |
| 398 | + * }; | |
| 399 | + * </pre></blockquote> | |
| 400 | + * <p> | |
| 401 | + * The implementation of this method provided by the | |
| 402 | + * <code>Applet</code> class returns <code>null</code>. | |
| 403 | + * | |
| 404 | + * @return an array describing the parameters this applet looks for. | |
| 405 | + */ | |
| 406 | + public String[][] getParameterInfo() { | |
| 407 | + return null; | |
| 408 | + } | |
| 409 | + | |
| 410 | + /** | |
| 411 | + * Plays the audio clip at the specified absolute URL. Nothing | |
| 412 | + * happens if the audio clip cannot be found. | |
| 413 | + * | |
| 414 | + * @param url an absolute URL giving the location of the audio clip. | |
| 415 | + */ | |
| 416 | + public void play(URL url) { | |
| 417 | + AudioClip clip = getAudioClip(url); | |
| 418 | + if (clip != null) { | |
| 419 | + clip.play(); | |
| 420 | + } | |
| 421 | + } | |
| 422 | + | |
| 423 | + /** | |
| 424 | + * Plays the audio clip given the URL and a specifier that is | |
| 425 | + * relative to it. Nothing happens if the audio clip cannot be found. | |
| 426 | + * | |
| 427 | + * @param url an absolute URL giving the base location of the | |
| 428 | + * audio clip. | |
| 429 | + * @param name the location of the audio clip, relative to the | |
| 430 | + * <code>url</code> argument. | |
| 431 | + */ | |
| 432 | + public void play(URL url, String name) { | |
| 433 | + AudioClip clip = getAudioClip(url, name); | |
| 434 | + if (clip != null) { | |
| 435 | + clip.play(); | |
| 436 | + } | |
| 437 | + } | |
| 438 | + | |
| 439 | + /** | |
| 440 | + * Called by the browser or applet viewer to inform | |
| 441 | + * this applet that it has been loaded into the system. It is always | |
| 442 | + * called before the first time that the <code>start</code> method is | |
| 443 | + * called. | |
| 444 | + * <p> | |
| 445 | + * A subclass of <code>Applet</code> should override this method if | |
| 446 | + * it has initialization to perform. For example, an applet with | |
| 447 | + * threads would use the <code>init</code> method to create the | |
| 448 | + * threads and the <code>destroy</code> method to kill them. | |
| 449 | + * <p> | |
| 450 | + * The implementation of this method provided by the | |
| 451 | + * <code>Applet</code> class does nothing. | |
| 452 | + * | |
| 453 | + * @see java.applet.Applet#destroy() | |
| 454 | + * @see java.applet.Applet#start() | |
| 455 | + * @see java.applet.Applet#stop() | |
| 456 | + */ | |
| 457 | + public void init() { | |
| 458 | + } | |
| 459 | + | |
| 460 | + /** | |
| 461 | + * Called by the browser or applet viewer to inform | |
| 462 | + * this applet that it should start its execution. It is called after | |
| 463 | + * the <code>init</code> method and each time the applet is revisited | |
| 464 | + * in a Web page. | |
| 465 | + * <p> | |
| 466 | + * A subclass of <code>Applet</code> should override this method if | |
| 467 | + * it has any operation that it wants to perform each time the Web | |
| 468 | + * page containing it is visited. For example, an applet with | |
| 469 | + * animation might want to use the <code>start</code> method to | |
| 470 | + * resume animation, and the <code>stop</code> method to suspend the | |
| 471 | + * animation. | |
| 472 | + * <p> | |
| 473 | + * Note: some methods, such as <code>getLocationOnScreen</code>, can only | |
| 474 | + * provide meaningful results if the applet is showing. Because | |
| 475 | + * <code>isShowing</code> returns <code>false</code> when the applet's | |
| 476 | + * <code>start</code> is first called, methods requiring | |
| 477 | + * <code>isShowing</code> to return <code>true</code> should be called from | |
| 478 | + * a <code>ComponentListener</code>. | |
| 479 | + * <p> | |
| 480 | + * The implementation of this method provided by the | |
| 481 | + * <code>Applet</code> class does nothing. | |
| 482 | + * | |
| 483 | + * @see java.applet.Applet#destroy() | |
| 484 | + * @see java.applet.Applet#init() | |
| 485 | + * @see java.applet.Applet#stop() | |
| 486 | + * @see java.awt.Component#isShowing() | |
| 487 | + * @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent) | |
| 488 | + */ | |
| 489 | + public void start() { | |
| 490 | + } | |
| 491 | + | |
| 492 | + /** | |
| 493 | + * Called by the browser or applet viewer to inform | |
| 494 | + * this applet that it should stop its execution. It is called when | |
| 495 | + * the Web page that contains this applet has been replaced by | |
| 496 | + * another page, and also just before the applet is to be destroyed. | |
| 497 | + * <p> | |
| 498 | + * A subclass of <code>Applet</code> should override this method if | |
| 499 | + * it has any operation that it wants to perform each time the Web | |
| 500 | + * page containing it is no longer visible. For example, an applet | |
| 501 | + * with animation might want to use the <code>start</code> method to | |
| 502 | + * resume animation, and the <code>stop</code> method to suspend the | |
| 503 | + * animation. | |
| 504 | + * <p> | |
| 505 | + * The implementation of this method provided by the | |
| 506 | + * <code>Applet</code> class does nothing. | |
| 507 | + * | |
| 508 | + * @see java.applet.Applet#destroy() | |
| 509 | + * @see java.applet.Applet#init() | |
| 510 | + */ | |
| 511 | + public void stop() { | |
| 512 | + } | |
| 513 | + | |
| 514 | + /** | |
| 515 | + * Called by the browser or applet viewer to inform | |
| 516 | + * this applet that it is being reclaimed and that it should destroy | |
| 517 | + * any resources that it has allocated. The <code>stop</code> method | |
| 518 | + * will always be called before <code>destroy</code>. | |
| 519 | + * <p> | |
| 520 | + * A subclass of <code>Applet</code> should override this method if | |
| 521 | + * it has any operation that it wants to perform before it is | |
| 522 | + * destroyed. For example, an applet with threads would use the | |
| 523 | + * <code>init</code> method to create the threads and the | |
| 524 | + * <code>destroy</code> method to kill them. | |
| 525 | + * <p> | |
| 526 | + * The implementation of this method provided by the | |
| 527 | + * <code>Applet</code> class does nothing. | |
| 528 | + * | |
| 529 | + * @see java.applet.Applet#init() | |
| 530 | + * @see java.applet.Applet#start() | |
| 531 | + * @see java.applet.Applet#stop() | |
| 532 | + */ | |
| 533 | + public void destroy() { | |
| 534 | + } | |
| 535 | + | |
| 536 | + // | |
| 537 | + // Accessibility support | |
| 538 | + // | |
| 539 | + | |
| 540 | + AccessibleContext accessibleContext = null; | |
| 541 | + | |
| 542 | + /** | |
| 543 | + * Gets the AccessibleContext associated with this Applet. | |
| 544 | + * For applets, the AccessibleContext takes the form of an | |
| 545 | + * AccessibleApplet. | |
| 546 | + * A new AccessibleApplet instance is created if necessary. | |
| 547 | + * | |
| 548 | + * @return an AccessibleApplet that serves as the | |
| 549 | + * AccessibleContext of this Applet | |
| 550 | + * @since 1.3 | |
| 551 | + */ | |
| 552 | + public AccessibleContext getAccessibleContext() { | |
| 553 | + if (accessibleContext == null) { | |
| 554 | + accessibleContext = new AccessibleApplet(); | |
| 555 | + } | |
| 556 | + return accessibleContext; | |
| 557 | + } | |
| 558 | + | |
| 559 | + /** | |
| 560 | + * This class implements accessibility support for the | |
| 561 | + * <code>Applet</code> class. It provides an implementation of the | |
| 562 | + * Java Accessibility API appropriate to applet user-interface elements. | |
| 563 | + * @since 1.3 | |
| 564 | + */ | |
| 565 | + protected class AccessibleApplet extends AccessibleAWTPanel { | |
| 566 | + | |
| 567 | + private static final long serialVersionUID = 8127374778187708896L; | |
| 568 | + | |
| 569 | + /** | |
| 570 | + * Get the role of this object. | |
| 571 | + * | |
| 572 | + * @return an instance of AccessibleRole describing the role of the | |
| 573 | + * object | |
| 574 | + */ | |
| 575 | + public AccessibleRole getAccessibleRole() { | |
| 576 | + return AccessibleRole.FRAME; | |
| 577 | + } | |
| 578 | + | |
| 579 | + /** | |
| 580 | + * Get the state of this object. | |
| 581 | + * | |
| 582 | + * @return an instance of AccessibleStateSet containing the current | |
| 583 | + * state set of the object | |
| 584 | + * @see AccessibleState | |
| 585 | + */ | |
| 586 | + public AccessibleStateSet getAccessibleStateSet() { | |
| 587 | + AccessibleStateSet states = super.getAccessibleStateSet(); | |
| 588 | + states.add(AccessibleState.ACTIVE); | |
| 589 | + return states; | |
| 590 | + } | |
| 591 | + | |
| 592 | + } | |
| 593 | +} | |
| @@ -0,0 +1,194 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. | |
| 4 | + * | |
| 5 | + * | |
| 6 | + * | |
| 7 | + * | |
| 8 | + * | |
| 9 | + * | |
| 10 | + * | |
| 11 | + * | |
| 12 | + * | |
| 13 | + * | |
| 14 | + * | |
| 15 | + * | |
| 16 | + * | |
| 17 | + * | |
| 18 | + * | |
| 19 | + * | |
| 20 | + * | |
| 21 | + * | |
| 22 | + * | |
| 23 | + * | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.applet; | |
| 27 | + | |
| 28 | +import java.awt.Image; | |
| 29 | +import java.awt.Graphics; | |
| 30 | +import java.awt.image.ColorModel; | |
| 31 | +import java.net.URL; | |
| 32 | +import java.util.Enumeration; | |
| 33 | +import java.io.InputStream; | |
| 34 | +import java.io.IOException; | |
| 35 | +import java.util.Iterator; | |
| 36 | + | |
| 37 | +/** | |
| 38 | + * This interface corresponds to an applet's environment: the | |
| 39 | + * document containing the applet and the other applets in the same | |
| 40 | + * document. | |
| 41 | + * <p> | |
| 42 | + * The methods in this interface can be used by an applet to obtain | |
| 43 | + * information about its environment. | |
| 44 | + * | |
| 45 | + * @author Arthur van Hoff | |
| 46 | + * @since JDK1.0 | |
| 47 | + */ | |
| 48 | +public interface AppletContext { | |
| 49 | + /** | |
| 50 | + * Creates an audio clip. | |
| 51 | + * | |
| 52 | + * @param url an absolute URL giving the location of the audio clip. | |
| 53 | + * @return the audio clip at the specified URL. | |
| 54 | + */ | |
| 55 | + AudioClip getAudioClip(URL url); | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * Returns an <code>Image</code> object that can then be painted on | |
| 59 | + * the screen. The <code>url</code> argument<code> </code>that is | |
| 60 | + * passed as an argument must specify an absolute URL. | |
| 61 | + * <p> | |
| 62 | + * This method always returns immediately, whether or not the image | |
| 63 | + * exists. When the applet attempts to draw the image on the screen, | |
| 64 | + * the data will be loaded. The graphics primitives that draw the | |
| 65 | + * image will incrementally paint on the screen. | |
| 66 | + * | |
| 67 | + * @param url an absolute URL giving the location of the image. | |
| 68 | + * @return the image at the specified URL. | |
| 69 | + * @see java.awt.Image | |
| 70 | + */ | |
| 71 | + Image getImage(URL url); | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * Finds and returns the applet in the document represented by this | |
| 75 | + * applet context with the given name. The name can be set in the | |
| 76 | + * HTML tag by setting the <code>name</code> attribute. | |
| 77 | + * | |
| 78 | + * @param name an applet name. | |
| 79 | + * @return the applet with the given name, or <code>null</code> if | |
| 80 | + * not found. | |
| 81 | + */ | |
| 82 | + Applet getApplet(String name); | |
| 83 | + | |
| 84 | + /** | |
| 85 | + * Finds all the applets in the document represented by this applet | |
| 86 | + * context. | |
| 87 | + * | |
| 88 | + * @return an enumeration of all applets in the document represented by | |
| 89 | + * this applet context. | |
| 90 | + */ | |
| 91 | + Enumeration<Applet> getApplets(); | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * Requests that the browser or applet viewer show the Web page | |
| 95 | + * indicated by the <code>url</code> argument. The browser or | |
| 96 | + * applet viewer determines which window or frame to display the | |
| 97 | + * Web page. This method may be ignored by applet contexts that | |
| 98 | + * are not browsers. | |
| 99 | + * | |
| 100 | + * @param url an absolute URL giving the location of the document. | |
| 101 | + */ | |
| 102 | + void showDocument(URL url); | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * Requests that the browser or applet viewer show the Web page | |
| 106 | + * indicated by the <code>url</code> argument. The | |
| 107 | + * <code>target</code> argument indicates in which HTML frame the | |
| 108 | + * document is to be displayed. | |
| 109 | + * The target argument is interpreted as follows: | |
| 110 | + * <p> | |
| 111 | + * <center><table border="3" summary="Target arguments and their descriptions"> | |
| 112 | + * <tr><th>Target Argument</th><th>Description</th></tr> | |
| 113 | + * <tr><td><code>"_self"</code> <td>Show in the window and frame that | |
| 114 | + * contain the applet.</tr> | |
| 115 | + * <tr><td><code>"_parent"</code><td>Show in the applet's parent frame. If | |
| 116 | + * the applet's frame has no parent frame, | |
| 117 | + * acts the same as "_self".</tr> | |
| 118 | + * <tr><td><code>"_top"</code> <td>Show in the top-level frame of the applet's | |
| 119 | + * window. If the applet's frame is the | |
| 120 | + * top-level frame, acts the same as "_self".</tr> | |
| 121 | + * <tr><td><code>"_blank"</code> <td>Show in a new, unnamed | |
| 122 | + * top-level window.</tr> | |
| 123 | + * <tr><td><i>name</i><td>Show in the frame or window named <i>name</i>. If | |
| 124 | + * a target named <i>name</i> does not already exist, a | |
| 125 | + * new top-level window with the specified name is created, | |
| 126 | + * and the document is shown there.</tr> | |
| 127 | + * </table> </center> | |
| 128 | + * <p> | |
| 129 | + * An applet viewer or browser is free to ignore <code>showDocument</code>. | |
| 130 | + * | |
| 131 | + * @param url an absolute URL giving the location of the document. | |
| 132 | + * @param target a <code>String</code> indicating where to display | |
| 133 | + * the page. | |
| 134 | + */ | |
| 135 | + public void showDocument(URL url, String target); | |
| 136 | + | |
| 137 | + /** | |
| 138 | + * Requests that the argument string be displayed in the | |
| 139 | + * "status window". Many browsers and applet viewers | |
| 140 | + * provide such a window, where the application can inform users of | |
| 141 | + * its current state. | |
| 142 | + * | |
| 143 | + * @param status a string to display in the status window. | |
| 144 | + */ | |
| 145 | + void showStatus(String status); | |
| 146 | + | |
| 147 | + /** | |
| 148 | + * Associates the specified stream with the specified key in this | |
| 149 | + * applet context. If the applet context previously contained a mapping | |
| 150 | + * for this key, the old value is replaced. | |
| 151 | + * <p> | |
| 152 | + * For security reasons, mapping of streams and keys exists for each | |
| 153 | + * codebase. In other words, applet from one codebase cannot access | |
| 154 | + * the streams created by an applet from a different codebase | |
| 155 | + * <p> | |
| 156 | + * @param key key with which the specified value is to be associated. | |
| 157 | + * @param stream stream to be associated with the specified key. If this | |
| 158 | + * parameter is <code>null</code>, the specified key is removed | |
| 159 | + * in this applet context. | |
| 160 | + * @throws <code>IOException</code> if the stream size exceeds a certain | |
| 161 | + * size limit. Size limit is decided by the implementor of this | |
| 162 | + * interface. | |
| 163 | + * @since 1.4 | |
| 164 | + */ | |
| 165 | + public void setStream(String key, InputStream stream)throws IOException; | |
| 166 | + | |
| 167 | + /** | |
| 168 | + * Returns the stream to which specified key is associated within this | |
| 169 | + * applet context. Returns <tt>null</tt> if the applet context contains | |
| 170 | + * no stream for this key. | |
| 171 | + * <p> | |
| 172 | + * For security reasons, mapping of streams and keys exists for each | |
| 173 | + * codebase. In other words, applet from one codebase cannot access | |
| 174 | + * the streams created by an applet from a different codebase | |
| 175 | + * <p> | |
| 176 | + * @return the stream to which this applet context maps the key | |
| 177 | + * @param key key whose associated stream is to be returned. | |
| 178 | + * @since 1.4 | |
| 179 | + */ | |
| 180 | + public InputStream getStream(String key); | |
| 181 | + | |
| 182 | + /** | |
| 183 | + * Finds all the keys of the streams in this applet context. | |
| 184 | + * <p> | |
| 185 | + * For security reasons, mapping of streams and keys exists for each | |
| 186 | + * codebase. In other words, applet from one codebase cannot access | |
| 187 | + * the streams created by an applet from a different codebase | |
| 188 | + * <p> | |
| 189 | + * @return an Iterator of all the names of the streams in this applet | |
| 190 | + * context. | |
| 191 | + * @since 1.4 | |
| 192 | + */ | |
| 193 | + public Iterator<String> getStreamKeys(); | |
| 194 | +} | |
| @@ -0,0 +1,111 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. | |
| 4 | + * | |
| 5 | + * | |
| 6 | + * | |
| 7 | + * | |
| 8 | + * | |
| 9 | + * | |
| 10 | + * | |
| 11 | + * | |
| 12 | + * | |
| 13 | + * | |
| 14 | + * | |
| 15 | + * | |
| 16 | + * | |
| 17 | + * | |
| 18 | + * | |
| 19 | + * | |
| 20 | + * | |
| 21 | + * | |
| 22 | + * | |
| 23 | + * | |
| 24 | + */ | |
| 25 | +package java.applet; | |
| 26 | + | |
| 27 | +import java.net.URL; | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * When an applet is first created, an applet stub is attached to it | |
| 31 | + * using the applet's <code>setStub</code> method. This stub | |
| 32 | + * serves as the interface between the applet and the browser | |
| 33 | + * environment or applet viewer environment in which the application | |
| 34 | + * is running. | |
| 35 | + * | |
| 36 | + * @author Arthur van Hoff | |
| 37 | + * @see java.applet.Applet#setStub(java.applet.AppletStub) | |
| 38 | + * @since JDK1.0 | |
| 39 | + */ | |
| 40 | +public interface AppletStub { | |
| 41 | + /** | |
| 42 | + * Determines if the applet is active. An applet is active just | |
| 43 | + * before its <code>start</code> method is called. It becomes | |
| 44 | + * inactive just before its <code>stop</code> method is called. | |
| 45 | + * | |
| 46 | + * @return <code>true</code> if the applet is active; | |
| 47 | + * <code>false</code> otherwise. | |
| 48 | + */ | |
| 49 | + boolean isActive(); | |
| 50 | + | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Gets the URL of the document in which the applet is embedded. | |
| 54 | + * For example, suppose an applet is contained | |
| 55 | + * within the document: | |
| 56 | + * <blockquote><pre> | |
| 57 | + * http://java.sun.com/products/jdk/1.2/index.html | |
| 58 | + * </pre></blockquote> | |
| 59 | + * The document base is: | |
| 60 | + * <blockquote><pre> | |
| 61 | + * http://java.sun.com/products/jdk/1.2/index.html | |
| 62 | + * </pre></blockquote> | |
| 63 | + * | |
| 64 | + * @return the {@link java.net.URL} of the document that contains the | |
| 65 | + * applet. | |
| 66 | + * @see java.applet.AppletStub#getCodeBase() | |
| 67 | + */ | |
| 68 | + URL getDocumentBase(); | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Gets the base URL. This is the URL of the directory which contains the applet. | |
| 72 | + * | |
| 73 | + * @return the base {@link java.net.URL} of | |
| 74 | + * the directory which contains the applet. | |
| 75 | + * @see java.applet.AppletStub#getDocumentBase() | |
| 76 | + */ | |
| 77 | + URL getCodeBase(); | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * Returns the value of the named parameter in the HTML tag. For | |
| 81 | + * example, if an applet is specified as | |
| 82 | + * <blockquote><pre> | |
| 83 | + * <applet code="Clock" width=50 height=50> | |
| 84 | + * <param name=Color value="blue"> | |
| 85 | + * </applet> | |
| 86 | + * </pre></blockquote> | |
| 87 | + * <p> | |
| 88 | + * then a call to <code>getParameter("Color")</code> returns the | |
| 89 | + * value <code>"blue"</code>. | |
| 90 | + * | |
| 91 | + * @param name a parameter name. | |
| 92 | + * @return the value of the named parameter, | |
| 93 | + * or <tt>null</tt> if not set. | |
| 94 | + */ | |
| 95 | + String getParameter(String name); | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * Returns the applet's context. | |
| 99 | + * | |
| 100 | + * @return the applet's context. | |
| 101 | + */ | |
| 102 | + AppletContext getAppletContext(); | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * Called when the applet wants to be resized. | |
| 106 | + * | |
| 107 | + * @param width the new requested width for the applet. | |
| 108 | + * @param height the new requested height for the applet. | |
| 109 | + */ | |
| 110 | + void appletResize(int width, int height); | |
| 111 | +} | |
| @@ -0,0 +1,53 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. | |
| 4 | + * | |
| 5 | + * | |
| 6 | + * | |
| 7 | + * | |
| 8 | + * | |
| 9 | + * | |
| 10 | + * | |
| 11 | + * | |
| 12 | + * | |
| 13 | + * | |
| 14 | + * | |
| 15 | + * | |
| 16 | + * | |
| 17 | + * | |
| 18 | + * | |
| 19 | + * | |
| 20 | + * | |
| 21 | + * | |
| 22 | + * | |
| 23 | + * | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.applet; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * The <code>AudioClip</code> interface is a simple abstraction for | |
| 30 | + * playing a sound clip. Multiple <code>AudioClip</code> items can be | |
| 31 | + * playing at the same time, and the resulting sound is mixed | |
| 32 | + * together to produce a composite. | |
| 33 | + * | |
| 34 | + * @author Arthur van Hoff | |
| 35 | + * @since JDK1.0 | |
| 36 | + */ | |
| 37 | +public interface AudioClip { | |
| 38 | + /** | |
| 39 | + * Starts playing this audio clip. Each time this method is called, | |
| 40 | + * the clip is restarted from the beginning. | |
| 41 | + */ | |
| 42 | + void play(); | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * Starts playing this audio clip in a loop. | |
| 46 | + */ | |
| 47 | + void loop(); | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * Stops playing this audio clip. | |
| 51 | + */ | |
| 52 | + void stop(); | |
| 53 | +} | |
| @@ -0,0 +1,11 @@ | ||
| 1 | +<../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + Applet.dis\ | |
| 5 | + AppletContext.dis\ | |
| 6 | + AppletStub.dis\ | |
| 7 | + AudioClip.dis\ | |
| 8 | + | |
| 9 | +DISBIN=$ROOT/java/dis/java/java/applet | |
| 10 | + | |
| 11 | +<$ROOT/mkfiles/mkjava | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,5 @@ | ||
| 1 | + | |
| 2 | +package java.awt; | |
| 3 | + | |
| 4 | +public interface ActionInputPreferred { | |
| 5 | +} | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,5 @@ | ||
| 1 | + | |
| 2 | +package java.awt; | |
| 3 | + | |
| 4 | +public interface KeyboardInputPreferred { | |
| 5 | +} | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,95 @@ | ||
| 1 | +package java.awt; | |
| 2 | + | |
| 3 | +import java.awt.*; | |
| 4 | + | |
| 5 | +public class Misc { | |
| 6 | + | |
| 7 | + public static void drawDisabledString(String label,int x,int y,Graphics g) | |
| 8 | + { | |
| 9 | + Color c=g.getColor(); | |
| 10 | + g.setColor(SystemColor.controlLtHighlight); | |
| 11 | + g.drawString(label,x+1,y+1); | |
| 12 | + g.setColor(SystemColor.controlShadow); | |
| 13 | + g.drawString(label,x,y); | |
| 14 | + g.setColor(c); | |
| 15 | + } | |
| 16 | + | |
| 17 | + public static void fill3DRect(int x,int y,int width,int height,boolean raised,Graphics g) | |
| 18 | + { | |
| 19 | + fill3DRect(new Rectangle(x,y,width,height),raised,g); | |
| 20 | + } | |
| 21 | + | |
| 22 | + public static void fill3DRect(Rectangle area,boolean raised,Graphics g) | |
| 23 | + { | |
| 24 | + int left=area.x; | |
| 25 | + int top=area.y; | |
| 26 | + int bottom=top+area.height-1; | |
| 27 | + int right=left+area.width-1; | |
| 28 | + | |
| 29 | + Color c=g.getColor(); | |
| 30 | + | |
| 31 | + g.setColor(raised?SystemColor.controlLtHighlight:SystemColor.controlShadow); | |
| 32 | + | |
| 33 | + g.drawLine(left,top,right-1,top); | |
| 34 | + g.drawLine(left,top+1,left,bottom); | |
| 35 | + | |
| 36 | + g.setColor(raised?SystemColor.controlShadow:SystemColor.controlLtHighlight); | |
| 37 | + | |
| 38 | + g.drawLine(right,bottom,right,top); | |
| 39 | + g.drawLine(right-1,bottom,left+1,bottom); | |
| 40 | + | |
| 41 | + g.setColor(c); | |
| 42 | + | |
| 43 | + g.fillRect(left+1,top+1,area.width-2,area.height-2); | |
| 44 | + | |
| 45 | + } | |
| 46 | + | |
| 47 | + | |
| 48 | + public static void Draw3DArea(int x,int y,int width,int height,Graphics g) | |
| 49 | + { | |
| 50 | + Draw3DArea(new Rectangle(x,y,width,height),g); | |
| 51 | + } | |
| 52 | + | |
| 53 | + public static void Draw3DArea(Rectangle area,Graphics g) | |
| 54 | + { | |
| 55 | + int left=area.x; | |
| 56 | + int top=area.y; | |
| 57 | + int bottom=top+area.height-1; | |
| 58 | + int right=left+area.width-1; | |
| 59 | + | |
| 60 | + g.setColor(SystemColor.controlHighlight); | |
| 61 | + g.drawLine(left,top,left,bottom-1); | |
| 62 | + g.drawLine(left,top,right-1,top); | |
| 63 | + | |
| 64 | + g.setColor(SystemColor.controlLtHighlight); | |
| 65 | + g.drawLine(left+1, top+1, right-2, top+1); | |
| 66 | + g.drawLine(left+1, top+2, left+1, bottom-2); | |
| 67 | + | |
| 68 | + g.setColor(SystemColor.controlShadow); | |
| 69 | + g.drawLine(right-1, top+1, right-1, bottom-1); | |
| 70 | + g.drawLine(left+1, bottom-1, right-1, bottom-1); | |
| 71 | + | |
| 72 | + g.setColor(SystemColor.controlDkShadow); | |
| 73 | + g.drawLine(right, top, right, bottom); | |
| 74 | + g.drawLine(left, bottom, right, bottom); | |
| 75 | + | |
| 76 | + | |
| 77 | + } | |
| 78 | + | |
| 79 | + | |
| 80 | + public static void drawTick(Graphics g,int x,int y,int boxsize) | |
| 81 | + | |
| 82 | + { | |
| 83 | + int tickWidth=(boxsize-4)/3; | |
| 84 | + for (int off=0;off<tickWidth;off++) | |
| 85 | + { | |
| 86 | + g.drawLine(x+3,y+boxsize-3-tickWidth-off,x+tickWidth+2,y+boxsize-4-off); | |
| 87 | + g.drawLine(x+tickWidth+3,y+boxsize-5-off,x+boxsize-4,y+tickWidth+2-off); | |
| 88 | + } | |
| 89 | + } | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | +} | |
| 95 | + | |
| @@ -0,0 +1,5 @@ | ||
| 1 | + | |
| 2 | +package java.awt; | |
| 3 | + | |
| 4 | +public interface NoInputPreferred { | |
| 5 | +} | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,5 @@ | ||
| 1 | + | |
| 2 | +package java.awt; | |
| 3 | + | |
| 4 | +public interface PositionalInputPreferred { | |
| 5 | +} | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,17 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + Clipboard.dis\ | |
| 5 | + ClipboardOwner.dis\ | |
| 6 | + DataFlavor.dis\ | |
| 7 | + StringSelection.dis\ | |
| 8 | + Transferable.dis\ | |
| 9 | +# for UnsupportedFlavorException.dis\ | |
| 10 | + XJ67lvo7CEuYBAk8ihSb4.dis\ | |
| 11 | + | |
| 12 | +DISBIN=$ROOT/java/dis/java/java/awt/datatransfer | |
| 13 | + | |
| 14 | +<$ROOT/mkfiles/mkjava | |
| 15 | + | |
| 16 | +XJ67lvo7CEuYBAk8ihSb4.dis: UnsupportedFlavorException.class | |
| 17 | + j2d $prereq | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,37 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + ActionEvent.dis\ | |
| 5 | + ActionListener.dis\ | |
| 6 | + AdjustmentEvent.dis\ | |
| 7 | + AdjustmentListener.dis\ | |
| 8 | + ComponentAdapter.dis\ | |
| 9 | + ComponentEvent.dis\ | |
| 10 | + ComponentListener.dis\ | |
| 11 | + ContainerAdapter.dis\ | |
| 12 | + ContainerEvent.dis\ | |
| 13 | + ContainerListener.dis\ | |
| 14 | + FocusAdapter.dis\ | |
| 15 | + FocusEvent.dis\ | |
| 16 | + FocusListener.dis\ | |
| 17 | + InputEvent.dis\ | |
| 18 | + ItemEvent.dis\ | |
| 19 | + ItemListener.dis\ | |
| 20 | + KeyAdapter.dis\ | |
| 21 | + KeyEvent.dis\ | |
| 22 | + KeyListener.dis\ | |
| 23 | + MouseAdapter.dis\ | |
| 24 | + MouseEvent.dis\ | |
| 25 | + MouseListener.dis\ | |
| 26 | + MouseMotionAdapter.dis\ | |
| 27 | + MouseMotionListener.dis\ | |
| 28 | + PaintEvent.dis\ | |
| 29 | + TextEvent.dis\ | |
| 30 | + TextListener.dis\ | |
| 31 | + WindowAdapter.dis\ | |
| 32 | + WindowEvent.dis\ | |
| 33 | + WindowListener.dis\ | |
| 34 | + | |
| 35 | +DISBIN=$ROOT/java/dis/java/java/awt/event | |
| 36 | + | |
| 37 | +<$ROOT/mkfiles/mkjava | |
Empty file added.
Empty file added.
| @@ -0,0 +1,49 @@ | ||
| 1 | +implement ColorModel_L; | |
| 2 | + | |
| 3 | +# javal v1.4 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +include "java/lang/ClassLoader_L.m"; | |
| 28 | + | |
| 29 | +#<< | |
| 30 | + | |
| 31 | +include "ColorModel_L.m"; | |
| 32 | + | |
| 33 | +#>> extra post includes here | |
| 34 | + | |
| 35 | +#<< | |
| 36 | + | |
| 37 | +init( jni_p : JNI ) | |
| 38 | +{ | |
| 39 | + # save java native inteface mod instance | |
| 40 | + jni = jni_p; | |
| 41 | + #>>extra initialization here | |
| 42 | + #<< | |
| 43 | +} | |
| 44 | + | |
| 45 | +deletepData_V( this : ref ColorModel_obj) | |
| 46 | +{#>> | |
| 47 | + this.pData = 0; | |
| 48 | +}#<< | |
| 49 | + | |
| @@ -0,0 +1,15 @@ | ||
| 1 | +# javal v1.4 generated file: edit with care | |
| 2 | + | |
| 3 | +ColorModel_L : module | |
| 4 | +{ | |
| 5 | + ColorModel_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + pData : int; | |
| 9 | + pixel_bits : int; | |
| 10 | + }; | |
| 11 | + | |
| 12 | + init : fn( jni_p : JNI ); | |
| 13 | + deletepData_V : fn( this : ref ColorModel_obj); | |
| 14 | + | |
| 15 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,46 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | +# for AreaAveragingScaleFilter.dis\ | |
| 5 | + CEw7djK-zeE4-ezmJIAZ+.dis\ | |
| 6 | + ColorModel.dis\ | |
| 7 | + CropImageFilter.dis\ | |
| 8 | + DirectColorModel.dis\ | |
| 9 | + FilteredImageSource.dis\ | |
| 10 | + ImageConsumer.dis\ | |
| 11 | + ImageFilter.dis\ | |
| 12 | + ImageObserver.dis\ | |
| 13 | + ImageProducer.dis\ | |
| 14 | + IndexColorModel.dis\ | |
| 15 | + MemoryImageSource.dis\ | |
| 16 | + PixelGrabber.dis\ | |
| 17 | + RGBImageFilter.dis\ | |
| 18 | + ReplicateScaleFilter.dis\ | |
| 19 | +# Limbo code\ | |
| 20 | + ColorModel_L.dis\ | |
| 21 | + | |
| 22 | +MODULES=\ | |
| 23 | + $ROOT/java/module/classloader.m\ | |
| 24 | + $ROOT/java/module/jni.m\ | |
| 25 | + $ROOT/java/module/cast.m\ | |
| 26 | + ColorModel_L.m\ | |
| 27 | + | |
| 28 | +SYSMODULES=\ | |
| 29 | + draw.m\ | |
| 30 | + hash.m\ | |
| 31 | + keyring.m\ | |
| 32 | + loader.m\ | |
| 33 | + math.m\ | |
| 34 | + string.m\ | |
| 35 | + sys.m\ | |
| 36 | + | |
| 37 | +DISBIN=$ROOT/java/dis/java/java/awt/image | |
| 38 | + | |
| 39 | +<$ROOT/mkfiles/mkjava | |
| 40 | + | |
| 41 | +LIMBOINCL=\ | |
| 42 | + $LIMBOINCL\ | |
| 43 | + -I$ROOT/java/pkg\ | |
| 44 | + | |
| 45 | +CEw7djK-zeE4-ezmJIAZ+.dis: AreaAveragingScaleFilter.class | |
| 46 | + j2d AreaAveragingScaleFilter.class | |
| @@ -0,0 +1,138 @@ | ||
| 1 | +<../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + event\ | |
| 5 | + datatransfer\ | |
| 6 | + image\ | |
| 7 | + peer\ | |
| 8 | + | |
| 9 | +TARG=\ | |
| 10 | + AWTError.dis\ | |
| 11 | + AWTEvent.dis\ | |
| 12 | + AWTEventMulticaster.dis\ | |
| 13 | + AWTException.dis\ | |
| 14 | + ActionInputPreferred.dis\ | |
| 15 | + Adjustable.dis\ | |
| 16 | + BorderLayout.dis\ | |
| 17 | + Button.dis\ | |
| 18 | + Canvas.dis\ | |
| 19 | + CardLayout.dis\ | |
| 20 | + Checkbox.dis\ | |
| 21 | + CheckboxGroup.dis\ | |
| 22 | + CheckboxMenuItem.dis\ | |
| 23 | + Choice.dis\ | |
| 24 | + Choice\$MenuWindow.dis\ | |
| 25 | + Color.dis\ | |
| 26 | + Component.dis\ | |
| 27 | +# for Component\$NativeInLightFixer.dis\ | |
| 28 | + uU+tI9EeZru56jt4ABTyZ.dis\ | |
| 29 | + Container.dis\ | |
| 30 | + Cursor.dis\ | |
| 31 | + Dialog.dis\ | |
| 32 | + Dimension.dis\ | |
| 33 | + Event.dis\ | |
| 34 | + EventDispatchThread.dis\ | |
| 35 | + EventQueue.dis\ | |
| 36 | + EventQueueItem.dis\ | |
| 37 | + FileDialog.dis\ | |
| 38 | + FlowLayout.dis\ | |
| 39 | + FocusManager.dis\ | |
| 40 | + Font.dis\ | |
| 41 | + FontMetrics.dis\ | |
| 42 | + Frame.dis\ | |
| 43 | + Graphics.dis\ | |
| 44 | + GridBagConstraints.dis\ | |
| 45 | + GridBagLayout.dis\ | |
| 46 | + GridBagLayoutInfo.dis\ | |
| 47 | + GridLayout.dis\ | |
| 48 | +# for IllegalComponentStateException.dis\ | |
| 49 | + 0xdZMaDu4YDn6Gv1ojXOi.dis\ | |
| 50 | + Image.dis\ | |
| 51 | + ImageMediaEntry.dis\ | |
| 52 | + Insets.dis\ | |
| 53 | + ItemSelectable.dis\ | |
| 54 | +# for KeyboardInputPreferred.dis\ | |
| 55 | + tZW2Nc+oIyd6dX0M-UilD.dis\ | |
| 56 | + Label.dis\ | |
| 57 | + LayoutManager.dis\ | |
| 58 | + LayoutManager2.dis\ | |
| 59 | + LightweightDispatcher.dis\ | |
| 60 | + LightweightPeer.dis\ | |
| 61 | + List.dis\ | |
| 62 | + MediaEntry.dis\ | |
| 63 | + MediaTracker.dis\ | |
| 64 | + Menu.dis\ | |
| 65 | + MenuBar.dis\ | |
| 66 | + MenuComponent.dis\ | |
| 67 | + MenuContainer.dis\ | |
| 68 | + MenuItem.dis\ | |
| 69 | + MenuShortcut.dis\ | |
| 70 | + Misc.dis\ | |
| 71 | + NoInputPreferred.dis\ | |
| 72 | + Panel.dis\ | |
| 73 | + Point.dis\ | |
| 74 | + Polygon.dis\ | |
| 75 | + PopupMenu.dis\ | |
| 76 | +# for PositionalInputPreferred.dis\ | |
| 77 | + 8AdFAaM7LI8fj1v6d+cNK.dis\ | |
| 78 | + PrintGraphics.dis\ | |
| 79 | + PrintJob.dis\ | |
| 80 | + Rectangle.dis\ | |
| 81 | + ScrollPane.dis\ | |
| 82 | + ScrollPane\$PeerFixer.dis\ | |
| 83 | + ScrollPaneAdjustable.dis\ | |
| 84 | + Scrollbar.dis\ | |
| 85 | + Shape.dis\ | |
| 86 | + SystemColor.dis\ | |
| 87 | + TextArea.dis\ | |
| 88 | + TextComponent.dis\ | |
| 89 | + TextField.dis\ | |
| 90 | + Toolkit.dis\ | |
| 91 | + Window.dis\ | |
| 92 | + | |
| 93 | +DISBIN=$ROOT/java/dis/java/java/awt | |
| 94 | + | |
| 95 | +<$ROOT/mkfiles/mkjava | |
| 96 | +<$ROOT/mkfiles/mksubdirs | |
| 97 | + | |
| 98 | +Choice\$MenuWindow.dis: Choice.class | |
| 99 | + j2d Choice\$MenuWindow.class | |
| 100 | + | |
| 101 | +uU+tI9EeZru56jt4ABTyZ.dis: Component.class | |
| 102 | + j2d Component\$NativeInLightFixer.class | |
| 103 | + | |
| 104 | +LightweightDispatcher.dis: Container.class | |
| 105 | + j2d LightweightDispatcher.class | |
| 106 | + | |
| 107 | +EventQueueItem.dis: EventQueue.class | |
| 108 | + j2d EventQueueItem.class | |
| 109 | + | |
| 110 | +GridBagLayoutInfo.dis: GridBagLayout.class | |
| 111 | + j2d GridBagLayoutInfo.class | |
| 112 | + | |
| 113 | +0xdZMaDu4YDn6Gv1ojXOi.dis: IllegalComponentStateException.class | |
| 114 | + j2d $prereq | |
| 115 | + | |
| 116 | +tZW2Nc+oIyd6dX0M-UilD.dis: KeyboardInputPreferred.class | |
| 117 | + j2d $prereq | |
| 118 | + | |
| 119 | +ImageMediaEntry.dis: MediaTracker.class | |
| 120 | + j2d ImageMediaEntry.class | |
| 121 | + | |
| 122 | +MediaEntry.dis: MediaTracker.class | |
| 123 | + j2d MediaEntry.class | |
| 124 | + | |
| 125 | +8AdFAaM7LI8fj1v6d+cNK.dis: PositionalInputPreferred.class | |
| 126 | + j2d $prereq | |
| 127 | + | |
| 128 | +ScrollPane\$PeerFixer.dis: ScrollPane.class | |
| 129 | + j2d ScrollPane\$PeerFixer.class | |
| 130 | + | |
| 131 | +ScrollPaneAdjustable.dis: ScrollPane.class | |
| 132 | + j2d ScrollPaneAdjustable.class | |
| 133 | + | |
| 134 | +LightweightPeer.dis: Toolkit.class | |
| 135 | + j2d LightweightPeer.class | |
| 136 | + | |
| 137 | +FocusManager.dis: Window.class | |
| 138 | + j2d FocusManager.class | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,6 @@ | ||
| 1 | + | |
| 2 | +package java.awt.peer; | |
| 3 | + | |
| 4 | +public interface DoubleBufferingPeer { | |
| 5 | + public boolean isDoubleBuffered(); | |
| 6 | +} | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,35 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + ActiveEvent.dis\ | |
| 5 | + ButtonPeer.dis\ | |
| 6 | + CanvasPeer.dis\ | |
| 7 | + CheckboxMenuItemPeer.dis\ | |
| 8 | + CheckboxPeer.dis\ | |
| 9 | + ChoicePeer.dis\ | |
| 10 | + ComponentPeer.dis\ | |
| 11 | + ContainerPeer.dis\ | |
| 12 | + DialogPeer.dis\ | |
| 13 | + DoubleBufferingPeer.dis\ | |
| 14 | + FileDialogPeer.dis\ | |
| 15 | + FontPeer.dis\ | |
| 16 | + FramePeer.dis\ | |
| 17 | + LabelPeer.dis\ | |
| 18 | + LightweightPeer.dis\ | |
| 19 | + ListPeer.dis\ | |
| 20 | + MenuBarPeer.dis\ | |
| 21 | + MenuComponentPeer.dis\ | |
| 22 | + MenuItemPeer.dis\ | |
| 23 | + MenuPeer.dis\ | |
| 24 | + PanelPeer.dis\ | |
| 25 | + PopupMenuPeer.dis\ | |
| 26 | + ScrollPanePeer.dis\ | |
| 27 | + ScrollbarPeer.dis\ | |
| 28 | + TextAreaPeer.dis\ | |
| 29 | + TextComponentPeer.dis\ | |
| 30 | + TextFieldPeer.dis\ | |
| 31 | + WindowPeer.dis\ | |
| 32 | + | |
| 33 | +DISBIN=$ROOT/java/dis/java/java/awt/peer | |
| 34 | + | |
| 35 | +<$ROOT/mkfiles/mkjava | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,63 @@ | ||
| 1 | +<../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + BeanDescriptor.dis\ | |
| 5 | + BeanInfo.dis\ | |
| 6 | + Beans.dis\ | |
| 7 | + BeansAppletContext.dis\ | |
| 8 | + BeansAppletStub.dis\ | |
| 9 | + Customizer.dis\ | |
| 10 | + EventSetDescriptor.dis\ | |
| 11 | + FeatureDescriptor.dis\ | |
| 12 | + GenericBeanInfo.dis\ | |
| 13 | +# for IndexedPropertyDescriptor.dis\ | |
| 14 | + ilsoQHwwPML2uGzS7a9sz.dis\ | |
| 15 | +# for IntrospectionException.dis\ | |
| 16 | + kKxvl0RXJ9GHO1gHFFNvw.dis\ | |
| 17 | + Introspector.dis\ | |
| 18 | + MethodDescriptor.dis\ | |
| 19 | +# for ObjectInputStreamWithLoader.dis\ | |
| 20 | + fOuvWMGaSExrtMuU8Cw+S.dis\ | |
| 21 | + ParameterDescriptor.dis\ | |
| 22 | + PropertyChangeEvent.dis\ | |
| 23 | +# for PropertyChangeListener.dis\ | |
| 24 | + M7phJvk2kRU7An2nlvP+n.dis\ | |
| 25 | + PropertyChangeSupport.dis\ | |
| 26 | + PropertyDescriptor.dis\ | |
| 27 | + PropertyEditor.dis\ | |
| 28 | + PropertyEditorManager.dis\ | |
| 29 | + PropertyEditorSupport.dis\ | |
| 30 | + PropertyVetoException.dis\ | |
| 31 | + SimpleBeanInfo.dis\ | |
| 32 | +# for VetoableChangeListener.dis\ | |
| 33 | + QD20WmJQo8+7yc9BbLrqW.dis\ | |
| 34 | + VetoableChangeSupport.dis\ | |
| 35 | + Visibility.dis\ | |
| 36 | + | |
| 37 | +DISBIN=$ROOT/java/dis/java/java/beans | |
| 38 | + | |
| 39 | +<$ROOT/mkfiles/mkjava | |
| 40 | + | |
| 41 | +BeansAppletContext.dis: Beans.class | |
| 42 | + j2d BeansAppletContext.class | |
| 43 | + | |
| 44 | +BeansAppletStub.dis: Beans.class | |
| 45 | + j2d BeansAppletStub.class | |
| 46 | + | |
| 47 | +fOuvWMGaSExrtMuU8Cw+S.dis: Beans.class | |
| 48 | + j2d ObjectInputStreamWithLoader.class | |
| 49 | + | |
| 50 | +ilsoQHwwPML2uGzS7a9sz.dis: IndexedPropertyDescriptor.class | |
| 51 | + j2d $prereq | |
| 52 | + | |
| 53 | +kKxvl0RXJ9GHO1gHFFNvw.dis: IntrospectionException.class | |
| 54 | + j2d $prereq | |
| 55 | + | |
| 56 | +GenericBeanInfo.dis: Introspector.class | |
| 57 | + j2d GenericBeanInfo.class | |
| 58 | + | |
| 59 | +M7phJvk2kRU7An2nlvP+n.dis: PropertyChangeListener.class | |
| 60 | + j2d $prereq | |
| 61 | + | |
| 62 | +QD20WmJQo8+7yc9BbLrqW.dis: VetoableChangeListener.class | |
| 63 | + j2d $prereq | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,72 @@ | ||
| 1 | +implement FileDescriptor_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + sys : import jni; | |
| 27 | + FALSE : import jni; | |
| 28 | + TRUE : import jni; | |
| 29 | +#<< | |
| 30 | + | |
| 31 | +include "FileDescriptor_L.m"; | |
| 32 | + | |
| 33 | +#>> extra post includes here | |
| 34 | +#<< | |
| 35 | + | |
| 36 | +init( jni_p : JNI ) | |
| 37 | +{ | |
| 38 | + # save java native inteface mod instance | |
| 39 | + jni = jni_p; | |
| 40 | + #>>extra initialization here | |
| 41 | + sys = jni->sys; | |
| 42 | + #<< | |
| 43 | +} | |
| 44 | + | |
| 45 | +valid_Z( this : ref FileDescriptor_obj) : int | |
| 46 | +{#>> | |
| 47 | + if (this.fd != nil) | |
| 48 | + return TRUE; | |
| 49 | + else | |
| 50 | + return FALSE; | |
| 51 | +}#<< | |
| 52 | + | |
| 53 | +sync_V( this : ref FileDescriptor_obj) | |
| 54 | +{#>> | |
| 55 | + # this routine has no meaning in the limbo world because there is | |
| 56 | + # nothing to sync or flush. It may have meaning to each underlying | |
| 57 | + # file system (device driver) but at the present there is no devtab | |
| 58 | + # interface to the device driver for sync. As such, this routine is | |
| 59 | + # a noop. | |
| 60 | + jni->ThrowException("java.io.SyncFailedException", "sync not gauranteed"); | |
| 61 | +}#<< | |
| 62 | + | |
| 63 | +initSystemFD_rFileDescriptor_I_rFileDescriptor( p0 : ref FileDescriptor_obj,p1 : int) : ref FileDescriptor_obj | |
| 64 | +{#>> | |
| 65 | + p0.fd = sys->fildes(p1); | |
| 66 | + return (p0); | |
| 67 | +}#<< | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| @@ -0,0 +1,16 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +FileDescriptor_L : module | |
| 4 | +{ | |
| 5 | + FileDescriptor_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + fd : ref Sys->FD; | |
| 9 | + }; | |
| 10 | + | |
| 11 | + init : fn( jni_p : JNI ); | |
| 12 | + valid_Z : fn( this : ref FileDescriptor_obj) : int; | |
| 13 | + sync_V : fn( this : ref FileDescriptor_obj); | |
| 14 | + initSystemFD_rFileDescriptor_I_rFileDescriptor : fn( p0 : ref FileDescriptor_obj,p1 : int) : ref FileDescriptor_obj; | |
| 15 | + | |
| 16 | +}; | |
Empty file added.
| @@ -0,0 +1,135 @@ | ||
| 1 | +implement FileInputStream_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + sys : import jni; | |
| 27 | + FALSE : import jni; | |
| 28 | + TRUE : import jni; | |
| 29 | +include "FileDescriptor_L.m"; | |
| 30 | + FileDescriptor_obj : import FileDescriptor_L; | |
| 31 | +#<< | |
| 32 | + | |
| 33 | +include "FileInputStream_L.m"; | |
| 34 | + | |
| 35 | +#>> extra post includes here | |
| 36 | +#<< | |
| 37 | + | |
| 38 | +init( jni_p : JNI ) | |
| 39 | +{ | |
| 40 | + # save java native inteface mod instance | |
| 41 | + jni = jni_p; | |
| 42 | + #>>extra initialization here | |
| 43 | + sys = jni->sys; | |
| 44 | + #<< | |
| 45 | +} | |
| 46 | + | |
| 47 | +open_rString_V( this : ref FileInputStream_obj, p0 : JString) | |
| 48 | +{#>> | |
| 49 | + # p0 == file name | |
| 50 | + | |
| 51 | + if ((p0 == nil) || (p0.str == nil)) | |
| 52 | + jni->ThrowException("java.lang.NullPointerException", "str is nil"); | |
| 53 | + | |
| 54 | + this.fd.fd = sys->open(p0.str, sys->OREAD); | |
| 55 | + if(this.fd.fd == nil) | |
| 56 | + jni->ThrowException("java.io.IOException", "open error"); | |
| 57 | +}#<< | |
| 58 | + | |
| 59 | +read_I( this : ref FileInputStream_obj) : int | |
| 60 | +{#>> | |
| 61 | + buf := array[1] of byte; | |
| 62 | + | |
| 63 | + if (this.fd.fd == nil) | |
| 64 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 65 | + readin := sys->read(this.fd.fd, buf, 1); | |
| 66 | + if (readin == 0) # EOF | |
| 67 | + return -1; | |
| 68 | + | |
| 69 | + if (readin < 0) | |
| 70 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 71 | + return (int buf[0]); | |
| 72 | + | |
| 73 | +}#<< | |
| 74 | + | |
| 75 | +readBytes_aB_I_I_I( this : ref FileInputStream_obj, p0 : JArrayB,p1 : int,p2 : int) : int | |
| 76 | +{#>> | |
| 77 | + # p0 == input buffer (array of bytes) | |
| 78 | + # p1 == offset | |
| 79 | + # p2 == length | |
| 80 | + # read p2 bytes from the file and place them at location (p0 + p1) | |
| 81 | + | |
| 82 | + if (this.fd == nil) | |
| 83 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 84 | + if ((p0 == nil) || (p0.ary == nil)) | |
| 85 | + jni->ThrowException("java.lang.NullPointerException", "nil buffer pointer"); | |
| 86 | + if ((p1 < 0) || (p1 > len p0.ary)) | |
| 87 | + jni->ThrowException("java.lang.ArrayIndexOutOfBoundsException", | |
| 88 | + jni->sys->sprint( "offset=%d len buf array=%d", p1, len p0.ary)); | |
| 89 | + | |
| 90 | + if ((p1 + p2) > len p0.ary) | |
| 91 | + p2 = (len p0.ary) - p1; | |
| 92 | + if (p2 <= 0) | |
| 93 | + return 0; | |
| 94 | + | |
| 95 | + n := sys->read(this.fd.fd, p0.ary[p1: len p0.ary], p2); | |
| 96 | + if (n == 0) # EOF | |
| 97 | + return -1; | |
| 98 | + | |
| 99 | + if (n < 0) | |
| 100 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 101 | + return n; | |
| 102 | +}#<< | |
| 103 | + | |
| 104 | +skip_J_J( this : ref FileInputStream_obj, p0 : big) : big | |
| 105 | +{#>> | |
| 106 | + # skip the next p0 bytes from the Input stream. First find out where you are in | |
| 107 | + # the stream. Next skip the bytes then return the "actual" bytes skipped. | |
| 108 | + | |
| 109 | + if (this.fd.fd == nil) | |
| 110 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 111 | + cur := sys->seek(this.fd.fd, 0, sys->SEEKRELA); | |
| 112 | + end := sys->seek(this.fd.fd, (int p0), sys->SEEKRELA); | |
| 113 | + return big (end - cur); | |
| 114 | +}#<< | |
| 115 | + | |
| 116 | +available_I( this : ref FileInputStream_obj) : int | |
| 117 | +{#>> | |
| 118 | + if (this.fd.fd == nil) | |
| 119 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 120 | + cur := sys->seek(this.fd.fd, 0, Sys->SEEKRELA); | |
| 121 | + end := sys->seek(this.fd.fd, 0, Sys->SEEKEND); | |
| 122 | + sys->seek(this.fd.fd, cur, Sys->SEEKSTART); | |
| 123 | + | |
| 124 | + return (end - cur); | |
| 125 | +}#<< | |
| 126 | + | |
| 127 | +close_V( this : ref FileInputStream_obj) | |
| 128 | +{#>> | |
| 129 | + if (this.fd != nil) | |
| 130 | + this.fd.fd = nil; | |
| 131 | +}#<< | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| @@ -0,0 +1,19 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +FileInputStream_L : module | |
| 4 | +{ | |
| 5 | + FileInputStream_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + fd : ref FileDescriptor_obj; | |
| 9 | + }; | |
| 10 | + | |
| 11 | + init : fn( jni_p : JNI ); | |
| 12 | + open_rString_V : fn( this : ref FileInputStream_obj, p0 : JString); | |
| 13 | + read_I : fn( this : ref FileInputStream_obj) : int; | |
| 14 | + readBytes_aB_I_I_I : fn( this : ref FileInputStream_obj, p0 : JArrayB,p1 : int,p2 : int) : int; | |
| 15 | + skip_J_J : fn( this : ref FileInputStream_obj, p0 : big) : big; | |
| 16 | + available_I : fn( this : ref FileInputStream_obj) : int; | |
| 17 | + close_V : fn( this : ref FileInputStream_obj); | |
| 18 | + | |
| 19 | +}; | |
Empty file added.
Empty file added.
| @@ -0,0 +1,116 @@ | ||
| 1 | +implement FileOutputStream_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + sys : import jni; | |
| 27 | + FALSE : import jni; | |
| 28 | + TRUE : import jni; | |
| 29 | +include "FileDescriptor_L.m"; | |
| 30 | + FileDescriptor_obj : import FileDescriptor_L; | |
| 31 | +#<< | |
| 32 | + | |
| 33 | +include "FileOutputStream_L.m"; | |
| 34 | + | |
| 35 | +#>> extra post includes here | |
| 36 | +#<< | |
| 37 | + | |
| 38 | +init( jni_p : JNI ) | |
| 39 | +{ | |
| 40 | + # save java native inteface mod instance | |
| 41 | + jni = jni_p; | |
| 42 | + #>>extra initialization here | |
| 43 | + sys = jni->sys; | |
| 44 | + #<< | |
| 45 | +} | |
| 46 | + | |
| 47 | +open_rString_V( this : ref FileOutputStream_obj, p0 : JString) | |
| 48 | +{#>> | |
| 49 | + # open file pointed to by p0. If it does not exists, create it and | |
| 50 | + # and open it with mode of 644. | |
| 51 | + | |
| 52 | + if ((p0 == nil) || (p0.str == nil)) | |
| 53 | + jni->ThrowException("java.lang.NullPointerException", "null file name"); | |
| 54 | + | |
| 55 | + this.fd.fd = sys->create(p0.str, sys->OWRITE, 8r666); | |
| 56 | + if(this.fd.fd == nil) | |
| 57 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 58 | +}#<< | |
| 59 | + | |
| 60 | +openAppend_rString_V( this : ref FileOutputStream_obj, p0 : JString) | |
| 61 | +{#>> | |
| 62 | + if ((p0 == nil) || (p0.str == nil)) | |
| 63 | + jni->ThrowException("java.lang.NullPointerException", "null filename"); | |
| 64 | + | |
| 65 | + this.fd.fd = sys->open(p0.str, sys->OWRITE); | |
| 66 | + if(this.fd.fd == nil) | |
| 67 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 68 | + sys->seek(this.fd.fd, 0, sys->SEEKEND); | |
| 69 | +}#<< | |
| 70 | + | |
| 71 | +write_I_V( this : ref FileOutputStream_obj, p0 : int) | |
| 72 | +{#>> | |
| 73 | + # p0 == character to write | |
| 74 | + c := array[1] of byte; | |
| 75 | + c[0] = byte p0; | |
| 76 | + | |
| 77 | + if ((this.fd == nil) || (this.fd.fd == nil)) | |
| 78 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 79 | + | |
| 80 | + if (sys->write(this.fd.fd, c, 1) != 1) | |
| 81 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 82 | +}#<< | |
| 83 | + | |
| 84 | +writeBytes_aB_I_I_V( this : ref FileOutputStream_obj, p0 : JArrayB,p1 : int,p2 : int) | |
| 85 | +{#>> | |
| 86 | + # p0 == buffer array to write from | |
| 87 | + # p1 == offset in buffer | |
| 88 | + # p2 == length to write out | |
| 89 | + | |
| 90 | + if ((this.fd == nil) || (this.fd.fd == nil)) | |
| 91 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 92 | + if ((p0 == nil) || (p0.ary == nil)) | |
| 93 | + jni->ThrowException("java.lang.NullPointerException", nil); | |
| 94 | + if ((p1 < 0) || (p2 < 0) || (p1 > (len p0.ary))) | |
| 95 | + jni->ThrowException("java.lang.ArrayIndexOutOfBoundsException", nil); | |
| 96 | + | |
| 97 | + n := 0; | |
| 98 | + while (p2 > 0) { | |
| 99 | + # you can also write the following line as..... | |
| 100 | + # n = sys->write(this.fd.fd, p0.ary[p1:], p2); | |
| 101 | + n = sys->write(this.fd.fd, p0.ary[p1:len p0.ary], p2); | |
| 102 | + if (n == -1) { | |
| 103 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 104 | + break; | |
| 105 | + } | |
| 106 | + p1 += n; | |
| 107 | + p2 -= n; | |
| 108 | + } | |
| 109 | +}#<< | |
| 110 | + | |
| 111 | +close_V( this : ref FileOutputStream_obj) | |
| 112 | +{#>> | |
| 113 | + if (this.fd != nil) | |
| 114 | + this.fd.fd = nil; | |
| 115 | +}#<< | |
| 116 | + | |
| @@ -0,0 +1,18 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +FileOutputStream_L : module | |
| 4 | +{ | |
| 5 | + FileOutputStream_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + fd : ref FileDescriptor_obj; | |
| 9 | + }; | |
| 10 | + | |
| 11 | + init : fn( jni_p : JNI ); | |
| 12 | + open_rString_V : fn( this : ref FileOutputStream_obj, p0 : JString); | |
| 13 | + openAppend_rString_V : fn( this : ref FileOutputStream_obj, p0 : JString); | |
| 14 | + write_I_V : fn( this : ref FileOutputStream_obj, p0 : int); | |
| 15 | + writeBytes_aB_I_I_V : fn( this : ref FileOutputStream_obj, p0 : JArrayB,p1 : int,p2 : int); | |
| 16 | + close_V : fn( this : ref FileOutputStream_obj); | |
| 17 | + | |
| 18 | +}; | |
Empty file added.
Empty file added.
| @@ -0,0 +1,332 @@ | ||
| 1 | +implement File_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + sys : import jni; | |
| 27 | + str : import jni; | |
| 28 | + FALSE : import jni; | |
| 29 | + TRUE : import jni; | |
| 30 | +#<< | |
| 31 | + | |
| 32 | +include "File_L.m"; | |
| 33 | + | |
| 34 | +#>> extra post includes here | |
| 35 | +include "workdir.m"; | |
| 36 | +include "regex.m"; | |
| 37 | +str_mod : String; | |
| 38 | +#<< | |
| 39 | + | |
| 40 | +init( jni_p : JNI ) | |
| 41 | +{ | |
| 42 | + # save java native inteface mod instance | |
| 43 | + jni = jni_p; | |
| 44 | + #>>extra initialization here | |
| 45 | + sys = jni->sys; | |
| 46 | + str_mod = jni->str; | |
| 47 | + #<< | |
| 48 | +} | |
| 49 | + | |
| 50 | +exists0_Z( this : ref File_obj) : int | |
| 51 | +{#>> | |
| 52 | + (ok, nil) := sys->stat(this.path.str); | |
| 53 | + if (ok == -1) | |
| 54 | + return (FALSE); | |
| 55 | + return (TRUE); | |
| 56 | +}#<< | |
| 57 | + | |
| 58 | +canWrite0_Z( this : ref File_obj) : int | |
| 59 | +{#>> | |
| 60 | + # this routine is real cludgy...try to open the file for writing | |
| 61 | + # to see if you have WRITE access rights or not. | |
| 62 | + | |
| 63 | + local_fd := sys->open(this.path.str, sys->OWRITE); | |
| 64 | + if (local_fd == nil) | |
| 65 | + return (FALSE); | |
| 66 | + return (TRUE); | |
| 67 | +}#<< | |
| 68 | + | |
| 69 | +canRead0_Z( this : ref File_obj) : int | |
| 70 | +{#>> | |
| 71 | + # this routine is real cludgy...try to open the file for reading | |
| 72 | + # to see if you have READ access rights or not. | |
| 73 | + | |
| 74 | + local_fd := sys->open(this.path.str, sys->OREAD); | |
| 75 | + if (local_fd == nil) | |
| 76 | + return (FALSE); | |
| 77 | + return (TRUE); | |
| 78 | +}#<< | |
| 79 | + | |
| 80 | +isFile0_Z( this : ref File_obj) : int | |
| 81 | +{#>> | |
| 82 | + (ok, dir) := sys->stat(this.path.str); | |
| 83 | + if(ok >= 0 && !(dir.mode & Sys->CHDIR)) | |
| 84 | + return (TRUE); | |
| 85 | + return (FALSE); | |
| 86 | +}#<< | |
| 87 | + | |
| 88 | +isDirectory0_Z( this : ref File_obj) : int | |
| 89 | +{#>> | |
| 90 | + (ok, dir) := sys->stat(this.path.str); | |
| 91 | + if(ok >= 0 && (dir.mode & Sys->CHDIR)) | |
| 92 | + return (TRUE); | |
| 93 | + return (FALSE); | |
| 94 | +}#<< | |
| 95 | + | |
| 96 | +lastModified0_J( this : ref File_obj) : big | |
| 97 | +{#>> | |
| 98 | + (ok, dir) := sys->stat(this.path.str); | |
| 99 | + if(ok >= 0) | |
| 100 | + return (big dir.mtime); | |
| 101 | + return (big 0); | |
| 102 | +}#<< | |
| 103 | + | |
| 104 | +length0_J( this : ref File_obj) : big | |
| 105 | +{#>> | |
| 106 | + (ok, dir) := sys->stat(this.path.str); | |
| 107 | + if(ok >= 0) | |
| 108 | + return (big dir.length); | |
| 109 | + return (big 0); | |
| 110 | +}#<< | |
| 111 | + | |
| 112 | +mkdir0_Z( this : ref File_obj) : int | |
| 113 | +{#>> | |
| 114 | + (ok, nil) := sys->stat(this.path.str); | |
| 115 | + if(ok >= 0) | |
| 116 | + return (FALSE); | |
| 117 | + fd := sys->create(this.path.str, sys->OREAD, sys->CHDIR + 8r777); | |
| 118 | + if(fd == nil) | |
| 119 | + return (FALSE); | |
| 120 | + fd = nil; | |
| 121 | + return (TRUE); | |
| 122 | +}#<< | |
| 123 | + | |
| 124 | +renameTo0_rFile_Z( this : ref File_obj, p0 : ref File_obj) : int | |
| 125 | +{#>> | |
| 126 | + # this routine is based on the appl/cmd/mv command in inferno.... | |
| 127 | + | |
| 128 | + #put from and to file names into complete path names | |
| 129 | + frompath := pathname(this.path.str); | |
| 130 | + topath := pathname(p0.path.str); | |
| 131 | + | |
| 132 | + #seperate the name of the file from the directory the files reside in | |
| 133 | + (fromdir, fromname) := split(frompath); | |
| 134 | + (todir, toname) := split(topath); | |
| 135 | + | |
| 136 | + (i, dirf) := sys->stat(this.path.str); | |
| 137 | + if ( i == -1 ) | |
| 138 | + return FALSE; | |
| 139 | + | |
| 140 | + # are the files in the same directory???? | |
| 141 | + if ( samefile(fromdir, todir) ) { | |
| 142 | + if ( toname == fromname ) | |
| 143 | + return TRUE; | |
| 144 | + (j, dirt) := sys->stat(p0.path.str); | |
| 145 | + if ( j == 0 ) { | |
| 146 | + if ( (dirf.mode | dirt.mode) & Sys->CHDIR ) | |
| 147 | + return FALSE; | |
| 148 | + hardremove(topath); | |
| 149 | + } | |
| 150 | + dirf.name = toname; | |
| 151 | + if ( sys->wstat(this.path.str, dirf) >= 0 ) | |
| 152 | + return TRUE; | |
| 153 | + } | |
| 154 | + #open the from file.... | |
| 155 | + if ( (fdf := sys->open(this.path.str, Sys->OREAD)) == nil ) | |
| 156 | + return FALSE; | |
| 157 | + | |
| 158 | + #open the to file.... | |
| 159 | + if ( (fdt := sys->create(p0.path.str, Sys->OWRITE, dirf.mode)) == nil ) | |
| 160 | + return FALSE;; | |
| 161 | + | |
| 162 | + #copy data from from file to to file.... | |
| 163 | + if ( (stat := copy1(fdf, fdt)) == TRUE ) { | |
| 164 | + fdf = nil; | |
| 165 | + if ( sys->remove(this.path.str) < 0 ) | |
| 166 | + return FALSE; | |
| 167 | + } | |
| 168 | + else { | |
| 169 | + fdt = nil; | |
| 170 | + sys->remove(p0.path.str); | |
| 171 | + } | |
| 172 | + return stat; | |
| 173 | +}#<< | |
| 174 | + | |
| 175 | +delete0_Z( this : ref File_obj) : int | |
| 176 | +{#>> | |
| 177 | + if (isFile0_Z(this) == TRUE) | |
| 178 | + return (remove0_b(this)); | |
| 179 | + return (FALSE); | |
| 180 | +}#<< | |
| 181 | + | |
| 182 | +rmdir0_Z( this : ref File_obj) : int | |
| 183 | +{#>> | |
| 184 | + if (isDirectory0_Z(this) == TRUE) | |
| 185 | + return (remove0_b(this)); | |
| 186 | + return (FALSE); | |
| 187 | +}#<< | |
| 188 | + | |
| 189 | +list0_aString( this : ref File_obj) : JArrayJString | |
| 190 | +{#>> | |
| 191 | + fd := sys->open(this.path.str, sys->OREAD); | |
| 192 | + if(fd == nil) { | |
| 193 | + return nil; | |
| 194 | + } | |
| 195 | + | |
| 196 | + dir_array := array[200] of Sys->Dir; | |
| 197 | + n := 0; | |
| 198 | + for(;;){ | |
| 199 | + if(len dir_array - n == 0){ | |
| 200 | + # expand dir_array | |
| 201 | + nd := array[2 * len dir_array] of Sys->Dir; | |
| 202 | + nd[0:] = dir_array; | |
| 203 | + dir_array = nd; | |
| 204 | + } | |
| 205 | + nr := sys->dirread(fd, dir_array[n:]); | |
| 206 | + if(nr < 0) | |
| 207 | + return nil; | |
| 208 | + if(nr == 0) | |
| 209 | + break; | |
| 210 | + n += nr; | |
| 211 | + } | |
| 212 | + file_name := array[n] of string; | |
| 213 | + | |
| 214 | + for(i := 0; i < n; i++) | |
| 215 | + file_name[i] = dir_array[i].name; | |
| 216 | + | |
| 217 | + return (jni->MkAString(file_name)); | |
| 218 | +}#<< | |
| 219 | + | |
| 220 | +canonPath_rString_rString( this : ref File_obj, p0 : JString) : JString | |
| 221 | +{#>> | |
| 222 | + TRACE_1 := this; # to remove warning msg at compile time; | |
| 223 | + | |
| 224 | + path := pathname(p0.str) + "/"; | |
| 225 | + | |
| 226 | + regex := load Regex Regex->PATH; | |
| 227 | + if ( regex == nil ) | |
| 228 | + jni->InitError( sys->sprint( "java.io.File: could not load %s: %r", Regex->PATH ) ); | |
| 229 | + | |
| 230 | + path = squeeze_out(regex, regex->compile("//", 0), "/", path); | |
| 231 | + path = squeeze_out(regex, regex->compile("/\\./", 0), "/", path); | |
| 232 | + path = squeeze_out(regex, regex->compile("/[^/]+/\\.\\./", 0), "/", path); | |
| 233 | + | |
| 234 | + if ( len path > 1 && path[len path - 1] == '/' ) | |
| 235 | + path = path[0:len path - 1]; | |
| 236 | + | |
| 237 | + return (jni->NewString( path)); | |
| 238 | +}#<< | |
| 239 | + | |
| 240 | +isAbsolute_Z( this : ref File_obj) : int | |
| 241 | +{#>> | |
| 242 | + if (str_mod->prefix("/", this.path.str)) | |
| 243 | + return (TRUE); | |
| 244 | + return (FALSE); | |
| 245 | +}#<< | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | +remove0_b( this : ref File_obj) : int | |
| 252 | +{ | |
| 253 | + if (sys->remove(this.path.str) < 0) | |
| 254 | + return (FALSE); | |
| 255 | + return (TRUE); | |
| 256 | +} | |
| 257 | + | |
| 258 | +copy1(fdf, fdt : ref Sys->FD): int | |
| 259 | +{ | |
| 260 | + n : int; | |
| 261 | + buf := array[8192] of byte; | |
| 262 | + | |
| 263 | + for ( ; ; ) { | |
| 264 | + n = sys->read(fdf, buf, len buf); | |
| 265 | + if (n<=0) | |
| 266 | + break; | |
| 267 | + n1 := sys->write(fdt, buf, n); | |
| 268 | + if ( n1 != n ) | |
| 269 | + return FALSE; | |
| 270 | + } | |
| 271 | + if ( n < 0 ) | |
| 272 | + return FALSE; | |
| 273 | + return TRUE; | |
| 274 | +} | |
| 275 | + | |
| 276 | +#convert a file name into complete path name | |
| 277 | +pathname(p : string) : string | |
| 278 | +{ | |
| 279 | + if ( p == nil || p[0] == '/' ) | |
| 280 | + return p; | |
| 281 | + gwd := load Workdir Workdir->PATH; | |
| 282 | + if ( gwd == nil ) | |
| 283 | + jni->InitError( sys->sprint( "java.io.File: could not load %s: %r", Workdir->PATH ) ); | |
| 284 | + | |
| 285 | + wd := gwd->init(); | |
| 286 | + if ( len wd == 0 ) | |
| 287 | + return p; | |
| 288 | + return wd + "/" + p; | |
| 289 | +} | |
| 290 | + | |
| 291 | +#pull out the name of the file only | |
| 292 | +split(name : string): (string,string) | |
| 293 | +{ | |
| 294 | + (d,t) := str_mod->splitr(name, "/"); | |
| 295 | + if ( d != nil ) | |
| 296 | + return(d,t); | |
| 297 | + else if ( name == ".." ) | |
| 298 | + return("../","."); | |
| 299 | + else | |
| 300 | + return("./",name); | |
| 301 | +} | |
| 302 | + | |
| 303 | +# return TRUE if file a is same as file b | |
| 304 | +samefile(a,b : string): int | |
| 305 | +{ | |
| 306 | + if ( a == b ) | |
| 307 | + return 1; | |
| 308 | + (i, file_a) := sys->stat(a); | |
| 309 | + (j, file_b) := sys->stat(b); | |
| 310 | + if ( i < 0 || j < 0 ) | |
| 311 | + return 0; | |
| 312 | + i = ((file_a.qid.path == file_b.qid.path) && (file_a.qid.vers == file_b.qid.vers) && | |
| 313 | + (file_a.dev == file_b.dev) && (file_a.dtype == file_b.dtype)); | |
| 314 | + return i; | |
| 315 | +} | |
| 316 | + | |
| 317 | +hardremove(a: string) | |
| 318 | +{ | |
| 319 | + do; while ( sys->remove(a) != -1 ); | |
| 320 | +} | |
| 321 | + | |
| 322 | +squeeze_out(r : Regex, pat : Regex->Re, repl, str :string) : string | |
| 323 | +{ | |
| 324 | + while ( str_mod->prefix("/../", str) ) | |
| 325 | + str = str[3:]; | |
| 326 | + a := r->execute(pat, str); | |
| 327 | + if (a == nil) | |
| 328 | + return str; | |
| 329 | + (beg, end) := a[0]; | |
| 330 | + str = str[0:beg] + repl + str[end:]; | |
| 331 | + return squeeze_out(r, pat, repl, str); | |
| 332 | +} | |
| @@ -0,0 +1,27 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +File_L : module | |
| 4 | +{ | |
| 5 | + File_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + path : JString; | |
| 9 | + }; | |
| 10 | + | |
| 11 | + init : fn( jni_p : JNI ); | |
| 12 | + exists0_Z : fn( this : ref File_obj) : int; | |
| 13 | + canWrite0_Z : fn( this : ref File_obj) : int; | |
| 14 | + canRead0_Z : fn( this : ref File_obj) : int; | |
| 15 | + isFile0_Z : fn( this : ref File_obj) : int; | |
| 16 | + isDirectory0_Z : fn( this : ref File_obj) : int; | |
| 17 | + lastModified0_J : fn( this : ref File_obj) : big; | |
| 18 | + length0_J : fn( this : ref File_obj) : big; | |
| 19 | + mkdir0_Z : fn( this : ref File_obj) : int; | |
| 20 | + renameTo0_rFile_Z : fn( this : ref File_obj, p0 : ref File_obj) : int; | |
| 21 | + delete0_Z : fn( this : ref File_obj) : int; | |
| 22 | + rmdir0_Z : fn( this : ref File_obj) : int; | |
| 23 | + list0_aString : fn( this : ref File_obj) : JArrayJString; | |
| 24 | + canonPath_rString_rString : fn( this : ref File_obj, p0 : JString) : JString; | |
| 25 | + isAbsolute_Z : fn( this : ref File_obj) : int; | |
| 26 | + | |
| 27 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,397 @@ | ||
| 1 | +implement ObjectInputStream_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + sys : import jni; | |
| 27 | + str : import jni; | |
| 28 | + FALSE : import jni; | |
| 29 | + TRUE : import jni; | |
| 30 | +#<< | |
| 31 | + | |
| 32 | +include "ObjectInputStream_L.m"; | |
| 33 | + | |
| 34 | +#>> extra post includes here | |
| 35 | +include "workdir.m"; | |
| 36 | +include "regex.m"; | |
| 37 | +str_mod : String; | |
| 38 | +ClassData, Value : import jni; | |
| 39 | +cast : Cast; | |
| 40 | +low : Low; | |
| 41 | +#<< | |
| 42 | + | |
| 43 | +init( jni_p : JNI ) | |
| 44 | +{ | |
| 45 | + # save java native inteface mod instance | |
| 46 | + jni = jni_p; | |
| 47 | + #>>extra initialization here | |
| 48 | + sys = jni->sys; | |
| 49 | + str_mod = jni->str; | |
| 50 | + cast = jni->CastMod(); | |
| 51 | + low = jni->LowMod(); | |
| 52 | + #<< | |
| 53 | +} | |
| 54 | + | |
| 55 | +loadClass0_rClass_rString_rClass( this : ref ObjectInputStream_obj, p0 : JClass,p1 : JString) : JClass | |
| 56 | +{#>> | |
| 57 | + TRACE_1 := (this, p0); | |
| 58 | + if(p1.str[0] == '[') | |
| 59 | + return jni->LookupArrayClass(p1.str); | |
| 60 | + else | |
| 61 | + return jni->GetClassObject( jni->FindClass(p1.str) ); | |
| 62 | +}#<< | |
| 63 | + | |
| 64 | +inputClassFields_rObject_rClass_aI_V( this : JObject, p0 : JObject,p1 : JClass,p2 : JArrayI) | |
| 65 | +{#>> | |
| 66 | + #p0 the object being inputted | |
| 67 | + #p1 class being referred to | |
| 68 | + #p2 fieldSequence array | |
| 69 | + | |
| 70 | + ok : int; | |
| 71 | + val : ref Value; | |
| 72 | + # | |
| 73 | + # get all fields except the transient and static | |
| 74 | + # | |
| 75 | + fields_n_sigs := jni->GetFieldSignatures(p1, (JNI->ACC_STATIC|JNI->ACC_TRANSIENT)); | |
| 76 | + # | |
| 77 | + # for each field, parse out the field name and signature. Then based on the | |
| 78 | + # signature, call the appropriate read routine. | |
| 79 | + # | |
| 80 | + for (i:=0; i < len p2.ary; i += 2) { | |
| 81 | + fldindex := p2.ary[i+1]; | |
| 82 | + | |
| 83 | + (str_part, tmp_str) := str_mod->splitl((fields_n_sigs.ary[fldindex]).str, " "); | |
| 84 | + sig_part := tmp_str[1]; | |
| 85 | + # | |
| 86 | + # call the appropriate read routine to get the value of this field | |
| 87 | + # | |
| 88 | + case sig_part { | |
| 89 | + # SIGNATURE_BYTE | |
| 90 | + 'B' => | |
| 91 | + (val, ok) = jni->CallMethod(this, "readByte", "()B", nil); | |
| 92 | + # SIGNATURE_CHAR | |
| 93 | + 'C' => | |
| 94 | + (val, ok) = jni->CallMethod(this, "readChar", "()C", nil); | |
| 95 | + # SIGNATURE_FLOAT | |
| 96 | + 'F' => | |
| 97 | + (val, ok) = jni->CallMethod(this, "readFloat", "()F", nil); | |
| 98 | + # SIGNATURE_DOUBLE | |
| 99 | + 'D' => | |
| 100 | + (val, ok) = jni->CallMethod(this, "readDouble", "()D", nil); | |
| 101 | + # SIGNATURE_INT | |
| 102 | + 'I' => | |
| 103 | + (val, ok) = jni->CallMethod(this, "readInt", "()I", nil); | |
| 104 | + # SIGNATURE_LONG | |
| 105 | + 'J' => | |
| 106 | + (val, ok) = jni->CallMethod(this, "readLong", "()J", nil); | |
| 107 | + # SIGNATURE_SHORT | |
| 108 | + 'S' => | |
| 109 | + (val, ok) = jni->CallMethod(this, "readShort", "()S", nil); | |
| 110 | + # SIGNATURE_BOOLEAN | |
| 111 | + 'Z' => | |
| 112 | + (val, ok) = jni->CallMethod(this, "readBoolean", "()Z", nil); | |
| 113 | + # SIGNATURE_ARRAY | |
| 114 | + '[' => | |
| 115 | + (val, ok) = jni->CallMethod(this, "readObject", "()Ljava/lang/Object;", nil); | |
| 116 | + # SIGNATURE_CLASS | |
| 117 | + 'L' => | |
| 118 | + (val, ok) = jni->CallMethod(this, "readObject", "()Ljava/lang/Object;", nil); | |
| 119 | + } | |
| 120 | + # | |
| 121 | + # now take that just readin value and store into the object. | |
| 122 | + # | |
| 123 | + if (ok == JNI->OK) | |
| 124 | + jni->SetObjField(p0, str_part, val); | |
| 125 | + } | |
| 126 | +}#<< | |
| 127 | + | |
| 128 | +inputArrayValues_rObject_rClass_V( this : JObject, p0 : JObject,p1 : JClass) | |
| 129 | +{#>> | |
| 130 | + # p0 is an array of Objects. We have to look at the signature | |
| 131 | + # of the array to find what the Objects really are. | |
| 132 | + # | |
| 133 | + # p1 the class name of the elements of the array (this is also | |
| 134 | + # the arrays signature) | |
| 135 | + # | |
| 136 | + # make sure this is an array we have. If so, get its length. | |
| 137 | + # | |
| 138 | + if ( jni->IsArray(p0) == JNI->FALSE) { | |
| 139 | + jni->ThrowException("java.io.InvalidClassException", "Not an array"); | |
| 140 | + } | |
| 141 | + length := jni->GetArrayLength(cast->ToJArray(p0)); | |
| 142 | + ok : int; | |
| 143 | + val : ref Value; | |
| 144 | + | |
| 145 | + # | |
| 146 | + # dispatch on the signature of the array and read in each element. | |
| 147 | + # | |
| 148 | + i : int; | |
| 149 | + case p1.aryname[1] { | |
| 150 | + # SIGNATURE_BYTE | |
| 151 | + 'B' => | |
| 152 | + { | |
| 153 | + mul_args := array[3] of ref Value; | |
| 154 | + mul_args[0] = ref Value.TObject(p0); | |
| 155 | + mul_args[1] = ref Value.TInt(0); | |
| 156 | + mul_args[2] = ref Value.TInt(length); | |
| 157 | + (val, ok) = jni->CallMethod(this, "readFully", "([BII)V", mul_args); | |
| 158 | + } | |
| 159 | + # SIGNATURE_CHAR | |
| 160 | + 'C' => | |
| 161 | + { | |
| 162 | + JAChar := cast->ToJArrayI(p0); | |
| 163 | + for (i = 0; i < length; i++) { | |
| 164 | + (val, ok) = jni->CallMethod(this, "readChar", "()C", nil); | |
| 165 | + JAChar.ary[i] = val.Char(); | |
| 166 | + } | |
| 167 | + } | |
| 168 | + # SIGNATURE_FLOAT | |
| 169 | + 'F' => | |
| 170 | + { | |
| 171 | + JAFloat := cast->ToJArrayF(p0); | |
| 172 | + for (i = 0; i < length; i++) { | |
| 173 | + (val, ok) = jni->CallMethod(this, "readFloat", "()F", nil); | |
| 174 | + JAFloat.ary[i] = val.Float(); | |
| 175 | + } | |
| 176 | + } | |
| 177 | + # SIGNATURE_DOUBLE | |
| 178 | + 'D' => | |
| 179 | + { | |
| 180 | + JADouble := cast->ToJArrayD(p0); | |
| 181 | + for (i = 0; i < length; i++) { | |
| 182 | + (val, ok) = jni->CallMethod(this, "readDouble", "()D", nil); | |
| 183 | + JADouble.ary[i] = val.Double(); | |
| 184 | + } | |
| 185 | + } | |
| 186 | + # SIGNATURE_INT | |
| 187 | + 'I' => | |
| 188 | + { | |
| 189 | + JAInt := cast->ToJArrayI(p0); | |
| 190 | + for (i = 0; i < length; i++) { | |
| 191 | + (val, ok) = jni->CallMethod(this, "readInt", "()I", nil); | |
| 192 | + JAInt.ary[i] = val.Int(); | |
| 193 | + } | |
| 194 | + } | |
| 195 | + # SIGNATURE_LONG | |
| 196 | + 'J' => | |
| 197 | + { | |
| 198 | + JALong := cast->ToJArrayJ(p0); | |
| 199 | + for (i = 0; i < length; i++) { | |
| 200 | + (val, ok) = jni->CallMethod(this, "readLong", "()J", nil); | |
| 201 | + JALong.ary[i] = val.Long(); | |
| 202 | + } | |
| 203 | + } | |
| 204 | + # SIGNATURE_SHORT | |
| 205 | + 'S' => | |
| 206 | + { | |
| 207 | + JAShort := cast->ToJArrayI(p0); | |
| 208 | + for (i = 0; i < length; i++) { | |
| 209 | + (val, ok) = jni->CallMethod(this, "readShort", "()S", nil); | |
| 210 | + JAShort.ary[i] = val.Short(); | |
| 211 | + } | |
| 212 | + } | |
| 213 | + # SIGNATURE_BOOLEAN | |
| 214 | + 'Z' => | |
| 215 | + { | |
| 216 | + JABool := cast->ToJArrayZ(p0); | |
| 217 | + for (i = 0; i < length; i++) { | |
| 218 | + (val, ok) = jni->CallMethod(this, "readBoolean", "()Z", nil); | |
| 219 | + JABool.ary[i] = byte val.Boolean(); | |
| 220 | + } | |
| 221 | + } | |
| 222 | + # SIGNATURE_ARRAY | |
| 223 | + '[' => | |
| 224 | + { | |
| 225 | + JAObj := cast->ToJArrayJObject(p0); | |
| 226 | + for (i = 0; i < length; i++) { | |
| 227 | + (val, ok) = jni->CallMethod(this, "readObject", "()Ljava/lang/Object;", nil); | |
| 228 | + JAObj.ary[i] = val.Object(); | |
| 229 | + } | |
| 230 | + } | |
| 231 | + # SIGNATURE_CLASS | |
| 232 | + 'L' => | |
| 233 | + { | |
| 234 | + JAObj := cast->ToJArrayJObject(p0); | |
| 235 | + for (i = 0; i < length; i++) { | |
| 236 | + (val, ok) = jni->CallMethod(this, "readObject", "()Ljava/lang/Object;", nil); | |
| 237 | + JAObj.ary[i] = val.Object(); | |
| 238 | + } | |
| 239 | + } | |
| 240 | + } | |
| 241 | +}#<< | |
| 242 | + | |
| 243 | +# | |
| 244 | +# Does class c directly implement interface iface? | |
| 245 | +# | |
| 246 | +directImp(c: ClassData, iface: string): int | |
| 247 | +{ | |
| 248 | + l := c.interdirect; | |
| 249 | + while(l != nil) { | |
| 250 | + i := hd l; | |
| 251 | + if(i.name == iface) | |
| 252 | + return 1; | |
| 253 | + l = tl l; | |
| 254 | + } | |
| 255 | + return 0; | |
| 256 | +} | |
| 257 | + | |
| 258 | +# | |
| 259 | +# If c directly implements Externalizable, then call its default | |
| 260 | +# constructor (if there is one). | |
| 261 | +# Otherwise, c must directly implement Serializable. In this case, | |
| 262 | +# find the nearest super that doesn't implement Serializable and call | |
| 263 | +# its default constructor (if there is one). | |
| 264 | +# In either case, if there is a constructor to call, then it must be public. | |
| 265 | +# If not, an IllegalAccessException is thrown. | |
| 266 | +# | |
| 267 | + | |
| 268 | +callCtor(c: ClassData, o: JObject) | |
| 269 | +{ | |
| 270 | + if(directImp(c, "java/io/Externalizable") == 0) { | |
| 271 | + if(directImp(c, "java/io/Serializable") == 0) | |
| 272 | + return; | |
| 273 | + c = c.super; | |
| 274 | + while(c != nil) { | |
| 275 | + if(directImp(c, "java/io/Serializable") == 0) | |
| 276 | + break; | |
| 277 | + c = c.super; | |
| 278 | + } | |
| 279 | + } | |
| 280 | + if(c == nil) | |
| 281 | + return; | |
| 282 | + (mod, ix) := jni->FindMethod(c, "<init>", "()V", JNI->METH_INIT); | |
| 283 | + if(mod == nil) | |
| 284 | + return; | |
| 285 | + flags := jni->GetMethodFlags(c.this, "<init> ()V"); | |
| 286 | + if((flags & JNI->ACC_PUBLIC) == 0) | |
| 287 | + jni->ThrowException("java.lang.IllegalAccessException", ""); | |
| 288 | + low->CallMethod(mod, ix, o, array[0] of ref Value, nil); | |
| 289 | +} | |
| 290 | + | |
| 291 | +# | |
| 292 | +# Allocate a new object of class p0. | |
| 293 | +# | |
| 294 | +allocateNewObject_rClass_rClass_rObject(p0 : JClass, p1 : JClass) : JObject | |
| 295 | +{#>> | |
| 296 | + TRACE_1 := p1; | |
| 297 | + o := jni->AllocObject(p0.class); | |
| 298 | + callCtor(p0.class, o); | |
| 299 | + return o; | |
| 300 | +}#<< | |
| 301 | + | |
| 302 | +allocateNewArray_rClass_I_rObject( p0 : JClass,p1 : int) : JObject | |
| 303 | +{#>> | |
| 304 | + # | |
| 305 | + # p0 is the class of the array elements | |
| 306 | + # p1 is number of elelments. | |
| 307 | + # | |
| 308 | + # | |
| 309 | + # example transformation..... | |
| 310 | + # jni->MkALong(array[p1] of big) ==> JArrayJ | |
| 311 | + # cast->BigToJArray(JArrayJ (aka BigArray)) ==> JArray | |
| 312 | + # cast->FromJArray(JArray) ==> JObject | |
| 313 | + # | |
| 314 | + case p0.aryname[1] { | |
| 315 | + # SIGNATURE_BYTE | |
| 316 | + 'B' => | |
| 317 | + { | |
| 318 | + # limbo array ==>JArrayB ==>JArray ==>JObject | |
| 319 | + return (cast->FromJArray(cast->ByteToJArray(jni->MkAByte(array[p1] of byte)))); | |
| 320 | + } | |
| 321 | + # SIGNATURE_CHAR | |
| 322 | + 'C' => | |
| 323 | + { | |
| 324 | + # limbo array ==>JArrayC ==>JArray ==>JObject | |
| 325 | + return (cast->FromJArray(cast->IntToJArray(jni->MkAChar(array[p1] of int)))); | |
| 326 | + } | |
| 327 | + # SIGNATURE_FLOAT | |
| 328 | + 'F' => | |
| 329 | + { | |
| 330 | + # limbo array ==>JArrayF ==>JArray ==>JObject | |
| 331 | + return (cast->FromJArray(cast->RealToJArray(jni->MkAFloat(array[p1] of real)))); | |
| 332 | + } | |
| 333 | + # SIGNATURE_DOUBLE | |
| 334 | + 'D' => | |
| 335 | + { | |
| 336 | + # limbo array ==>JArrayD ==>JArray ==>JObject | |
| 337 | + return (cast->FromJArray(cast->RealToJArray(jni->MkADouble(array[p1] of real)))); | |
| 338 | + } | |
| 339 | + # SIGNATURE_INT | |
| 340 | + 'I' => | |
| 341 | + { | |
| 342 | + # limbo array ==>JArrayI ==>JArray ==>JObject | |
| 343 | + return (cast->FromJArray(cast->IntToJArray(jni->MkAInt(array[p1] of int)))); | |
| 344 | + } | |
| 345 | + # SIGNATURE_LONG | |
| 346 | + 'J' => | |
| 347 | + { | |
| 348 | + # limbo array ==>JArrayJ ==>JArray ==>JObject | |
| 349 | + return (cast->FromJArray(cast->BigToJArray(jni->MkALong(array[p1] of big)))); | |
| 350 | + } | |
| 351 | + # SIGNATURE_SHORT | |
| 352 | + 'S' => | |
| 353 | + { | |
| 354 | + # limbo array ==>JArrayS ==>JArray ==>JObject | |
| 355 | + return (cast->FromJArray(cast->IntToJArray(jni->MkAShort(array[p1] of int)))); | |
| 356 | + } | |
| 357 | + # SIGNATURE_BOOLEAN | |
| 358 | + 'Z' => | |
| 359 | + { | |
| 360 | + # limbo array ==>JArrayZ ==>JArray ==>JObject | |
| 361 | + return (cast->FromJArray(cast->ByteToJArray(jni->MkABoolean(array[p1] of byte)))); | |
| 362 | + } | |
| 363 | + # SIGNATURE_ARRAY | |
| 364 | + '[' => | |
| 365 | + { | |
| 366 | + objarray := cast->ObjectToJArray(jni->MkAObject(array[p1] of JObject)); | |
| 367 | + desc := jni->JSigToDescriptor(p0.aryname); | |
| 368 | + objarray.dims = desc.dims; | |
| 369 | + objarray.class = desc.class; | |
| 370 | + objarray.primitive = desc.prim; | |
| 371 | + return (cast->FromJArray(objarray)); | |
| 372 | + } | |
| 373 | + # SIGNATURE_CLASS | |
| 374 | + 'L' => | |
| 375 | + { | |
| 376 | + objarray := cast->ObjectToJArray(jni->MkAObject(array[p1] of JObject)); | |
| 377 | + objarray.class = jni->FindClass(p0.aryname[2:len p0.aryname-1]); | |
| 378 | + return (cast->FromJArray(objarray)); | |
| 379 | + } | |
| 380 | + } | |
| 381 | + jni->ThrowException("java.io.InvalidClassException", "Unknown signature"); | |
| 382 | + return nil; | |
| 383 | +}#<< | |
| 384 | + | |
| 385 | +invokeObjectReader_rObject_rClass_Z( this : JObject, p0 : JObject,p1 : JClass) : int | |
| 386 | +{#>> | |
| 387 | + junk := p1; | |
| 388 | + # | |
| 389 | + # call readObject() on object "p0" with an argument of "this" | |
| 390 | + # | |
| 391 | + MyValueArray := array[] of { | |
| 392 | + ref Value.TObject(this) | |
| 393 | + }; | |
| 394 | + (a, b) := jni->CallMethod(p0, "readObject", "(Ljava/io/ObjectInputStream;)V", MyValueArray); | |
| 395 | + | |
| 396 | + return b == JNI->OK; | |
| 397 | +}#<< | |
| @@ -0,0 +1,36 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +ObjectInputStream_L : module | |
| 4 | +{ | |
| 5 | + ObjectInputStream_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + in : JObject; | |
| 9 | + count : int; | |
| 10 | + blockDataMode : byte; | |
| 11 | + dis : JObject; | |
| 12 | + abortIOException : JObject; | |
| 13 | + abortClassNotFoundException : JObject; | |
| 14 | + currentObject : JObject; | |
| 15 | + currentClassDesc : JObject; | |
| 16 | + currentClass : JClass; | |
| 17 | + classdesc : JArrayJObject; | |
| 18 | +# classes : JArrayJClass; | |
| 19 | + spClass : int; | |
| 20 | + wireHandle2Object : JObject; | |
| 21 | + nextWireOffset : int; | |
| 22 | + callbacks : JObject; | |
| 23 | + recursionDepth : int; | |
| 24 | + currCode : byte; | |
| 25 | + enableResolve : byte; | |
| 26 | + }; | |
| 27 | + | |
| 28 | + init : fn( jni_p : JNI ); | |
| 29 | + loadClass0_rClass_rString_rClass : fn( this : ref ObjectInputStream_obj, p0 : JClass,p1 : JString) : JClass; | |
| 30 | + inputClassFields_rObject_rClass_aI_V : fn( this : JObject, p0 : JObject,p1 : JClass,p2 : JArrayI); | |
| 31 | + inputArrayValues_rObject_rClass_V : fn( this : JObject, p0 : JObject,p1 : JClass); | |
| 32 | + allocateNewObject_rClass_rClass_rObject : fn( p0 : JClass,p1 : JClass) : JObject; | |
| 33 | + allocateNewArray_rClass_I_rObject : fn( p0 : JClass,p1 : int) : JObject; | |
| 34 | + invokeObjectReader_rObject_rClass_Z : fn( this : JObject, p0 : JObject,p1 : JClass) : int; | |
| 35 | + | |
| 36 | +}; | |
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,257 @@ | ||
| 1 | +implement ObjectOutputStream_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + sys : import jni; | |
| 27 | + str : import jni; | |
| 28 | + FALSE : import jni; | |
| 29 | + TRUE : import jni; | |
| 30 | +#<< | |
| 31 | + | |
| 32 | +include "ObjectOutputStream_L.m"; | |
| 33 | + | |
| 34 | +#>> extra post includes here | |
| 35 | +include "workdir.m"; | |
| 36 | +include "regex.m"; | |
| 37 | +str_mod : String; | |
| 38 | +Value : import jni; | |
| 39 | +cast : Cast; | |
| 40 | +#<< | |
| 41 | + | |
| 42 | +init( jni_p : JNI ) | |
| 43 | +{ | |
| 44 | + # save java native inteface mod instance | |
| 45 | + jni = jni_p; | |
| 46 | + #>>extra initialization here | |
| 47 | + sys = jni->sys; | |
| 48 | + str_mod = jni->str; | |
| 49 | + cast = jni->CastMod(); | |
| 50 | + #<< | |
| 51 | +} | |
| 52 | + | |
| 53 | +outputClassFields_rObject_rClass_aI_V( this : JObject, p0 : JObject,p1 : JClass,p2 : JArrayI) | |
| 54 | +{#>> | |
| 55 | + | |
| 56 | + class := jni->GetObjectClass(p0); | |
| 57 | + #p0 the object being outputted | |
| 58 | + #p1 class being referred to | |
| 59 | + #p2 fieldSequence array | |
| 60 | + | |
| 61 | + a : ref Value; | |
| 62 | + b : int; | |
| 63 | + # | |
| 64 | + # get all fields except the transient and static | |
| 65 | + # | |
| 66 | + fields_n_sigs := jni->GetFieldSignatures(p1, (JNI->ACC_STATIC|JNI->ACC_TRANSIENT)); | |
| 67 | + # | |
| 68 | + # for each field, parse out the field name and signature. Then based on the | |
| 69 | + # signature, call the appropriate write routine. | |
| 70 | + # | |
| 71 | + for (i:=0; i < len p2.ary; i += 2) { | |
| 72 | + fldindex := p2.ary[i+1]; | |
| 73 | + | |
| 74 | + (str_part, tmp_str) := str_mod->splitl((fields_n_sigs.ary[fldindex]).str, " "); | |
| 75 | + sig_part := tmp_str[1]; | |
| 76 | + # | |
| 77 | + # get the value of this field and call the write routine | |
| 78 | + # | |
| 79 | + argv := array[] of { | |
| 80 | + jni->GetObjField(p0, str_part, tmp_str[1:]) | |
| 81 | + }; | |
| 82 | + pick v := argv[0] { | |
| 83 | + TByte => | |
| 84 | + argv[0] = ref Value.TInt(v.jbyte); | |
| 85 | + TChar => | |
| 86 | + argv[0] = ref Value.TInt(v.jchar); | |
| 87 | + TShort => | |
| 88 | + argv[0] = ref Value.TInt(v.jshort); | |
| 89 | + } | |
| 90 | + case sig_part { | |
| 91 | + # SIGNATURE_BYTE | |
| 92 | + 'B' => | |
| 93 | + (a, b) = jni->CallMethod(this, "writeByte", "(I)V", argv); | |
| 94 | + # SIGNATURE_CHAR | |
| 95 | + 'C' => | |
| 96 | + (a, b) = jni->CallMethod(this, "writeChar", "(I)V", argv); | |
| 97 | + # SIGNATURE_FLOAT | |
| 98 | + 'F' => | |
| 99 | + (a, b) = jni->CallMethod(this, "writeFloat", "(F)V", argv); | |
| 100 | + # SIGNATURE_DOUBLE | |
| 101 | + 'D' => | |
| 102 | + (a, b) = jni->CallMethod(this, "writeDouble", "(D)V", argv); | |
| 103 | + # SIGNATURE_INT | |
| 104 | + 'I' => | |
| 105 | + (a, b) = jni->CallMethod(this, "writeInt", "(I)V", argv); | |
| 106 | + # SIGNATURE_LONG | |
| 107 | + 'J' => | |
| 108 | + (a, b) = jni->CallMethod(this, "writeLong", "(J)V", argv); | |
| 109 | + # SIGNATURE_SHORT | |
| 110 | + 'S' => | |
| 111 | + (a, b) = jni->CallMethod(this, "writeShort", "(I)V", argv); | |
| 112 | + # SIGNATURE_BOOLEAN | |
| 113 | + 'Z' => | |
| 114 | + (a, b) = jni->CallMethod(this, "writeBoolean", "(Z)V", argv); | |
| 115 | + # SIGNATURE_ARRAY | |
| 116 | + '[' => | |
| 117 | + (a, b) = jni->CallMethod(this, "writeObject", "(Ljava/lang/Object;)V", argv); | |
| 118 | + # SIGNATURE_CLASS | |
| 119 | + 'L' => | |
| 120 | + (a, b) = jni->CallMethod(this, "writeObject", "(Ljava/lang/Object;)V", argv); | |
| 121 | + } | |
| 122 | + } | |
| 123 | +}#<< | |
| 124 | + | |
| 125 | +outputArrayValues_rObject_rClass_V( this : JObject, p0 : JObject,p1 : JClass) | |
| 126 | +{#>> | |
| 127 | + # p0 the array being outputted | |
| 128 | + # p1 the class name of the elements of the array (this is also the arrays signature) | |
| 129 | + # | |
| 130 | + # | |
| 131 | + # make sure this is an array we have. If so, get the | |
| 132 | + # length and write it out. | |
| 133 | + # | |
| 134 | + if ( jni->IsArray(p0) == JNI->FALSE) { | |
| 135 | + jni->ThrowException("java.io.InvalidClassException", "Not an array"); | |
| 136 | + } | |
| 137 | + length := jni->GetArrayLength(cast->ToJArray(p0)); | |
| 138 | + argv := array[1] of ref Value; | |
| 139 | + argv[0] = ref Value.TInt(length); | |
| 140 | + (a, b) := jni->CallMethod(this, "writeInt", "(I)V", argv); | |
| 141 | + | |
| 142 | + # | |
| 143 | + # dispatch on the signature of the array and print out each element. | |
| 144 | + # | |
| 145 | + i : int; | |
| 146 | + case p1.aryname[1] { | |
| 147 | + # SIGNATURE_BYTE | |
| 148 | + 'B' => | |
| 149 | + { | |
| 150 | + JAByte := cast->ToJArrayB(p0); | |
| 151 | + for (i = 0; i < length; i++) { | |
| 152 | + argv[0] = ref Value.TInt(int JAByte.ary[i]); | |
| 153 | + (a, b) = jni->CallMethod(this, "writeByte", "(I)V", argv); | |
| 154 | + } | |
| 155 | + } | |
| 156 | + # SIGNATURE_CHAR | |
| 157 | + 'C' => | |
| 158 | + { | |
| 159 | + JAChar := cast->ToJArrayI(p0); | |
| 160 | + for (i = 0; i < length; i++) { | |
| 161 | + argv[0] = ref Value.TInt(JAChar.ary[i]); | |
| 162 | + (a, b) = jni->CallMethod(this, "writeChar", "(I)V", argv); | |
| 163 | + } | |
| 164 | + } | |
| 165 | + # SIGNATURE_FLOAT | |
| 166 | + 'F' => | |
| 167 | + { | |
| 168 | + JAFloat := cast->ToJArrayF(p0); | |
| 169 | + for (i = 0; i < length; i++) { | |
| 170 | + argv[0] = ref Value.TFloat(JAFloat.ary[i]); | |
| 171 | + (a, b) = jni->CallMethod(this, "writeFloat", "(F)V", argv); | |
| 172 | + } | |
| 173 | + } | |
| 174 | + # SIGNATURE_DOUBLE | |
| 175 | + 'D' => | |
| 176 | + { | |
| 177 | + JADouble := cast->ToJArrayD(p0); | |
| 178 | + for (i = 0; i < length; i++) { | |
| 179 | + argv[0] = ref Value.TDouble(JADouble.ary[i]); | |
| 180 | + (a, b) = jni->CallMethod(this, "writeDouble", "(D)V", argv); | |
| 181 | + } | |
| 182 | + } | |
| 183 | + # SIGNATURE_INT | |
| 184 | + 'I' => | |
| 185 | + { | |
| 186 | + JAInt := cast->ToJArrayI(p0); | |
| 187 | + for (i = 0; i < length; i++) { | |
| 188 | + argv[0] = ref Value.TInt(JAInt.ary[i]); | |
| 189 | + (a, b) = jni->CallMethod(this, "writeInt", "(I)V", argv); | |
| 190 | + } | |
| 191 | + } | |
| 192 | + # SIGNATURE_LONG | |
| 193 | + 'J' => | |
| 194 | + { | |
| 195 | + JALong := cast->ToJArrayJ(p0); | |
| 196 | + for (i = 0; i < length; i++) { | |
| 197 | + argv[0] = ref Value.TLong(JALong.ary[i]); | |
| 198 | + (a, b) = jni->CallMethod(this, "writeLong", "(J)V", argv); | |
| 199 | + } | |
| 200 | + } | |
| 201 | + # SIGNATURE_SHORT | |
| 202 | + 'S' => | |
| 203 | + { | |
| 204 | + JAShort := cast->ToJArrayI(p0); | |
| 205 | + for (i = 0; i < length; i++) { | |
| 206 | + argv[0] = ref Value.TInt(JAShort.ary[i]); | |
| 207 | + (a, b) = jni->CallMethod(this, "writeShort", "(I)V", argv); | |
| 208 | + } | |
| 209 | + } | |
| 210 | + # SIGNATURE_BOOLEAN | |
| 211 | + 'Z' => | |
| 212 | + { | |
| 213 | + JABool := cast->ToJArrayZ(p0); | |
| 214 | + for (i = 0; i < length; i++) { | |
| 215 | + argv[0] = ref Value.TBoolean(int JABool.ary[i]); | |
| 216 | + (a, b) = jni->CallMethod(this, "writeBoolean", "(Z)V", argv); | |
| 217 | + } | |
| 218 | + } | |
| 219 | + # SIGNATURE_ARRAY | |
| 220 | + '[' => | |
| 221 | + { | |
| 222 | + JAObj := cast->ToJArrayJObject(p0); | |
| 223 | + for (i = 0; i < length; i++) { | |
| 224 | + argv[0] = ref Value.TObject(JAObj.ary[i]); | |
| 225 | + (a, b) = jni->CallMethod(this, "writeObject", "(Ljava/lang/Object;)V", argv); | |
| 226 | + } | |
| 227 | + } | |
| 228 | + # SIGNATURE_CLASS | |
| 229 | + 'L' => | |
| 230 | + { | |
| 231 | + JAObj := cast->ToJArrayJObject(p0); | |
| 232 | + for (i = 0; i < length; i++) { | |
| 233 | + argv[0] = ref Value.TObject(JAObj.ary[i]); | |
| 234 | + (a, b) = jni->CallMethod(this, "writeObject", "(Ljava/lang/Object;)V", argv); | |
| 235 | + } | |
| 236 | + } | |
| 237 | + } | |
| 238 | +}#<< | |
| 239 | + | |
| 240 | +invokeObjectWriter_rObject_rClass_Z( this : JObject, p0 : JObject,p1 : JClass) : int | |
| 241 | +{#>> | |
| 242 | + junk := p1; | |
| 243 | + # | |
| 244 | + # call writeObject() on object "p0" with an argument of "this" | |
| 245 | + # | |
| 246 | + MyValueArray := array[] of { | |
| 247 | + ref Value.TObject(this) | |
| 248 | + }; | |
| 249 | + (a, b) := jni->CallMethod(p0, "writeObject", "(Ljava/io/ObjectOutputStream;)V", MyValueArray); | |
| 250 | + | |
| 251 | + return b == JNI->OK; | |
| 252 | +}#<< | |
| 253 | + | |
| 254 | +getRefHashCode_rObject_I( p0 : JObject) : int | |
| 255 | +{#>> | |
| 256 | + return( jni->IdentityHash(p0) ); | |
| 257 | +}#<< | |
| @@ -0,0 +1,33 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +ObjectOutputStream_L : module | |
| 4 | +{ | |
| 5 | + ObjectOutputStream_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + blockDataMode : byte; | |
| 9 | + buf : JArrayB; | |
| 10 | + count : int; | |
| 11 | + out : JObject; | |
| 12 | + dos : JObject; | |
| 13 | + abortIOException : JObject; | |
| 14 | + wireHandle2Object : JArrayJObject; | |
| 15 | + wireNextHandle : JArrayI; | |
| 16 | + wireHash2Handle : JArrayI; | |
| 17 | + nextWireOffset : int; | |
| 18 | + currentObject : JObject; | |
| 19 | + currentClassDesc : JObject; | |
| 20 | + classDescStack : JObject; | |
| 21 | + enableReplace : byte; | |
| 22 | + replaceObjects : JArrayJObject; | |
| 23 | + nextReplaceOffset : int; | |
| 24 | + recursionDepth : int; | |
| 25 | + }; | |
| 26 | + | |
| 27 | + init : fn( jni_p : JNI ); | |
| 28 | + outputClassFields_rObject_rClass_aI_V : fn( this : JObject, p0 : JObject,p1 : JClass,p2 : JArrayI); | |
| 29 | + outputArrayValues_rObject_rClass_V : fn( this : JObject, p0 : JObject,p1 : JClass); | |
| 30 | + invokeObjectWriter_rObject_rClass_Z : fn( this : JObject, p0 : JObject,p1 : JClass) : int; | |
| 31 | + getRefHashCode_rObject_I : fn( p0 : JObject) : int; | |
| 32 | + | |
| 33 | +}; | |
Empty file added.
| @@ -0,0 +1,164 @@ | ||
| 1 | +implement ObjectStreamClass_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + sys : import jni; | |
| 27 | + str : import jni; | |
| 28 | + FALSE : import jni; | |
| 29 | + TRUE : import jni; | |
| 30 | +#<< | |
| 31 | + | |
| 32 | +include "ObjectStreamClass_L.m"; | |
| 33 | + | |
| 34 | +#>> extra post includes here | |
| 35 | +include "workdir.m"; | |
| 36 | +include "regex.m"; | |
| 37 | +str_mod : String; | |
| 38 | +Value : import jni; | |
| 39 | +cast : Cast; | |
| 40 | +#<< | |
| 41 | + | |
| 42 | +init( jni_p : JNI ) | |
| 43 | +{ | |
| 44 | + # save java native inteface mod instance | |
| 45 | + jni = jni_p; | |
| 46 | + #>>extra initialization here | |
| 47 | + sys = jni->sys; | |
| 48 | + str_mod = jni->str; | |
| 49 | + cast = jni->CastMod(); | |
| 50 | + #<< | |
| 51 | +} | |
| 52 | + | |
| 53 | +getClassAccess_rClass_I( p0 : JClass) : int | |
| 54 | +{#>> | |
| 55 | + return (jni->GetClassFlags(p0) & JNI->ACC_WRITTEN_FLAGS); | |
| 56 | +}#<< | |
| 57 | + | |
| 58 | +getMethodSignatures_rClass_aString( p0 : JClass) : JArrayJString | |
| 59 | +{#>> | |
| 60 | + # Return an array of Strings containing the method names and signatures. | |
| 61 | + return (jni->GetMethodSignatures(p0, 0)); | |
| 62 | +}#<< | |
| 63 | + | |
| 64 | +getMethodAccess_rClass_rString_I( p0 : JClass,p1 : JString) : int | |
| 65 | +{#>> | |
| 66 | + return (jni->GetMethodFlags(p0, p1.str) & JNI->ACC_WRITTEN_FLAGS); | |
| 67 | +}#<< | |
| 68 | + | |
| 69 | +getFieldSignatures_rClass_aString( p0 : JClass) : JArrayJString | |
| 70 | +{#>> | |
| 71 | + # Return an array of Strings containing the field names and signatures. | |
| 72 | + return (jni->GetFieldSignatures(p0, 0)); | |
| 73 | +}#<< | |
| 74 | + | |
| 75 | +getFieldAccess_rClass_rString_I( p0 : JClass,p1 : JString) : int | |
| 76 | +{#>> | |
| 77 | + return (jni->GetFieldFlags(p0, p1.str) & JNI->ACC_WRITTEN_FLAGS); | |
| 78 | +}#<< | |
| 79 | + | |
| 80 | +getFields0_rClass_aObjectStreamField( this : ref ObjectStreamClass_obj, p0 : JClass) : JArrayJObject | |
| 81 | +{#>> | |
| 82 | + # | |
| 83 | + # Return an array of ObjectStreamField objects for each non-static and | |
| 84 | + # non-transient field of the specified class. First find and load the | |
| 85 | + # ObjectStreamField class. | |
| 86 | + # | |
| 87 | + junk := this; | |
| 88 | + cl_data := jni->FindClass("java/io/ObjectStreamField"); | |
| 89 | + if (cl_data == nil) | |
| 90 | + jni->FatalError("ObjectStreamClass could not load java/io/ObjectStreamField"); | |
| 91 | + | |
| 92 | + # | |
| 93 | + # Get a list of all non-static and non transient fields of this class. If there are | |
| 94 | + # non, jni->GetFieldSignatures() returns an array of length 0. | |
| 95 | + # | |
| 96 | + fields_n_sigs := jni->GetFieldSignatures(p0, (JNI->ACC_STATIC|JNI->ACC_TRANSIENT)); | |
| 97 | + | |
| 98 | + MyValueArray := array[4] of ref Value; | |
| 99 | + MyObjectArray := array[len fields_n_sigs.ary] of JObject; | |
| 100 | + | |
| 101 | + # | |
| 102 | + # for each non-static and non-transient fields of this class... | |
| 103 | + # call constructor for ObjectStreamField as follows | |
| 104 | + # ObjectStreamField(n, sig, o, t) | |
| 105 | + # where n is field name, sig is first byte of field signature | |
| 106 | + # o is index into class field table and if sig != [ or L, | |
| 107 | + # t is NULL. If sig is [ or L, t is signature. | |
| 108 | + # For each of those constructors that are created, stuff them into | |
| 109 | + # an array entry. | |
| 110 | + # | |
| 111 | + for (i:=0; i < len fields_n_sigs.ary; i++) { | |
| 112 | + # | |
| 113 | + # Each entry in fields_n_sigs.ary is of the format <name> <sig> where name is | |
| 114 | + # the name of the field and signature is its full signature. Seperate them | |
| 115 | + # out and format a call instruction to call the constructor for ObjectStreamField. | |
| 116 | + # | |
| 117 | + (name, full_sig) := str_mod->splitl((fields_n_sigs.ary[i]).str, " "); | |
| 118 | + full_sig = full_sig[1:]; | |
| 119 | + | |
| 120 | + MyValueArray[0] = ref Value.TObject(cast->FromJString(jni->NewString(name))); | |
| 121 | + MyValueArray[1] = ref Value.TChar(full_sig[0]); | |
| 122 | + # NOT offset of field in object (but does it matter)??? | |
| 123 | + MyValueArray[2] = ref Value.TInt(i); | |
| 124 | + if ((full_sig[0] == 'L') || (full_sig[0] == '[')) | |
| 125 | + MyValueArray[3] = ref Value.TObject(cast->FromJString(jni->NewString(full_sig))); | |
| 126 | + else | |
| 127 | + MyValueArray[3] = ref Value.TObject(nil); | |
| 128 | + | |
| 129 | + jObj := jni->AllocObject(cl_data); | |
| 130 | + (ret, ok) := jni->CallMethod(jObj, "<init>", "(Ljava/lang/String;CILjava/lang/String;)V", MyValueArray); | |
| 131 | + if (ok != JNI->OK) | |
| 132 | + jni->FatalError("ObjectStreamClass could not create ObjectStreamField"); | |
| 133 | + # | |
| 134 | + # make an array of these created objects. | |
| 135 | + # | |
| 136 | + MyObjectArray[i] = jObj; | |
| 137 | + } | |
| 138 | + # | |
| 139 | + # Finally, return the full array. | |
| 140 | + # | |
| 141 | + jary := jni->MkAObject(MyObjectArray); | |
| 142 | + jary.class = cl_data; | |
| 143 | + return jary; | |
| 144 | +}#<< | |
| 145 | + | |
| 146 | +getSerialVersionUID_rClass_J( p0 : JClass) : big | |
| 147 | +{#>> | |
| 148 | + ret : big; | |
| 149 | + val : ref Value; | |
| 150 | + val = jni->GetStaticField(p0.class, "serialVersionUID", "J"); | |
| 151 | + if (val != nil) | |
| 152 | + ret = val.Long(); | |
| 153 | + else | |
| 154 | + ret = big 0; | |
| 155 | + return ret; | |
| 156 | +}#<< | |
| 157 | + | |
| 158 | +hasWriteObject_rClass_Z( p0 : JClass) : int | |
| 159 | +{#>> | |
| 160 | + if (jni->GetMethodFlags(p0, "writeObject (Ljava/io/ObjectOutputStream;)V") != 0) | |
| 161 | + return JNI->TRUE; | |
| 162 | + else | |
| 163 | + return JNI->FALSE; | |
| 164 | +}#<< | |
| @@ -0,0 +1,30 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +ObjectStreamClass_L : module | |
| 4 | +{ | |
| 5 | + ObjectStreamClass_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + name : JString; | |
| 9 | + superclass : ref ObjectStreamClass_obj; | |
| 10 | + serializable : byte; | |
| 11 | + externalizable : byte; | |
| 12 | + fields : JArrayJObject; | |
| 13 | + ofClass : JClass; | |
| 14 | + suid : big; | |
| 15 | + fieldSequence : JArrayI; | |
| 16 | + hasWriteObjectMethod : byte; | |
| 17 | + localClassDesc : ref ObjectStreamClass_obj; | |
| 18 | + }; | |
| 19 | + | |
| 20 | + init : fn( jni_p : JNI ); | |
| 21 | + getClassAccess_rClass_I : fn( p0 : JClass) : int; | |
| 22 | + getMethodSignatures_rClass_aString : fn( p0 : JClass) : JArrayJString; | |
| 23 | + getMethodAccess_rClass_rString_I : fn( p0 : JClass,p1 : JString) : int; | |
| 24 | + getFieldSignatures_rClass_aString : fn( p0 : JClass) : JArrayJString; | |
| 25 | + getFieldAccess_rClass_rString_I : fn( p0 : JClass,p1 : JString) : int; | |
| 26 | + getFields0_rClass_aObjectStreamField : fn( this : ref ObjectStreamClass_obj, p0 : JClass) : JArrayJObject; | |
| 27 | + getSerialVersionUID_rClass_J : fn( p0 : JClass) : big; | |
| 28 | + hasWriteObject_rClass_Z : fn( p0 : JClass) : int; | |
| 29 | + | |
| 30 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,190 @@ | ||
| 1 | +implement RandomAccessFile_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + sys : import jni; | |
| 27 | + FALSE : import jni; | |
| 28 | + TRUE : import jni; | |
| 29 | +include "FileDescriptor_L.m"; | |
| 30 | + FileDescriptor_obj : import FileDescriptor_L; | |
| 31 | +#<< | |
| 32 | + | |
| 33 | +include "RandomAccessFile_L.m"; | |
| 34 | + | |
| 35 | +#>> extra post includes here | |
| 36 | +#<< | |
| 37 | + | |
| 38 | +init( jni_p : JNI ) | |
| 39 | +{ | |
| 40 | + # save java native inteface mod instance | |
| 41 | + jni = jni_p; | |
| 42 | + #>>extra initialization here | |
| 43 | + sys = jni->sys; | |
| 44 | + #<< | |
| 45 | +} | |
| 46 | + | |
| 47 | +open_rString_Z_V( this : ref RandomAccessFile_obj, p0 : JString,p1 : int) | |
| 48 | +{#>> | |
| 49 | + # p0 == file name | |
| 50 | + # p1 == writable flag | |
| 51 | + | |
| 52 | + if ((this.fd == nil) || (p0 == nil) || (p0.str == nil)) | |
| 53 | + jni->ThrowException("java.lang.NullPointerException", "null path name"); | |
| 54 | + | |
| 55 | + if (p1 == TRUE){ | |
| 56 | + this.fd.fd = sys->open(p0.str, sys->ORDWR); | |
| 57 | + if(this.fd.fd == nil) | |
| 58 | + this.fd.fd = sys->create(p0.str, Sys->ORDWR, 8r640); | |
| 59 | + } | |
| 60 | + else | |
| 61 | + this.fd.fd = sys->open(p0.str, sys->OREAD); | |
| 62 | + | |
| 63 | + if(this.fd.fd == nil) | |
| 64 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 65 | +}#<< | |
| 66 | + | |
| 67 | +read_I( this : ref RandomAccessFile_obj) : int | |
| 68 | +{#>> | |
| 69 | + buf := array[1] of byte; | |
| 70 | + | |
| 71 | + if ((this.fd == nil) || (this.fd.fd == nil)) | |
| 72 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 73 | + | |
| 74 | + readin := sys->read(this.fd.fd, buf, 1); | |
| 75 | + if (readin == 0) # EOF | |
| 76 | + return -1; | |
| 77 | + | |
| 78 | + if (readin < 0) | |
| 79 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 80 | + return (int buf[0]); | |
| 81 | +}#<< | |
| 82 | + | |
| 83 | +FD: import Sys; | |
| 84 | +stderr: ref FD; | |
| 85 | +readBytes_aB_I_I_I( this : ref RandomAccessFile_obj, p0 : JArrayB,p1 : int,p2 : int) : int | |
| 86 | +{#>> | |
| 87 | + # p0 == buffer for read in data | |
| 88 | + # p1 == offset in buffer to start to place data | |
| 89 | + # p2 == amount of data to read in | |
| 90 | + | |
| 91 | + if ((this.fd == nil) || (this.fd.fd == nil)) | |
| 92 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 93 | + | |
| 94 | + if ((p0 == nil) || (p0.ary == nil)) | |
| 95 | + jni->ThrowException("java.lang.NullPointerException", "null array"); | |
| 96 | + | |
| 97 | + if ((p1 < 0) || (p1 > len p0.ary)) | |
| 98 | + jni->ThrowException("java.lang.ArrayIndexOutOfBoundsException", nil); | |
| 99 | + | |
| 100 | + if ((p1 + p2) > len p0.ary) | |
| 101 | + p2 = (len p0.ary) - p1; | |
| 102 | + | |
| 103 | + if (p2 <= 0) | |
| 104 | + jni->ThrowException("java.lang.ArrayIndexOutOfBoundsException", | |
| 105 | +nil); | |
| 106 | + | |
| 107 | + n := sys->read(this.fd.fd, p0.ary[p1:len p0.ary], p2); | |
| 108 | + if (n == 0) # EOF | |
| 109 | + return -1; | |
| 110 | + | |
| 111 | + if (n < 0) | |
| 112 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 113 | + return n; | |
| 114 | +}#<< | |
| 115 | + | |
| 116 | +write_I_V( this : ref RandomAccessFile_obj, p0 : int) | |
| 117 | +{#>> | |
| 118 | + c := array[1] of byte; | |
| 119 | + c[0] = byte p0; | |
| 120 | + | |
| 121 | + if ((this.fd == nil) || (this.fd.fd == nil)) | |
| 122 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 123 | + | |
| 124 | + if (sys->write(this.fd.fd, c, 1) != 1) | |
| 125 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 126 | +}#<< | |
| 127 | + | |
| 128 | +writeBytes_aB_I_I_V( this : ref RandomAccessFile_obj, p0 : JArrayB,p1 : int,p2 : int) | |
| 129 | +{#>> | |
| 130 | + # p0 == buffer array to write from | |
| 131 | + # p1 == offset in buffer | |
| 132 | + # p2 == amount to write out | |
| 133 | + | |
| 134 | + if ((this.fd == nil) || (this.fd.fd == nil)) | |
| 135 | + jni->ThrowException("java.lang.NullPointerException", "null FileDescriptor"); | |
| 136 | + if ((p0 == nil) || (p0.ary == nil)) | |
| 137 | + jni->ThrowException("java.lang.NullPointerException", nil); | |
| 138 | + if ((p1 < 0) || (p2 < 0) || (p1 + p2 > (len p0.ary))) | |
| 139 | + jni->ThrowException("java.lang.ArrayIndexOutOfBoundsException", nil); | |
| 140 | + | |
| 141 | + n := 0; | |
| 142 | + while (p2 > 0) { | |
| 143 | + n = sys->write(this.fd.fd, p0.ary[p1:len p0.ary], p2); | |
| 144 | + if (n == -1) { | |
| 145 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 146 | + break; | |
| 147 | + } | |
| 148 | + p1 += n; | |
| 149 | + p2 -= n; | |
| 150 | + } | |
| 151 | +}#<< | |
| 152 | + | |
| 153 | +getFilePointer_J( this : ref RandomAccessFile_obj) : big | |
| 154 | +{#>> | |
| 155 | + if (this.fd == nil) | |
| 156 | + jni->ThrowException("java.io.IOException", "this.fd nil"); | |
| 157 | + cur := sys->seek(this.fd.fd, 0, sys->SEEKRELA); | |
| 158 | + if (cur < 0) | |
| 159 | + jni->ThrowException("java.io.IOException", sys->sprint("%r")); | |
| 160 | + return (big cur); | |
| 161 | +}#<< | |
| 162 | + | |
| 163 | +seek_J_V( this : ref RandomAccessFile_obj, p0 : big) | |
| 164 | +{#>> | |
| 165 | + if (this.fd == nil) | |
| 166 | + jni->ThrowException("java.io.IOException", "this.fd nil"); | |
| 167 | + sys->seek(this.fd.fd, (int p0), sys->SEEKSTART); | |
| 168 | +}#<< | |
| 169 | + | |
| 170 | +length_J( this : ref RandomAccessFile_obj) : big | |
| 171 | +{#>> | |
| 172 | + if (this.fd == nil) | |
| 173 | + jni->ThrowException("java.io.IOException", "this.fd nil"); | |
| 174 | + cur := sys->seek(this.fd.fd, 0, sys->SEEKRELA); | |
| 175 | + end := sys->seek(this.fd.fd, 0, sys->SEEKEND); | |
| 176 | + sys->seek(this.fd.fd, cur, sys->SEEKSTART); | |
| 177 | + | |
| 178 | + return (big end); | |
| 179 | +}#<< | |
| 180 | + | |
| 181 | +close_V( this : ref RandomAccessFile_obj) | |
| 182 | +{#>> | |
| 183 | + if (this.fd != nil) | |
| 184 | + this.fd.fd = nil; | |
| 185 | +}#<< | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| @@ -0,0 +1,22 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +RandomAccessFile_L : module | |
| 4 | +{ | |
| 5 | + RandomAccessFile_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + fd : ref FileDescriptor_obj; | |
| 9 | + }; | |
| 10 | + | |
| 11 | + init : fn( jni_p : JNI ); | |
| 12 | + open_rString_Z_V : fn( this : ref RandomAccessFile_obj, p0 : JString,p1 : int); | |
| 13 | + read_I : fn( this : ref RandomAccessFile_obj) : int; | |
| 14 | + readBytes_aB_I_I_I : fn( this : ref RandomAccessFile_obj, p0 : JArrayB,p1 : int,p2 : int) : int; | |
| 15 | + write_I_V : fn( this : ref RandomAccessFile_obj, p0 : int); | |
| 16 | + writeBytes_aB_I_I_V : fn( this : ref RandomAccessFile_obj, p0 : JArrayB,p1 : int,p2 : int); | |
| 17 | + getFilePointer_J : fn( this : ref RandomAccessFile_obj) : big; | |
| 18 | + seek_J_V : fn( this : ref RandomAccessFile_obj, p0 : big); | |
| 19 | + length_J : fn( this : ref RandomAccessFile_obj) : big; | |
| 20 | + close_V : fn( this : ref RandomAccessFile_obj); | |
| 21 | + | |
| 22 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,150 @@ | ||
| 1 | +<../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + BufferedInputStream.dis\ | |
| 5 | + BufferedOutputStream.dis\ | |
| 6 | + BufferedReader.dis\ | |
| 7 | + BufferedWriter.dis\ | |
| 8 | + ByteArrayInputStream.dis\ | |
| 9 | + ByteArrayOutputStream.dis\ | |
| 10 | + CharArrayReader.dis\ | |
| 11 | + CharArrayWriter.dis\ | |
| 12 | +# for CharConversionException.dis\ | |
| 13 | + oF8WXXue0VYZof82fzj4L.dis\ | |
| 14 | + DataInput.dis\ | |
| 15 | + DataInputStream.dis\ | |
| 16 | + DataOutput.dis\ | |
| 17 | + DataOutputStream.dis\ | |
| 18 | + EOFException.dis\ | |
| 19 | + Externalizable.dis\ | |
| 20 | + File.dis\ | |
| 21 | + FileDescriptor.dis\ | |
| 22 | + FileInputStream.dis\ | |
| 23 | + FileNotFoundException.dis\ | |
| 24 | + FileOutputStream.dis\ | |
| 25 | + FileReader.dis\ | |
| 26 | + FileWriter.dis\ | |
| 27 | + FilenameFilter.dis\ | |
| 28 | + FilterInputStream.dis\ | |
| 29 | + FilterOutputStream.dis\ | |
| 30 | + FilterReader.dis\ | |
| 31 | + FilterWriter.dis\ | |
| 32 | + IOException.dis\ | |
| 33 | + InputStream.dis\ | |
| 34 | + InputStreamReader.dis\ | |
| 35 | +# for InterruptedIOException.dis\ | |
| 36 | + Udmf2Su14O7L1V-QzaTq3.dis\ | |
| 37 | + InvalidClassException.dis\ | |
| 38 | +# for InvalidObjectException.dis\ | |
| 39 | + PjqhaWOg4nDK5hla7XFmv.dis\ | |
| 40 | + LineNumberInputStream.dis\ | |
| 41 | + LineNumberReader.dis\ | |
| 42 | + NotActiveException.dis\ | |
| 43 | +# for NotSerializableException.dis\ | |
| 44 | + YBCI4zMUNV+Uc45idEPcv.dis\ | |
| 45 | + ObjectInput.dis\ | |
| 46 | + ObjectInputStream.dis\ | |
| 47 | + ObjectInputValidation.dis\ | |
| 48 | + ObjectOutput.dis\ | |
| 49 | + ObjectOutputStream.dis\ | |
| 50 | + ObjectStreamClass.dis\ | |
| 51 | +# for ObjectStreamClassEntry.dis\ | |
| 52 | + 6T1LdH4wdbOUJeqUfASeI.dis\ | |
| 53 | + ObjectStreamConstants.dis\ | |
| 54 | + ObjectStreamException.dis\ | |
| 55 | + ObjectStreamField.dis\ | |
| 56 | + OptionalDataException.dis\ | |
| 57 | + OutputStream.dis\ | |
| 58 | + OutputStreamWriter.dis\ | |
| 59 | + PipedInputStream.dis\ | |
| 60 | + PipedOutputStream.dis\ | |
| 61 | + PipedReader.dis\ | |
| 62 | + PipedWriter.dis\ | |
| 63 | + PrintStream.dis\ | |
| 64 | + PrintWriter.dis\ | |
| 65 | + PushbackInputStream.dis\ | |
| 66 | + PushbackReader.dis\ | |
| 67 | + RandomAccessFile.dis\ | |
| 68 | + Reader.dis\ | |
| 69 | + SequenceInputStream.dis\ | |
| 70 | + Serializable.dis\ | |
| 71 | +# for StreamCorruptedException.dis\ | |
| 72 | + 7Ev9-si8zsgglOEBSxbM3.dis\ | |
| 73 | + StreamTokenizer.dis\ | |
| 74 | +# for StringBufferInputStream.dis\ | |
| 75 | + O+cE9tcuJ1-znyckKtvEt.dis\ | |
| 76 | + StringReader.dis\ | |
| 77 | + StringWriter.dis\ | |
| 78 | + SyncFailedException.dis\ | |
| 79 | +# for UTFDataFormatException.dis\ | |
| 80 | + VgQ9w-N7w2YXJglmrtjzJ.dis\ | |
| 81 | +# for UnsupportedEncodingException.dis\ | |
| 82 | + 34nQVDtVtK+3NDDpbkN7j.dis\ | |
| 83 | + ValidationCallback.dis\ | |
| 84 | + WriteAbortedException.dis\ | |
| 85 | + Writer.dis\ | |
| 86 | +# Limbo code\ | |
| 87 | + FileDescriptor_L.dis\ | |
| 88 | + FileInputStream_L.dis\ | |
| 89 | + FileOutputStream_L.dis\ | |
| 90 | + File_L.dis\ | |
| 91 | + ObjectInputStream_L.dis\ | |
| 92 | + ObjectOutputStream_L.dis\ | |
| 93 | + ObjectStreamClass_L.dis\ | |
| 94 | + RandomAccessFile_L.dis\ | |
| 95 | + | |
| 96 | +MODULES=\ | |
| 97 | + $ROOT/java/module/classloader.m\ | |
| 98 | + $ROOT/java/module/jni.m\ | |
| 99 | + $ROOT/java/module/cast.m\ | |
| 100 | + FileDescriptor_L.m\ | |
| 101 | + FileInputStream_L.m\ | |
| 102 | + FileOutputStream_L.m\ | |
| 103 | + File_L.m\ | |
| 104 | + ObjectInputStream_L.m\ | |
| 105 | + ObjectOutputStream_L.m\ | |
| 106 | + ObjectStreamClass_L.m\ | |
| 107 | + RandomAccessFile_L.m\ | |
| 108 | + | |
| 109 | +SYSMODULES=\ | |
| 110 | + draw.m\ | |
| 111 | + hash.m\ | |
| 112 | + keyring.m\ | |
| 113 | + loader.m\ | |
| 114 | + math.m\ | |
| 115 | + string.m\ | |
| 116 | + sys.m\ | |
| 117 | + | |
| 118 | +DISBIN=$ROOT/java/dis/java/java/io | |
| 119 | + | |
| 120 | +<$ROOT/mkfiles/mkjava | |
| 121 | + | |
| 122 | +oF8WXXue0VYZof82fzj4L.dis: CharConversionException.class | |
| 123 | + j2d CharConversionException.class | |
| 124 | + | |
| 125 | +Udmf2Su14O7L1V-QzaTq3.dis: InterruptedIOException.class | |
| 126 | + j2d InterruptedIOException.class | |
| 127 | + | |
| 128 | +PjqhaWOg4nDK5hla7XFmv.dis: InvalidObjectException.class | |
| 129 | + j2d InvalidObjectException.class | |
| 130 | + | |
| 131 | +YBCI4zMUNV+Uc45idEPcv.dis: NotSerializableException.class | |
| 132 | + j2d NotSerializableException.class | |
| 133 | + | |
| 134 | +6T1LdH4wdbOUJeqUfASeI.dis: ObjectStreamClass.class | |
| 135 | + j2d ObjectStreamClassEntry.class | |
| 136 | + | |
| 137 | +7Ev9-si8zsgglOEBSxbM3.dis: StreamCorruptedException.class | |
| 138 | + j2d StreamCorruptedException.class | |
| 139 | + | |
| 140 | +O+cE9tcuJ1-znyckKtvEt.dis: StringBufferInputStream.class | |
| 141 | + j2d StringBufferInputStream.class | |
| 142 | + | |
| 143 | +VgQ9w-N7w2YXJglmrtjzJ.dis: UTFDataFormatException.class | |
| 144 | + j2d UTFDataFormatException.class | |
| 145 | + | |
| 146 | +34nQVDtVtK+3NDDpbkN7j.dis: UnsupportedEncodingException.class | |
| 147 | + j2d UnsupportedEncodingException.class | |
| 148 | + | |
| 149 | +ValidationCallback.dis: ObjectInputStream.class | |
| 150 | + j2d ValidationCallback.class | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,63 @@ | ||
| 1 | +implement Character_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +#<< | |
| 28 | + | |
| 29 | +include "Character_L.m"; | |
| 30 | + | |
| 31 | +#>> extra post includes here | |
| 32 | + | |
| 33 | +include "unicode_table.m"; | |
| 34 | + | |
| 35 | +unicode_table : UnicodeTable; | |
| 36 | + A, | |
| 37 | + Y, | |
| 38 | + X : import unicode_table; | |
| 39 | + | |
| 40 | +#<< | |
| 41 | + | |
| 42 | +init( jni_p : JNI ) | |
| 43 | +{ | |
| 44 | + # save java native inteface mod instance | |
| 45 | + jni = jni_p; | |
| 46 | + #>>extra initialization here | |
| 47 | + #<< | |
| 48 | +} | |
| 49 | + | |
| 50 | +lookup_C_I( p0 : int) : int | |
| 51 | +{#>> | |
| 52 | + if ( unicode_table == nil ) | |
| 53 | + loadtable(); | |
| 54 | + | |
| 55 | + return( A[Y[(X[p0>>6]<<6)|(p0& 16r3F)]] ); | |
| 56 | +}#<< | |
| 57 | + | |
| 58 | +loadtable() | |
| 59 | +{ | |
| 60 | + unicode_table = load UnicodeTable UnicodeTable->PATH; | |
| 61 | + if ( unicode_table == nil ) | |
| 62 | + jni->InitError( jni->sys->sprint( "java.lang.Character: could not load %s: %r", UnicodeTable->PATH ) ); | |
| 63 | +} | |
| @@ -0,0 +1,14 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +Character_L : module | |
| 4 | +{ | |
| 5 | + Character_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + value : int; | |
| 9 | + }; | |
| 10 | + | |
| 11 | + init : fn( jni_p : JNI ); | |
| 12 | + lookup_C_I : fn( p0 : int) : int; | |
| 13 | + | |
| 14 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,82 @@ | ||
| 1 | +implement ClassLoader_L; | |
| 2 | + | |
| 3 | +# javal v1.2 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JObject : import jni; | |
| 23 | + | |
| 24 | +#>> extra pre includes here | |
| 25 | + | |
| 26 | +#<< | |
| 27 | + | |
| 28 | +include "ClassLoader_L.m"; | |
| 29 | + | |
| 30 | +#>> extra post includes here | |
| 31 | + | |
| 32 | +#<< | |
| 33 | + | |
| 34 | +init( jni_p : JNI ) | |
| 35 | +{ | |
| 36 | + # save java native inteface mod instance | |
| 37 | + jni = jni_p; | |
| 38 | + #>>extra initialization here | |
| 39 | + #<< | |
| 40 | +} | |
| 41 | + | |
| 42 | +init_V( this : ref ClassLoader_obj) | |
| 43 | +{#>> | |
| 44 | + junk := this; | |
| 45 | +}#<< | |
| 46 | + | |
| 47 | +defineClass0_rString_aB_I_I_rClass( this : ref ClassLoader_obj, p0 : JString,p1 : JArrayB,p2 : int,p3 : int) : JClass | |
| 48 | +{#>> | |
| 49 | + junk := (this,p0,p1,p2,p3); | |
| 50 | + jni->ThrowException( "java.lang.ClassNotFoundException", "not implemented" ); | |
| 51 | + return( nil ); | |
| 52 | +}#<< | |
| 53 | + | |
| 54 | +resolveClass0_rClass_V( this : ref ClassLoader_obj, p0 : JClass) | |
| 55 | +{#>> | |
| 56 | + junk := (this,p0); | |
| 57 | + jni->FatalError( "resolveClass() not implemented" ); | |
| 58 | +}#<< | |
| 59 | + | |
| 60 | +findSystemClass0_rString_rClass( this : ref ClassLoader_obj, p0 : JString) : JClass | |
| 61 | +{#>> | |
| 62 | + junk := (this,p0); | |
| 63 | + jni->FatalError( "findSystemClass() not implemented" ); | |
| 64 | + return( nil ); | |
| 65 | +}#<< | |
| 66 | + | |
| 67 | +getSystemResourceAsStream0_rString_rInputStream( p0 : JString) : JObject | |
| 68 | +{#>> | |
| 69 | + junk := p0; | |
| 70 | + jni->FatalError( "getSystemResourceAsStream() not implemented" ); | |
| 71 | + return( nil ); | |
| 72 | +}#<< | |
| 73 | + | |
| 74 | +getSystemResourceAsName0_rString_rString( p0 : JString) : JString | |
| 75 | +{#>> | |
| 76 | + junk := p0; | |
| 77 | + jni->FatalError( "getSystemResourceAsName() not implemented" ); | |
| 78 | + return( nil ); | |
| 79 | +}#<< | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| @@ -0,0 +1,20 @@ | ||
| 1 | +# javal v1.2 generated file: edit with care | |
| 2 | + | |
| 3 | +ClassLoader_L : module | |
| 4 | +{ | |
| 5 | + ClassLoader_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + initialized : int; | |
| 9 | + classes : JObject; | |
| 10 | + }; | |
| 11 | + | |
| 12 | + init : fn( jni_p : JNI ); | |
| 13 | + init_V : fn( this : ref ClassLoader_obj); | |
| 14 | + defineClass0_rString_aB_I_I_rClass : fn( this : ref ClassLoader_obj, p0 : JString,p1 : JArrayB,p2 : int,p3 : int) : JClass; | |
| 15 | + resolveClass0_rClass_V : fn( this : ref ClassLoader_obj, p0 : JClass); | |
| 16 | + findSystemClass0_rString_rClass : fn( this : ref ClassLoader_obj, p0 : JString) : JClass; | |
| 17 | + getSystemResourceAsStream0_rString_rInputStream : fn( p0 : JString) : JObject; | |
| 18 | + getSystemResourceAsName0_rString_rString : fn( p0 : JString) : JString; | |
| 19 | + | |
| 20 | +}; | |
Empty file added.
| @@ -0,0 +1,778 @@ | ||
| 1 | +implement Class_L; | |
| 2 | + | |
| 3 | +# javal v1.2 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JObject : import jni; | |
| 23 | + | |
| 24 | +#>> extra pre includes here | |
| 25 | + | |
| 26 | + jldr : JavaClassLoader; | |
| 27 | + cast : Cast; | |
| 28 | + | |
| 29 | +#<< | |
| 30 | + | |
| 31 | +include "Class_L.m"; | |
| 32 | + | |
| 33 | +#>> extra post includes here | |
| 34 | + | |
| 35 | + ClassData, | |
| 36 | + Value : import jni; | |
| 37 | + | |
| 38 | +include "reflect/reflect.m"; | |
| 39 | + refl : Reflect; | |
| 40 | + | |
| 41 | +#<< | |
| 42 | + | |
| 43 | +init( jni_p : JNI ) | |
| 44 | +{ | |
| 45 | + # save java native inteface mod instance | |
| 46 | + jni = jni_p; | |
| 47 | + #>>extra initialization here | |
| 48 | + jldr = jni->jldr; | |
| 49 | + cast = jni->CastMod(); | |
| 50 | + #<< | |
| 51 | +} | |
| 52 | + | |
| 53 | +forName_rString_rClass( p0 : JString) : JClass | |
| 54 | +{#>> | |
| 55 | + e := ref Sys->Exception; | |
| 56 | + if (jni->sys->rescue("JLD:e0*", e) == Sys->HANDLER) | |
| 57 | + { | |
| 58 | + if ( p0.str != nil && p0.str[0] == '[' ) | |
| 59 | + return( jni->LookupArrayClass(p0.str) ); | |
| 60 | + else | |
| 61 | + return( jni->GetClassObject( jni->FindClass(p0.str) ) ); | |
| 62 | + } | |
| 63 | + | |
| 64 | + jni->sys->rescued(Sys->ONCE, nil); | |
| 65 | + # turn into a ClassNotFoundException | |
| 66 | + jni->ThrowException( "java.lang.ClassNotFoundException", p0.str ); | |
| 67 | + return(nil); | |
| 68 | +}#<< | |
| 69 | + | |
| 70 | +newInstance_rObject( this : JClass) : JObject | |
| 71 | +{#>> | |
| 72 | + if ( this.class.flags & (JNI->ACC_INTERFACE | JNI->ACC_ABSTRACT) ) { | |
| 73 | + s : string; | |
| 74 | + if ( isPrimitive_Z(this) == JNI->TRUE ) | |
| 75 | + s = this.class.name[len "inferno/vm/":len this.class.name - 2]; | |
| 76 | + else if ( this.aryname != nil ) | |
| 77 | + s = this.aryname; | |
| 78 | + else | |
| 79 | + s = this.class.name; | |
| 80 | + jni->ThrowException( "java.lang.InstantiationException", s ); | |
| 81 | + } | |
| 82 | + # create new object for the given class | |
| 83 | + return( jni->NewObject(this.class) ); | |
| 84 | +}#<< | |
| 85 | + | |
| 86 | +isInstance_rObject_Z( this : JClass, p0 : JObject) : int | |
| 87 | +{#>> | |
| 88 | + return( jni->IsInstanceOf( p0, this.class ) ); | |
| 89 | +}#<< | |
| 90 | + | |
| 91 | +isAssignableFrom_rClass_Z( this : JClass, p0 : JClass) : int | |
| 92 | +{#>> | |
| 93 | + return( jni->IsAssignable( p0, this ) ); | |
| 94 | +}#<< | |
| 95 | + | |
| 96 | +isInterface_Z( this : JClass) : int | |
| 97 | +{#>> | |
| 98 | + return( this.class.flags & JNI->ACC_INTERFACE ); | |
| 99 | +}#<< | |
| 100 | + | |
| 101 | +isArray_Z( this : JClass) : int | |
| 102 | +{#>> | |
| 103 | + return( this.class.name == "inferno/vm/Array" ); | |
| 104 | +}#<< | |
| 105 | + | |
| 106 | +isPrimitive_Z( this : JClass) : int | |
| 107 | +{#>> | |
| 108 | + ret : int; | |
| 109 | + if ( jni->PrimitiveIndex(this, 0) > 0 ) | |
| 110 | + ret = JNI->TRUE; | |
| 111 | + else | |
| 112 | + ret = JNI->FALSE; | |
| 113 | + return ret; | |
| 114 | +}#<< | |
| 115 | + | |
| 116 | +getName_rString( this : JClass) : JString | |
| 117 | +{#>> | |
| 118 | + name : string; | |
| 119 | + if ( isPrimitive_Z(this) == JNI->TRUE ) | |
| 120 | + { | |
| 121 | + # mk primitive name from a slice | |
| 122 | + name = this.class.name[len "inferno/vm/":len this.class.name - 2]; | |
| 123 | + } | |
| 124 | + else | |
| 125 | + { | |
| 126 | + if ( this.aryname != nil ) | |
| 127 | + { | |
| 128 | + name = this.aryname; | |
| 129 | + } | |
| 130 | + else | |
| 131 | + { | |
| 132 | + name = this.class.name; | |
| 133 | + } | |
| 134 | + # change slashes to dots | |
| 135 | + for ( i := 0; i < len name; i++ ) | |
| 136 | + if ( name[i] == '/' ) | |
| 137 | + name[i] = '.'; | |
| 138 | + } | |
| 139 | + return( jni->NewString( name ) ); | |
| 140 | +}#<< | |
| 141 | + | |
| 142 | +getClassLoader_rClassLoader( this : JClass) : JObject | |
| 143 | +{#>> | |
| 144 | + junk := (this); | |
| 145 | + jni->FatalError( "getClassLoader() not implemented" ); | |
| 146 | + return(nil); | |
| 147 | +}#<< | |
| 148 | + | |
| 149 | +getSuperclass_rClass( this : JClass) : JClass | |
| 150 | +{#>> | |
| 151 | + if ( isPrimitive_Z(this) == JNI->TRUE | |
| 152 | + || this.class.flags & JNI->ACC_INTERFACE ) | |
| 153 | + return nil; | |
| 154 | + if ( (superclass := jni->GetSuperclass(this.class)) == nil ) | |
| 155 | + return nil; | |
| 156 | + return( jni->GetClassObject( superclass ) ); | |
| 157 | +}#<< | |
| 158 | + | |
| 159 | +getInterfaces_aClass( this : JClass) : JArrayJClass | |
| 160 | +{#>> | |
| 161 | + n : int; | |
| 162 | + # kludge for arrays to be consistent with JavaSoft's VM | |
| 163 | + if ( isArray_Z(this) ) | |
| 164 | + n = 0; | |
| 165 | + else | |
| 166 | + n = len this.class.interdirect; | |
| 167 | + interface := array [n] of JObject; | |
| 168 | + il := this.class.interdirect; | |
| 169 | + for (i := n-1; i >= 0; i--) { | |
| 170 | + interface[i] = cast->FromJClass(jni->GetClassObject(hd il)); | |
| 171 | + il = tl il; | |
| 172 | + } | |
| 173 | + classarray := cast->JArrayToClass(cast->ObjectToJArray(jni->MkAObject(interface))); | |
| 174 | + classarray.class = jni->FindClass("java/lang/Class"); | |
| 175 | + return classarray; | |
| 176 | +}#<< | |
| 177 | + | |
| 178 | +getComponentType_rClass(this : JClass) : JClass | |
| 179 | +{#>> | |
| 180 | + if(this == nil || this.aryname == nil) | |
| 181 | + return nil; | |
| 182 | + | |
| 183 | + name : string; | |
| 184 | + c := this.aryname[1]; | |
| 185 | + if(c == '[') { | |
| 186 | + return jni->LookupArrayClass(this.aryname[1:]); | |
| 187 | + } else { | |
| 188 | + if(c == 'L') { | |
| 189 | + name = this.aryname[2:len this.aryname - 1]; | |
| 190 | + } else { | |
| 191 | + getReflect(); | |
| 192 | + name = "inferno/vm/" + refl->TypeCharToName(c) + "_p"; | |
| 193 | + } | |
| 194 | + return jni->GetClassObject(jni->FindClass(name)); | |
| 195 | + } | |
| 196 | +}#<< | |
| 197 | + | |
| 198 | +getModifiers_I( this : JClass) : int | |
| 199 | +{#>> | |
| 200 | + return( this.class.flags & (~ JNI->ACC_SYNCHRONIZED)); | |
| 201 | +}#<< | |
| 202 | + | |
| 203 | +getSigners_aObject( this : JClass) : JArrayJObject | |
| 204 | +{#>> | |
| 205 | + junk := (this); | |
| 206 | + jni->FatalError( "getSigners() not implemented" ); | |
| 207 | + return(nil); | |
| 208 | +}#<< | |
| 209 | + | |
| 210 | +setSigners_aObject_V( this : JClass, p0 : JArrayJObject) | |
| 211 | +{#>> | |
| 212 | + junk := (this,p0); | |
| 213 | + jni->FatalError( "setSigners() not implemented" ); | |
| 214 | +}#<< | |
| 215 | + | |
| 216 | +getPrimitiveClass_rString_rClass( p0 : JString) : JClass | |
| 217 | +{#>> | |
| 218 | + e := ref Sys->Exception; | |
| 219 | + if (jni->sys->rescue("JLD:e0*", e) == Sys->HANDLER) | |
| 220 | + { | |
| 221 | + return( jni->GetClassObject(jni->FindClass("inferno/vm/"+ p0.str +"_p")) ); | |
| 222 | + } | |
| 223 | + return(nil); | |
| 224 | +}#<< | |
| 225 | + | |
| 226 | +getFields0_I_aField( this : JClass, p0 : int) : JArrayJObject | |
| 227 | +{#>> | |
| 228 | +# 'this' represents the class whose fields are wanted. | |
| 229 | +# p0 == 0 for PUBLIC members (includes inherited members) | |
| 230 | +# p0 == 1 for DECLARED members (All members but not inherited members) | |
| 231 | + | |
| 232 | + objs : list of JObject; | |
| 233 | + if ( !isArray_Z(this) ) | |
| 234 | + objs = getFields(this, p0); | |
| 235 | + | |
| 236 | + obj_array := array[len objs] of JObject; | |
| 237 | + for ( i := 0; objs != nil ; i++ ) { | |
| 238 | + obj_array[i] = hd objs; | |
| 239 | + objs = tl objs; | |
| 240 | + } | |
| 241 | + | |
| 242 | + fieldarray := jni->MkAObject(obj_array); | |
| 243 | + fieldarray.class = jni->FindClass("java/lang/reflect/Field"); | |
| 244 | + return fieldarray; | |
| 245 | +}#<< | |
| 246 | + | |
| 247 | +getMethods0_I_aMethod( this : JClass, p0 : int) : JArrayJObject | |
| 248 | +{#>> | |
| 249 | +# 'this' represents the class whose methods are wanted. | |
| 250 | +# p0 == 0 for PUBLIC members (includes inherited members) | |
| 251 | +# p0 == 1 for DECLARED members (All members but not inherited members) | |
| 252 | + | |
| 253 | + objs : list of JObject; | |
| 254 | + | |
| 255 | + # if primitive or interface, filter out java.lang.Object methods | |
| 256 | + if ( isPrimitive_Z(this) == JNI->TRUE | |
| 257 | + || this.class.flags & JNI->ACC_INTERFACE ) | |
| 258 | + p0 = 1; | |
| 259 | + objs = getMethods(this, p0); | |
| 260 | + | |
| 261 | + obj_array := array[len objs] of JObject; | |
| 262 | + for ( i := 0; objs != nil ; i++ ) { | |
| 263 | + obj_array[i] = hd objs; | |
| 264 | + objs = tl objs; | |
| 265 | + } | |
| 266 | + | |
| 267 | + methodarray := jni->MkAObject(obj_array); | |
| 268 | + methodarray.class = jni->FindClass("java/lang/reflect/Method"); | |
| 269 | + return methodarray; | |
| 270 | +}#<< | |
| 271 | + | |
| 272 | +getConstructors0_I_aConstructor( this : JClass, p0 : int) : JArrayJObject | |
| 273 | +{#>> | |
| 274 | +# 'this' represents the class whose constructors are wanted. | |
| 275 | +# p0 == 0 for PUBLIC members (includes inherited members) | |
| 276 | +# p0 == 1 for DECLARED members (All members but not inherited members) | |
| 277 | + | |
| 278 | + objs : list of JObject; | |
| 279 | + if ( isPrimitive_Z(this) == JNI->FALSE && !isArray_Z(this) ) | |
| 280 | + objs = getConstructors(this, p0); | |
| 281 | + | |
| 282 | + obj_array := array[len objs] of JObject; | |
| 283 | + for ( i := 0; objs != nil ; i++ ) { | |
| 284 | + obj_array[i] = hd objs; | |
| 285 | + objs = tl objs; | |
| 286 | + } | |
| 287 | + | |
| 288 | + constructorarray := jni->MkAObject(obj_array); | |
| 289 | + constructorarray.class = jni->FindClass("java/lang/reflect/Constructor"); | |
| 290 | + return constructorarray; | |
| 291 | +}#<< | |
| 292 | + | |
| 293 | +getField0_rString_I_rField( this : JClass, p0 : JString,p1 : int) : JObject | |
| 294 | +{#>> | |
| 295 | +# 'this' represents the class for which a Field is desired. | |
| 296 | +# p0 is the name of the field. | |
| 297 | +# p1 == 0 for PUBLIC members (includes inherited members) | |
| 298 | +# p1 == 1 for DECLARED members (All members but not inherited members) | |
| 299 | + | |
| 300 | + staticfields := this.class.staticdata; | |
| 301 | + flg : int; | |
| 302 | + fld : ref jldr->Field; | |
| 303 | + for ( i := 0; i < len staticfields; i++ ) { | |
| 304 | + fld = staticfields[i]; | |
| 305 | + flg = fld.flags; | |
| 306 | + if ( fld.field == p0.str && | |
| 307 | + (p1 != 0 || (flg & JNI->ACC_PUBLIC) != 0) ) | |
| 308 | + break; | |
| 309 | + } | |
| 310 | + if ( i >= len staticfields ) { # Not a public static field | |
| 311 | + super : list of ref jldr->Field = nil; | |
| 312 | + if ( (superclass := jni->GetSuperclass(this.class)) != nil && | |
| 313 | + superclass != this.class ) | |
| 314 | + super = superclass.objectdata; | |
| 315 | + objfields := this.class.objectdata; | |
| 316 | + for ( i = 0; objfields != nil; i++ ) { | |
| 317 | + if ( p1 == 1 && objfields == super ) # exclude inherited | |
| 318 | + break; | |
| 319 | + fld = hd objfields; | |
| 320 | + flg = fld.flags; | |
| 321 | + if ( fld.field == p0.str && | |
| 322 | + (p1 != 0 || (flg & JNI->ACC_PUBLIC) != 0) ) | |
| 323 | + break; | |
| 324 | + objfields = tl objfields; | |
| 325 | + } | |
| 326 | + if ( objfields == super || objfields == nil ) | |
| 327 | + i = len staticfields + len this.class.objectdata; | |
| 328 | + } | |
| 329 | + if ( i >= len staticfields + len this.class.objectdata ) { | |
| 330 | + jni->ThrowException("java/lang/NoSuchFieldException", ""); | |
| 331 | + return nil; | |
| 332 | + } | |
| 333 | + return makeField(this, fld, i); | |
| 334 | +}#<< | |
| 335 | + | |
| 336 | +getMethod0_rString_aClass_I_rMethod( this : JClass, p0 : JString,p1 : JArrayJClass,p2 : int) : JObject | |
| 337 | +{#>> | |
| 338 | +# 'this' represents the class for which a Method is desired. | |
| 339 | +# p0 is the name of the method. | |
| 340 | +# p1 is a Java array of Class objects, corresponding to the formal parameters | |
| 341 | +# of the method for which a Method object is desired. The array | |
| 342 | +# is used to construct a signature string which can be matched against | |
| 343 | +# data compiled by the classloader. | |
| 344 | +# p2 == 0 for PUBLIC members (includes inherited members) | |
| 345 | +# p2 == 1 for DECLARED members (All members but not inherited members) | |
| 346 | + | |
| 347 | + signatur := "(" + MakeSignature(p1) + ")"; | |
| 348 | + | |
| 349 | + methods := this.class.staticmethods; | |
| 350 | + for ( i := 0; i < len methods; i++ ) { | |
| 351 | + fld := methods[i]; | |
| 352 | + if ( fld.field == p0.str && jni->str->prefix(signatur, fld.signature) && | |
| 353 | + (p2 != 0 || (fld.flags & JNI->ACC_PUBLIC) != 0) ) | |
| 354 | + return makeMethod(this, fld, i, p1, fld.signature[len signatur:]); | |
| 355 | + } | |
| 356 | + methods = this.class.privatemethods; | |
| 357 | + for ( i = 0; i < len methods; i++ ) { | |
| 358 | + fld := methods[i]; | |
| 359 | + if ( fld.field == p0.str && jni->str->prefix(signatur, fld.signature) && | |
| 360 | + (p2 != 0 || (fld.flags & JNI->ACC_PUBLIC) != 0) ) | |
| 361 | + return makeMethod(this, fld, i, p1, fld.signature[len signatur:]); | |
| 362 | + } | |
| 363 | + vmethods := this.class.virtualmethods; | |
| 364 | + for ( i = 0; i < len vmethods; i++ ) { | |
| 365 | + fld := vmethods[i].field; | |
| 366 | + if ( fld.field == p0.str && jni->str->prefix(signatur, fld.signature) && | |
| 367 | + ((p2 != 0 && this.class == vmethods[i].class) | |
| 368 | + || (fld.flags & JNI->ACC_PUBLIC) != 0) ) { | |
| 369 | + if ( vmethods[i].class != this.class ) | |
| 370 | + this = jni->GetClassObject(vmethods[i].class); | |
| 371 | + return makeMethod(this, fld, i, p1, fld.signature[len signatur:]); | |
| 372 | + } | |
| 373 | + } | |
| 374 | + jni->ThrowException("java/lang/NoSuchMethodException", ""); | |
| 375 | + return nil; | |
| 376 | +}#<< | |
| 377 | + | |
| 378 | +getConstructor0_aClass_I_rConstructor( this : JClass, p0 : JArrayJClass,p1 : int) : JObject | |
| 379 | +{#>> | |
| 380 | +# 'this' represents the class for which a Constructor is desired. | |
| 381 | +# p0 is a Java array of Class objects, corresponding to the formal parameters | |
| 382 | +# of the constructor for which a Constructor object is desired. The array | |
| 383 | +# is used to construct a signature string which can be matched against | |
| 384 | +# data compiled by the classloader. | |
| 385 | +# p1 == 0 for PUBLIC members (includes inherited members) | |
| 386 | +# p1 == 1 for DECLARED members (All members but not inherited members) | |
| 387 | + | |
| 388 | + signatur := "(" + MakeSignature(p0) + ")"; | |
| 389 | + | |
| 390 | + initmethods := this.class.initmethods; | |
| 391 | + flg : int; | |
| 392 | + fld : ref jldr->Field; | |
| 393 | + for ( i := 0; i < len initmethods; i++ ) { | |
| 394 | + fld = initmethods[i]; | |
| 395 | + flg = fld.flags; | |
| 396 | + if ( jni->str->prefix(signatur, fld.signature) && | |
| 397 | + (p1 != 0 || (flg & JNI->ACC_PUBLIC) != 0) ) | |
| 398 | + break; | |
| 399 | + } | |
| 400 | + if ( i >= len initmethods ) { | |
| 401 | + jni->ThrowException("java/lang/NoSuchMethodException", ""); | |
| 402 | + return nil; | |
| 403 | + } | |
| 404 | + return makeMethod(this, fld, i, p0, nil); | |
| 405 | +}#<< | |
| 406 | + | |
| 407 | +# | |
| 408 | +# getPublicStaticFields() and doInterfaces() are helper | |
| 409 | +# functions for getFields(). | |
| 410 | +# | |
| 411 | + | |
| 412 | +# | |
| 413 | +# Return list of public static fields of this class. | |
| 414 | +# | |
| 415 | + | |
| 416 | +getPublicStaticFields(this : JClass, objs : list of JObject) : list of JObject | |
| 417 | +{ | |
| 418 | + flds := this.class.staticdata; | |
| 419 | + for ( i := len flds - 1; i >= 0; i-- ) | |
| 420 | + if ( (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) | |
| 421 | + objs = makeField(this, flds[i], i) :: objs; | |
| 422 | + return objs; | |
| 423 | +} | |
| 424 | + | |
| 425 | +# | |
| 426 | +# Recursively (for superinterfaces) call getPublicStaticFields() | |
| 427 | +# on interfaces of this class. | |
| 428 | +# | |
| 429 | + | |
| 430 | +ifacelist: list of JClass; | |
| 431 | + | |
| 432 | +doInterfaces(this : JClass, objs : list of JObject) : list of JObject | |
| 433 | +{ | |
| 434 | + ifaces := this.class.interfaces; | |
| 435 | +outer: for ( i := 0; i < len ifaces; i++ ) { | |
| 436 | + iface := jni->GetClassObject(ifaces[i].class); | |
| 437 | + for ( l := ifacelist; l != nil; l = tl l ) | |
| 438 | + if ( hd l == iface ) | |
| 439 | + continue outer; | |
| 440 | + ifacelist = iface :: ifacelist; | |
| 441 | + objs = getPublicStaticFields(iface, objs); | |
| 442 | + objs = doInterfaces(iface, objs); | |
| 443 | + } | |
| 444 | + return objs; | |
| 445 | +} | |
| 446 | + | |
| 447 | +# | |
| 448 | +# A helper function that gets fields for the class represented | |
| 449 | +# by this. p0 == 0 => PUBLIC fields, p0 == 1 => DECLARED fields. | |
| 450 | +# Candidate fields are found in the loader array staticdata (for | |
| 451 | +# static fields) and list objectdata (for instance fields). | |
| 452 | +# | |
| 453 | + | |
| 454 | +getFields(this : JClass, p0 : int) : list of JObject | |
| 455 | +{ | |
| 456 | + objs : list of JObject; | |
| 457 | + | |
| 458 | + # get instance fields | |
| 459 | + objdata := this.class.objectdata; | |
| 460 | + flds := array[len objdata] of ref jldr->Field; | |
| 461 | + super : list of ref jldr->Field = nil; | |
| 462 | + if ( (superclass := jni->GetSuperclass(this.class)) != nil ) | |
| 463 | + super = superclass.objectdata; | |
| 464 | + for ( i := 0; objdata != nil; i++ ) { | |
| 465 | + if ( p0 == 1 && objdata == super ) | |
| 466 | + break; | |
| 467 | + flds[i] = hd objdata; | |
| 468 | + objdata = tl objdata; | |
| 469 | + } | |
| 470 | + # need to associate declaring class with each instance field ??? | |
| 471 | + for ( i--; i >= 0; i-- ) | |
| 472 | + if ( p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) | |
| 473 | + objs = makeField(this, flds[i], i) :: objs; | |
| 474 | + | |
| 475 | + # get class fields of this class | |
| 476 | + flds = this.class.staticdata; | |
| 477 | + for ( i = len flds - 1; i >= 0; i-- ) | |
| 478 | + if ( p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) | |
| 479 | + objs = makeField(this, flds[i], i) :: objs; | |
| 480 | + | |
| 481 | + # get class fields of super classes and interfaces | |
| 482 | + if ( p0 == 0 ) { | |
| 483 | + ifacelist = nil; | |
| 484 | + objs = doInterfaces(this, objs); | |
| 485 | + curclass := this; | |
| 486 | + while ( ( curclass = getSuperclass_rClass(curclass) ) != nil ) { | |
| 487 | + objs = getPublicStaticFields(curclass, objs); | |
| 488 | + objs = doInterfaces(curclass, objs); | |
| 489 | + } | |
| 490 | + } | |
| 491 | + | |
| 492 | + return objs; | |
| 493 | +} | |
| 494 | +# | |
| 495 | +# A helper function that gets methods for the class represented | |
| 496 | +# by this. p0 == 0 => PUBLIC methods, p0 == 1 => DECLARED methods. | |
| 497 | +# Candidate methods are found in the loader arrays staticmethods (for | |
| 498 | +# class methods), privatemethods (for methods private to this | |
| 499 | +# particular class), and virtualmethods (public instance methods of | |
| 500 | +# this class and all its superclasses). | |
| 501 | +# | |
| 502 | +getMethods(this : JClass, p0 : int) : list of JObject | |
| 503 | +{ | |
| 504 | + objs : list of JObject; | |
| 505 | + | |
| 506 | + getReflect(); | |
| 507 | + | |
| 508 | + flds := this.class.staticmethods; | |
| 509 | + for ( i := 0; i < len flds; i++ ) | |
| 510 | + if ( p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) | |
| 511 | + objs = makeAMethod(this, flds[i], i) :: objs; | |
| 512 | + | |
| 513 | + if ( p0 != 0 ) { | |
| 514 | + flds = this.class.privatemethods; | |
| 515 | + for ( i = len flds - 1; i >= 0; i-- ) | |
| 516 | + objs = makeAMethod(this, flds[i], i) :: objs; | |
| 517 | + } | |
| 518 | + | |
| 519 | + vflds := this.class.virtualmethods; | |
| 520 | + for ( i = len vflds - 1; i >= 0; i-- ) | |
| 521 | + if ( (p0 == 1 && vflds[i].class == this.class) # declared, this class | |
| 522 | + || ( p0 == 0 && (vflds[i].field.flags & JNI->ACC_PUBLIC) != 0 ) ) { | |
| 523 | + if ( vflds[i].class != this.class ) | |
| 524 | + this = jni->GetClassObject(vflds[i].class); | |
| 525 | + objs = makeAMethod(this, vflds[i].field, i) :: objs; | |
| 526 | + } | |
| 527 | + | |
| 528 | + return objs; | |
| 529 | +} | |
| 530 | +# | |
| 531 | +# A helper function that gets constructors for the class represented | |
| 532 | +# by this. p0 == 0 => PUBLIC constructors, p0 == 1 => DECLARED | |
| 533 | +# constructors. Candidate constructors are found in the loader | |
| 534 | +# array initmethods. | |
| 535 | +# | |
| 536 | +getConstructors(this : JClass, p0 : int) : list of JObject | |
| 537 | +{ | |
| 538 | + objs : list of JObject; | |
| 539 | + | |
| 540 | + getReflect(); | |
| 541 | + | |
| 542 | + flds := this.class.initmethods; | |
| 543 | + for ( i := len flds - 1; i >= 0; i-- ) | |
| 544 | + if ( p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) | |
| 545 | + objs = makeAMethod(this, flds[i], i) :: objs; | |
| 546 | + | |
| 547 | + return objs; | |
| 548 | +} | |
| 549 | +# | |
| 550 | +# Make sure Reflect module is loaded. | |
| 551 | +# | |
| 552 | +getReflect() | |
| 553 | +{ | |
| 554 | + if ( refl == nil ) { | |
| 555 | + refl = load Reflect Reflect->PATH; | |
| 556 | + if ( refl == nil ) | |
| 557 | + jni->InitError( jni->sys->sprint( "java.lang.Class: could not load %s: %r", Reflect->PATH ) ); | |
| 558 | + else | |
| 559 | + refl->init(jni); | |
| 560 | + } | |
| 561 | +} | |
| 562 | +# | |
| 563 | +# Construct a Field Object. The field is a member of the class | |
| 564 | +# represented by this, and the loader data for the field is in fld, | |
| 565 | +# which is at offset ix in the appropriate array or list. The 'slot' | |
| 566 | +# elements of a Field_obj adt is used only by native methods, and has | |
| 567 | +# the fields modifier flags in the low-order 16 bits, and the index | |
| 568 | +# into the array/list in the upper 16 bits. (The index into what | |
| 569 | +# depends on the modifier flags.) | |
| 570 | +# | |
| 571 | +makeField(this : JClass, fld : ref jldr->Field, ix : int) : JObject | |
| 572 | +{ | |
| 573 | + getReflect(); | |
| 574 | + fldobj := jni->AllocObject(jni->FindClass("java/lang/reflect/Field")); | |
| 575 | + | |
| 576 | + clazz := ref Value.TObject(cast->FromJClass(this)); | |
| 577 | + jni->SetObjField(fldobj, "clazz", clazz); | |
| 578 | + | |
| 579 | + name := ref Value.TObject(cast->FromJString(jni->NewString(fld.field))); | |
| 580 | + jni->SetObjField(fldobj, "name", name); | |
| 581 | + | |
| 582 | + class : ref Value; | |
| 583 | + if ( (typ := refl->SigToType(fld.signature)) > 0 ) | |
| 584 | + class = refl->GetPrimitiveClass(typ); | |
| 585 | + else { | |
| 586 | + classname := fld.signature[1:len fld.signature - 1]; | |
| 587 | + class = ref Value.TObject(cast->FromJClass( | |
| 588 | + jni->GetClassObject(jni->FindClass(classname)))); | |
| 589 | + } | |
| 590 | + jni->SetObjField(fldobj, "type", class); | |
| 591 | + | |
| 592 | + slot := ref Value.TInt((fld.flags & 16rffff) | (ix << 16)); | |
| 593 | + jni->SetObjField(fldobj, "slot", slot); | |
| 594 | + | |
| 595 | + return fldobj; | |
| 596 | +} | |
| 597 | +# | |
| 598 | +# Make a new Method/Constructor object for a method or constructor in | |
| 599 | +# the class this. The loader information for the method/constructor is | |
| 600 | +# found in the loader Field adt fld, which is at offset ix in its | |
| 601 | +# array or list. The signature for the arguments is converted into | |
| 602 | +# a corresponding array of Class objects by makeParamClassArray, then | |
| 603 | +# makeMethod is called to generate the new object. | |
| 604 | +# | |
| 605 | +makeAMethod(this: JClass, fld : ref jldr->Field, ix : int) : JObject | |
| 606 | +{ | |
| 607 | + (sig, retsig) := jni->str->splitr(fld.signature, ")"); | |
| 608 | + objectarray := makeParamClassArray(sig); | |
| 609 | + | |
| 610 | + classarray := cast->JArrayToClass(cast->ObjectToJArray(objectarray)); | |
| 611 | + return makeMethod(this, fld, ix, classarray, retsig); | |
| 612 | +} | |
| 613 | +# | |
| 614 | +# Construct a Method Object. Also used to make Constructor Objects, | |
| 615 | +# share several elements with Methods. The two can be distinguished | |
| 616 | +# because constructors have the name "<init>" (however, Constructor | |
| 617 | +# Objects do not have a 'name' field, nor do they have a 'returnType' | |
| 618 | +# field. The 'slot' field, which is only used by native methods, | |
| 619 | +# is filled with modifier flags in the lower 16 bits and an index (ix) | |
| 620 | +# into an appropriate loader array/list in the upper 16 bits (which | |
| 621 | +# array can be determined by the modifier flags. ). The arguments | |
| 622 | +# types required by the method are specified by the cl array of | |
| 623 | +# Class ofjects. The return value, if any, is specified by the | |
| 624 | +# signature given in retsig. | |
| 625 | +# | |
| 626 | +makeMethod(this: JClass, fld : ref jldr->Field, ix : int, cl : JArrayJClass, | |
| 627 | + retsig : string) : JObject | |
| 628 | +{ | |
| 629 | + mcl : ClassData; | |
| 630 | + isConstructor := 0; | |
| 631 | + if ( fld.field == "<init>" ) | |
| 632 | + isConstructor = 1; | |
| 633 | + if ( isConstructor ) | |
| 634 | + mcl = jni->FindClass("java/lang/reflect/Constructor"); | |
| 635 | + else | |
| 636 | + mcl = jni->FindClass("java/lang/reflect/Method"); | |
| 637 | + methobj := jni->AllocObject(mcl); | |
| 638 | + | |
| 639 | + clazz := ref Value.TObject(cast->FromJClass(this)); | |
| 640 | + jni->SetObjField(methobj, "clazz", clazz); | |
| 641 | + | |
| 642 | + if ( ! isConstructor ) { | |
| 643 | + name := ref Value.TObject(cast->FromJString(jni->NewString(fld.field))); | |
| 644 | + jni->SetObjField(methobj, "name", name); | |
| 645 | + } | |
| 646 | + | |
| 647 | + slot := ref Value.TInt((fld.flags & 16rffff) | (ix << 16)); | |
| 648 | + jni->SetObjField(methobj, "slot", slot); | |
| 649 | + | |
| 650 | + if ( ! isConstructor ) { | |
| 651 | + getReflect(); | |
| 652 | + ret : ref Value; | |
| 653 | + if ( (typ := refl->SigToType(retsig)) > 0 ) | |
| 654 | + ret = refl->GetPrimitiveClass(typ); | |
| 655 | + else { | |
| 656 | + rclass: JClass; | |
| 657 | + case retsig[0] { | |
| 658 | + 'L' => | |
| 659 | + rcdata := jni->FindClass(retsig[1:len retsig -1]); | |
| 660 | + rclass = jni->GetClassObject(rcdata); | |
| 661 | + '[' => | |
| 662 | + rclass = jni->LookupArrayClass(retsig); | |
| 663 | + 'V' => | |
| 664 | + rcdata := jni->FindClass("inferno/vm/void_p"); | |
| 665 | + rclass = jni->GetClassObject(rcdata); | |
| 666 | + } | |
| 667 | + ret = ref Value.TObject(cast->FromJClass(rclass)); | |
| 668 | + } | |
| 669 | + jni->SetObjField(methobj, "returnType", ret); | |
| 670 | + } | |
| 671 | + | |
| 672 | + args := ref Value.TObject(cast->FromJArray(cast->ClassToJArray(cl))); | |
| 673 | + jni->SetObjField(methobj, "parameterTypes", args); | |
| 674 | + | |
| 675 | + # Don't know how to get the list of exceptions thrown. | |
| 676 | + # jni->SetObjField(methobj, "exceptionTypes", excs); | |
| 677 | + # Set to a sensible default for now. | |
| 678 | + foo := cast->JArrayToClass(cast->ObjectToJArray(makeParamClassArray("()"))); | |
| 679 | + excs := ref Value.TObject(cast->FromJArray(cast->ClassToJArray(foo))); | |
| 680 | + jni->SetObjField(methobj, "exceptionTypes", excs); | |
| 681 | + return methobj; | |
| 682 | +} | |
| 683 | +# | |
| 684 | +# Turn a signature into an array of Class Objects. | |
| 685 | +# | |
| 686 | +makeParamClassArray(sig : string) : JArrayJObject | |
| 687 | +{ | |
| 688 | + if ( sig[0] != '(' || sig[len sig -1] != ')' ) | |
| 689 | + return nil; | |
| 690 | + clist := makeParamClass(sig[1:len sig -1]); | |
| 691 | + jajcl := array[len clist] of JObject; | |
| 692 | + for ( i := 0; i < len jajcl; i++ ) { | |
| 693 | + jajcl[i] = hd clist; | |
| 694 | + clist = tl clist; | |
| 695 | + } | |
| 696 | + paramclassarray := jni->MkAObject(jajcl); | |
| 697 | + paramclassarray.class = jni->FindClass("java/lang/Class"); | |
| 698 | + return paramclassarray; | |
| 699 | +} | |
| 700 | +# | |
| 701 | +# Recursively turn a signature into a list of JClass | |
| 702 | +# | |
| 703 | +makeParamClass(sig : string) : list of JObject | |
| 704 | +{ | |
| 705 | + if ( sig == "" ) | |
| 706 | + return nil; | |
| 707 | + | |
| 708 | + (first, rest) := splitSignature(sig); | |
| 709 | + jobj: JObject; | |
| 710 | + case first[0] { | |
| 711 | + 'L' => | |
| 712 | + first = first[1:len first - 1]; | |
| 713 | + newcl := jni->GetClassObject(jni->FindClass(first)); | |
| 714 | + jobj = cast->FromJClass(newcl); | |
| 715 | + '[' => | |
| 716 | + newcl := jni->LookupArrayClass(first); | |
| 717 | + jobj = cast->FromJClass(newcl); | |
| 718 | + 'Z' or 'B' or 'S' or 'C' or 'I' or 'J' or 'F' or 'D' => | |
| 719 | + typ := refl->SigToType(first); | |
| 720 | + jobj = refl->GetPrimitiveClass(typ).Object(); | |
| 721 | + * => | |
| 722 | + return nil; | |
| 723 | + } | |
| 724 | + | |
| 725 | + return jobj :: makeParamClass(rest); | |
| 726 | +} | |
| 727 | +# | |
| 728 | +# Convert an array of JClass to the corresponding signature string. | |
| 729 | +# | |
| 730 | +MakeSignature(jcl : JArrayJClass) : string | |
| 731 | +{ | |
| 732 | + clarray: array of JClass; | |
| 733 | + if ( jcl != nil ) | |
| 734 | + clarray = jcl.ary; | |
| 735 | + sig := ""; | |
| 736 | + for ( i := 0; i < len clarray; i++) | |
| 737 | + sig += MakeSingleSignature(clarray[i]); | |
| 738 | + return sig; | |
| 739 | +} | |
| 740 | +# | |
| 741 | +# Convert a Jclass to the corresponding signature. | |
| 742 | +# | |
| 743 | +MakeSingleSignature(this : JClass) : string | |
| 744 | +{ | |
| 745 | + if ( (typ := jni->PrimitiveIndex(this, 1)) > 0 ) { | |
| 746 | + getReflect(); | |
| 747 | + return refl->TypeToSig(typ); | |
| 748 | + } | |
| 749 | + | |
| 750 | + if ( this.aryname != nil ) | |
| 751 | + return this.aryname; | |
| 752 | + | |
| 753 | + # | |
| 754 | + # Must be a class type | |
| 755 | + # | |
| 756 | + return "L" + this.class.name + ";"; | |
| 757 | +} | |
| 758 | +# | |
| 759 | +# Break a signature into an initial type plus the remainder. | |
| 760 | +# | |
| 761 | +splitSignature(sig : string) : (string, string) | |
| 762 | +{ | |
| 763 | + case sig[0] { | |
| 764 | + 'L' => | |
| 765 | + for ( i := 1; sig[i] != ';'; i++ ) ; | |
| 766 | + i++; | |
| 767 | + return (sig[0:i], sig[i:]); | |
| 768 | + | |
| 769 | + '[' => # recurse to get element type | |
| 770 | + (first, rest) := splitSignature(sig[1:]); | |
| 771 | + return ("[" + first, rest); | |
| 772 | + | |
| 773 | + 'Z' or 'B' or 'S' or 'C' or 'I' or 'J' or 'F' or 'D' => | |
| 774 | + return (sig[0:1], sig[1:]); | |
| 775 | + } | |
| 776 | + return (nil, nil); | |
| 777 | +} | |
| 778 | + | |
| @@ -0,0 +1,30 @@ | ||
| 1 | +# javal v1.2 generated file: edit with care | |
| 2 | + | |
| 3 | +Class_L : module | |
| 4 | +{ | |
| 5 | + | |
| 6 | + init : fn( jni_p : JNI ); | |
| 7 | + forName_rString_rClass : fn( p0 : JString) : JClass; | |
| 8 | + newInstance_rObject : fn( this : JClass) : JObject; | |
| 9 | + isInstance_rObject_Z : fn( this : JClass, p0 : JObject) : int; | |
| 10 | + isAssignableFrom_rClass_Z : fn( this : JClass, p0 : JClass) : int; | |
| 11 | + isInterface_Z : fn( this : JClass) : int; | |
| 12 | + isArray_Z : fn( this : JClass) : int; | |
| 13 | + isPrimitive_Z : fn( this : JClass) : int; | |
| 14 | + getName_rString : fn( this : JClass) : JString; | |
| 15 | + getClassLoader_rClassLoader : fn( this : JClass) : JObject; | |
| 16 | + getSuperclass_rClass : fn( this : JClass) : JClass; | |
| 17 | + getInterfaces_aClass : fn( this : JClass) : JArrayJClass; | |
| 18 | + getComponentType_rClass : fn( this : JClass) : JClass; | |
| 19 | + getModifiers_I : fn( this : JClass) : int; | |
| 20 | + getSigners_aObject : fn( this : JClass) : JArrayJObject; | |
| 21 | + setSigners_aObject_V : fn( this : JClass, p0 : JArrayJObject); | |
| 22 | + getPrimitiveClass_rString_rClass : fn( p0 : JString) : JClass; | |
| 23 | + getFields0_I_aField : fn( this : JClass, p0 : int) : JArrayJObject; | |
| 24 | + getMethods0_I_aMethod : fn( this : JClass, p0 : int) : JArrayJObject; | |
| 25 | + getConstructors0_I_aConstructor : fn( this : JClass, p0 : int) : JArrayJObject; | |
| 26 | + getField0_rString_I_rField : fn( this : JClass, p0 : JString,p1 : int) : JObject; | |
| 27 | + getMethod0_rString_aClass_I_rMethod : fn( this : JClass, p0 : JString,p1 : JArrayJClass,p2 : int) : JObject; | |
| 28 | + getConstructor0_aClass_I_rConstructor : fn( this : JClass, p0 : JArrayJClass,p1 : int) : JObject; | |
| 29 | + | |
| 30 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,66 @@ | ||
| 1 | +implement Double_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +#<< | |
| 28 | + | |
| 29 | +include "Double_L.m"; | |
| 30 | + | |
| 31 | +#>> extra post includes here | |
| 32 | +math : Math; | |
| 33 | +#<< | |
| 34 | + | |
| 35 | +init( jni_p : JNI ) | |
| 36 | +{ | |
| 37 | + # save java native inteface mod instance | |
| 38 | + jni = jni_p; | |
| 39 | + #>>extra initialization here | |
| 40 | + math = jni->math; | |
| 41 | + #<< | |
| 42 | +} | |
| 43 | + | |
| 44 | +doubleToLongBits_D_J( p0 : real) : big | |
| 45 | +{#>> | |
| 46 | + return( math->realbits64(p0) ); | |
| 47 | +}#<< | |
| 48 | + | |
| 49 | +longBitsToDouble_J_D( p0 : big) : real | |
| 50 | +{#>> | |
| 51 | + return( math->bits64real( p0 ) ); | |
| 52 | +}#<< | |
| 53 | + | |
| 54 | +valueOf0_rString_D( p0 : JString) : real | |
| 55 | +{#>> | |
| 56 | + return( real p0.str ); | |
| 57 | +}#<< | |
| 58 | + | |
| 59 | +mkstring_D_rString( p0 : real) : JString | |
| 60 | +{#>> | |
| 61 | + s := string p0; | |
| 62 | + if(p0 == 0.0) | |
| 63 | + s += ".0"; | |
| 64 | + return( jni->NewString( s ) ); | |
| 65 | +}#<< | |
| 66 | + | |
| @@ -0,0 +1,17 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +Double_L : module | |
| 4 | +{ | |
| 5 | + Double_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + value : real; | |
| 9 | + }; | |
| 10 | + | |
| 11 | + init : fn( jni_p : JNI ); | |
| 12 | + doubleToLongBits_D_J : fn( p0 : real) : big; | |
| 13 | + longBitsToDouble_J_D : fn( p0 : big) : real; | |
| 14 | + valueOf0_rString_D : fn( p0 : JString) : real; | |
| 15 | + mkstring_D_rString : fn( p0 : real) : JString; | |
| 16 | + | |
| 17 | +}; | |
Empty file added.
Empty file added.
| @@ -0,0 +1,73 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)ExceptionInInitializerError.java 1.2 97/01/20 | |
| 3 | + * | |
| 4 | + * Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 5 | + * | |
| 6 | + * Permission to use, copy, modify, and distribute this software | |
| 7 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 8 | + * fee is hereby granted provided that this copyright notice | |
| 9 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 10 | + * for further important copyright and licensing information. | |
| 11 | + * | |
| 12 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 13 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 14 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 15 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 16 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 17 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 18 | + */ | |
| 19 | + | |
| 20 | +package java.lang; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * Signals that an unexpected exception has occurred in a static initializer. | |
| 24 | + * | |
| 25 | + * @author Frank Yellin | |
| 26 | + * @version 1.2, 01/20/97 | |
| 27 | + * | |
| 28 | + * @since JDK1.1 | |
| 29 | + */ | |
| 30 | +public | |
| 31 | +class ExceptionInInitializerError extends LinkageError { | |
| 32 | + private Throwable exception; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * Constructs an ExceptionInInitializerError with no detail message. | |
| 36 | + * A detail message is a String that describes this particular exception. | |
| 37 | + * | |
| 38 | + * @since JDK1.1 | |
| 39 | + */ | |
| 40 | + public ExceptionInInitializerError() { | |
| 41 | + super(); | |
| 42 | + } | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * Constructs a new ExceptionInInitializerError class initialized to | |
| 46 | + * the specific throwable | |
| 47 | + * | |
| 48 | + * @param thrown The exception thrown | |
| 49 | + * @since JDK1.1 | |
| 50 | + */ | |
| 51 | + public ExceptionInInitializerError(Throwable thrown) { | |
| 52 | + this.exception = thrown; | |
| 53 | + } | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * Constructs a ExceptionInInitializerError with the specified detail message. | |
| 57 | + * A detail message is a String that describes this particular exception. | |
| 58 | + * | |
| 59 | + * @param s the detail message | |
| 60 | + * @since JDK1.1 | |
| 61 | + */ | |
| 62 | + public ExceptionInInitializerError(String s) { | |
| 63 | + super(s); | |
| 64 | + } | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Returns the exception that occurred during a static initialization that | |
| 68 | + * caused this Error to be created. | |
| 69 | + */ | |
| 70 | + public Throwable getException() { | |
| 71 | + return exception; | |
| 72 | + } | |
| 73 | +} | |
Empty file added.
| @@ -0,0 +1,60 @@ | ||
| 1 | +implement Float_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +#<< | |
| 28 | + | |
| 29 | +include "Float_L.m"; | |
| 30 | + | |
| 31 | +#>> extra post includes here | |
| 32 | +math : Math; | |
| 33 | +#<< | |
| 34 | + | |
| 35 | +init( jni_p : JNI ) | |
| 36 | +{ | |
| 37 | + # save java native inteface mod instance | |
| 38 | + jni = jni_p; | |
| 39 | + #>>extra initialization here | |
| 40 | + math = jni->math; | |
| 41 | + #<< | |
| 42 | +} | |
| 43 | + | |
| 44 | +floatToIntBits_F_I( p0 : real) : int | |
| 45 | +{#>> | |
| 46 | + return( math->realbits32(p0) ); | |
| 47 | +}#<< | |
| 48 | + | |
| 49 | +intBitsToFloat_I_F( p0 : int) : real | |
| 50 | +{#>> | |
| 51 | + return( math->bits32real(p0) ); | |
| 52 | +}#<< | |
| 53 | + | |
| 54 | +mkstring_F_rString( p0 : real) : JString | |
| 55 | +{#>> | |
| 56 | + s := string p0; | |
| 57 | + if(p0 == 0.0) | |
| 58 | + s += ".0"; | |
| 59 | + return( jni->NewString( s ) ); | |
| 60 | +}#<< | |
| @@ -0,0 +1,16 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +Float_L : module | |
| 4 | +{ | |
| 5 | + Float_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + value : real; | |
| 9 | + }; | |
| 10 | + | |
| 11 | + init : fn( jni_p : JNI ); | |
| 12 | + floatToIntBits_F_I : fn( p0 : real) : int; | |
| 13 | + intBitsToFloat_I_F : fn( p0 : int) : real; | |
| 14 | + mkstring_F_rString : fn( p0 : real) : JString; | |
| 15 | + | |
| 16 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,207 @@ | ||
| 1 | +implement InfernoProcess_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +include "java/io/FileDescriptor_L.m"; | |
| 28 | + FileDescriptor_obj : import FileDescriptor_L; | |
| 29 | + | |
| 30 | +#<< | |
| 31 | + | |
| 32 | +include "InfernoProcess_L.m"; | |
| 33 | + | |
| 34 | +#>> extra post includes here | |
| 35 | + | |
| 36 | +include "sh.m"; | |
| 37 | + | |
| 38 | +ioexception := ""; | |
| 39 | + | |
| 40 | +#<< | |
| 41 | + | |
| 42 | +init( jni_p : JNI ) | |
| 43 | +{ | |
| 44 | + # save java native inteface mod instance | |
| 45 | + jni = jni_p; | |
| 46 | + #>>extra initialization here | |
| 47 | + #<< | |
| 48 | +} | |
| 49 | + | |
| 50 | +initProc_aString_aString_V( this : ref InfernoProcess_obj, p0 : JArrayJString,p1 : JArrayJString) | |
| 51 | +{#>> | |
| 52 | + # | |
| 53 | + # p0 : command and arguments | |
| 54 | + # p1 : environment in for var=value; does not apply in Inferno | |
| 55 | + # | |
| 56 | + dummy := this; | |
| 57 | + jstrs := p0.ary; | |
| 58 | + args : list of string; | |
| 59 | + l := len jstrs; | |
| 60 | + for ( i := l-1; i >= 0; i--) | |
| 61 | + args = jstrs[i].str :: args; | |
| 62 | + | |
| 63 | + sync := chan of int; | |
| 64 | + spawn exec(this, args, sync); | |
| 65 | + pid := <- sync; | |
| 66 | + if ( pid == 0 ) | |
| 67 | + jni->ThrowException("java.io.IOException", ioexception); | |
| 68 | +}#<< | |
| 69 | + | |
| 70 | +waitFor_I( this : ref InfernoProcess_obj) : int | |
| 71 | +{#>> | |
| 72 | + if ( this.waitfd.fd == nil ) | |
| 73 | + this.terminated = JNI->TRUE; | |
| 74 | + while ( this.terminated == JNI->FALSE ) { | |
| 75 | + (ok, nil) := jni->sys->fstat(this.waitfd.fd); | |
| 76 | + if ( ok < 0 ) | |
| 77 | + this.terminated = JNI->TRUE; | |
| 78 | + else | |
| 79 | + jni->sys->sleep(1000); | |
| 80 | + } | |
| 81 | + this.waitfd.fd = nil; | |
| 82 | + return 0; | |
| 83 | +}#<< | |
| 84 | + | |
| 85 | +destroy_V( this : ref InfernoProcess_obj) | |
| 86 | +{#>> | |
| 87 | + if ( this.pid == 0 || isTerminated_Z(this) == JNI->TRUE ) | |
| 88 | + return; | |
| 89 | + | |
| 90 | + fd := jni->sys->open("/prog/"+string this.pid+"/ctl", jni->sys->OWRITE); | |
| 91 | + if ( fd != nil ) | |
| 92 | + jni->sys->fprint(fd, "killgrp"); | |
| 93 | + this.pid = 0; | |
| 94 | + this.terminated = JNI->TRUE; | |
| 95 | +}#<< | |
| 96 | + | |
| 97 | +isTerminated_Z( this : ref InfernoProcess_obj) : int | |
| 98 | +{#>> | |
| 99 | + # If the file descriptor being used to wait for the process to terminate | |
| 100 | + # is still good, the process hasn't terminated yet. | |
| 101 | + # | |
| 102 | + if ( this.waitfd.fd == nil ) | |
| 103 | + return this.terminated = JNI->TRUE; | |
| 104 | + (ok, nil) := jni->sys->fstat(this.waitfd.fd); | |
| 105 | + if ( ok < 0 ) | |
| 106 | + this.terminated = JNI->TRUE; | |
| 107 | + return this.terminated; | |
| 108 | +}#<< | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | +exec(this : ref InfernoProcess_obj, args : list of string, | |
| 113 | + waitpid : chan of int) | |
| 114 | +{ | |
| 115 | + # find and load module corresponding to hd args. | |
| 116 | + cmd := hd args; | |
| 117 | + file := cmd; | |
| 118 | + if ( len file < 4 || file[len file - 4:] != ".dis" ) | |
| 119 | + file += ".dis"; | |
| 120 | + | |
| 121 | + c := load Command file; | |
| 122 | + if ( c == nil ) { | |
| 123 | + err := jni->sys->sprint("%r"); | |
| 124 | + if ( err == "file does not exist" && file[0] != '/' && | |
| 125 | + file[0:2] != "./" ) { | |
| 126 | + c = load Command "/dis/" + file; | |
| 127 | + if ( c == nil ) | |
| 128 | + err = jni->sys->sprint("%r"); | |
| 129 | + } | |
| 130 | + if ( c == nil ) { | |
| 131 | + ioexception = jni->sys->sprint("%s: %r", cmd); | |
| 132 | + waitpid <- = 0; | |
| 133 | + return; | |
| 134 | + } | |
| 135 | + } | |
| 136 | + # | |
| 137 | + # Get pid (via pctl) and save; We save the pid of the PARENT of the | |
| 138 | + # thread that will actually execute the command. Then if someone | |
| 139 | + # calls destroy, the whole group is killed. | |
| 140 | + # | |
| 141 | + this.pid = jni->sys->pctl(Sys->FORKNS | Sys->NEWPGRP, nil); | |
| 142 | + # | |
| 143 | + # Note: have to open the /prog/n/wait file of parent before doing the spawn. | |
| 144 | + # | |
| 145 | + waitfd : ref Sys->FD;; | |
| 146 | + if ( this.pid > 0 ) | |
| 147 | + waitfd = jni->sys->open("#p/" + string this.pid + "/wait", Sys->OREAD); | |
| 148 | + this.waitfd.fd = waitfd; | |
| 149 | + | |
| 150 | + # arrange for new input/output to the command. Save in stdin & stdout. | |
| 151 | + si := array[2] of ref Sys->FD; | |
| 152 | + so := array[2] of ref Sys->FD; | |
| 153 | + se := array[2] of ref Sys->FD; | |
| 154 | + if ( jni->sys->pipe(si) < 0 ) { | |
| 155 | + ioexception = "pipe failure"; | |
| 156 | + waitpid <- = 0; | |
| 157 | + return; | |
| 158 | + } | |
| 159 | + if ( jni->sys->pipe(so) < 0 ) { | |
| 160 | + ioexception = "pipe failure"; | |
| 161 | + waitpid <- = 0; | |
| 162 | + return; | |
| 163 | + } | |
| 164 | + if ( jni->sys->pipe(se) < 0 ) { | |
| 165 | + ioexception = "pipe failure"; | |
| 166 | + waitpid <- = 0; | |
| 167 | + return; | |
| 168 | + } | |
| 169 | + this.stdin.fd = si[1]; | |
| 170 | + this.stdout.fd = so[0]; | |
| 171 | + this.stderr.fd = se[0]; | |
| 172 | + spawn exec1(c, si[0], so[1], se[1], args, waitpid); | |
| 173 | + si[0] = si[1] = so[0] = so[1] = se[0] = se[1] = nil; | |
| 174 | + # | |
| 175 | + # We can't just exit this thread, or we could never detect completion | |
| 176 | + # of the child. So we wait here for the wait notification. | |
| 177 | + # Note that we nil the 'this' reference, so that it will be | |
| 178 | + # possible for it to be garbage collected when not referenced elsewhere. | |
| 179 | + # That means we can't set the terminated flag, so that anyone who | |
| 180 | + # really needs to know whether the process has terminated has to check | |
| 181 | + # to see if this.waitfd.fd is still a valid FD. | |
| 182 | + # | |
| 183 | + this = nil; | |
| 184 | + buf := array[64] of byte; | |
| 185 | + if ( waitfd != nil && jni->sys->read(waitfd, buf, len buf) < 0 ) | |
| 186 | + jni->sys->print("read error on wait file: %r\n") | |
| 187 | + ; # even if this is an error, how do we report it? | |
| 188 | +} | |
| 189 | + | |
| 190 | +exec1(cmd : Command, in, out, err : ref Sys->FD, args : list of string, | |
| 191 | + c : chan of int) | |
| 192 | +{ | |
| 193 | + newfds := in.fd :: out.fd :: err.fd :: nil; | |
| 194 | + pid := jni->sys->pctl(Sys->NEWFD, newfds); | |
| 195 | + jni->sys->dup(in.fd, 0); | |
| 196 | + jni->sys->dup(out.fd, 1); | |
| 197 | + jni->sys->dup(err.fd, 2); | |
| 198 | + in = out = err = nil; | |
| 199 | + pid = jni->sys->pctl(Sys->NEWFD, 0 :: 1 :: 2 :: nil); | |
| 200 | + # | |
| 201 | + # Eventually there has to be a way to get the Draw->Context. | |
| 202 | + # | |
| 203 | + # ctxt := jni->GetContext(); | |
| 204 | + c <- = pid; | |
| 205 | + cmd->init(nil, args); | |
| 206 | +} | |
| 207 | + | |
| @@ -0,0 +1,22 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +InfernoProcess_L : module | |
| 4 | +{ | |
| 5 | + InfernoProcess_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + stdin : ref FileDescriptor_obj; | |
| 9 | + stdout : ref FileDescriptor_obj; | |
| 10 | + stderr : ref FileDescriptor_obj; | |
| 11 | + pid : int; | |
| 12 | + waitfd : ref FileDescriptor_obj; | |
| 13 | + terminated : int; | |
| 14 | + }; | |
| 15 | + | |
| 16 | + init : fn( jni_p : JNI ); | |
| 17 | + initProc_aString_aString_V : fn( this : ref InfernoProcess_obj, p0 : JArrayJString,p1 : JArrayJString); | |
| 18 | + waitFor_I : fn( this : ref InfernoProcess_obj) : int; | |
| 19 | + destroy_V : fn( this : ref InfernoProcess_obj); | |
| 20 | + isTerminated_Z : fn( this : ref InfernoProcess_obj) : int; | |
| 21 | + | |
| 22 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,119 @@ | ||
| 1 | +implement Math_L; | |
| 2 | + | |
| 3 | +# javal v1.2 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JObject : import jni; | |
| 23 | + | |
| 24 | +#>> extra pre includes here | |
| 25 | + | |
| 26 | +#<< | |
| 27 | + | |
| 28 | +include "Math_L.m"; | |
| 29 | + | |
| 30 | +#>> extra post includes here | |
| 31 | +math : Math; | |
| 32 | +#<< | |
| 33 | + | |
| 34 | +init( jni_p : JNI ) | |
| 35 | +{ | |
| 36 | + # save java native inteface mod instance | |
| 37 | + jni = jni_p; | |
| 38 | + #>>extra initialization here | |
| 39 | + math = jni->math; | |
| 40 | + #<< | |
| 41 | +} | |
| 42 | + | |
| 43 | +sin_D_D( p0 : real) : real | |
| 44 | +{#>> | |
| 45 | + return( math->sin(p0) ); | |
| 46 | +}#<< | |
| 47 | + | |
| 48 | +cos_D_D( p0 : real) : real | |
| 49 | +{#>> | |
| 50 | + return( math->cos(p0) ); | |
| 51 | +}#<< | |
| 52 | + | |
| 53 | +tan_D_D( p0 : real) : real | |
| 54 | +{#>> | |
| 55 | + return( math->tan(p0) ); | |
| 56 | +}#<< | |
| 57 | + | |
| 58 | +asin_D_D( p0 : real) : real | |
| 59 | +{#>> | |
| 60 | + return( math->asin(p0) ); | |
| 61 | +}#<< | |
| 62 | + | |
| 63 | +acos_D_D( p0 : real) : real | |
| 64 | +{#>> | |
| 65 | + return( math->acos(p0) ); | |
| 66 | +}#<< | |
| 67 | + | |
| 68 | +atan_D_D( p0 : real) : real | |
| 69 | +{#>> | |
| 70 | + return( math->atan(p0) ); | |
| 71 | +}#<< | |
| 72 | + | |
| 73 | +exp_D_D( p0 : real) : real | |
| 74 | +{#>> | |
| 75 | + return( math->exp(p0) ); | |
| 76 | +}#<< | |
| 77 | + | |
| 78 | +log_D_D( p0 : real) : real | |
| 79 | +{#>> | |
| 80 | + return( math->log(p0) ); | |
| 81 | +}#<< | |
| 82 | + | |
| 83 | +sqrt_D_D( p0 : real) : real | |
| 84 | +{#>> | |
| 85 | + return( math->sqrt(p0) ); | |
| 86 | +}#<< | |
| 87 | + | |
| 88 | +IEEEremainder_D_D_D( p0 : real,p1 : real) : real | |
| 89 | +{#>> | |
| 90 | + return( math->remainder(p0,p1) ); | |
| 91 | +}#<< | |
| 92 | + | |
| 93 | +ceil_D_D( p0 : real) : real | |
| 94 | +{#>> | |
| 95 | + return( math->ceil(p0) ); | |
| 96 | +}#<< | |
| 97 | + | |
| 98 | +floor_D_D( p0 : real) : real | |
| 99 | +{#>> | |
| 100 | + return( math->floor(p0) ); | |
| 101 | +}#<< | |
| 102 | + | |
| 103 | +rint_D_D( p0 : real) : real | |
| 104 | +{#>> | |
| 105 | + return( math->rint(p0) ); | |
| 106 | +}#<< | |
| 107 | + | |
| 108 | +atan2_D_D_D( p0 : real,p1 : real) : real | |
| 109 | +{#>> | |
| 110 | + return( math->atan2(p0,p1) ); | |
| 111 | +}#<< | |
| 112 | + | |
| 113 | +pow_D_D_D( p0 : real,p1 : real) : real | |
| 114 | +{#>> | |
| 115 | + return( math->pow(p0,p1) ); | |
| 116 | +}#<< | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| @@ -0,0 +1,27 @@ | ||
| 1 | +# javal v1.2 generated file: edit with care | |
| 2 | + | |
| 3 | +Math_L : module | |
| 4 | +{ | |
| 5 | + Math_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + }; | |
| 9 | + | |
| 10 | + init : fn( jni_p : JNI ); | |
| 11 | + sin_D_D : fn( p0 : real) : real; | |
| 12 | + cos_D_D : fn( p0 : real) : real; | |
| 13 | + tan_D_D : fn( p0 : real) : real; | |
| 14 | + asin_D_D : fn( p0 : real) : real; | |
| 15 | + acos_D_D : fn( p0 : real) : real; | |
| 16 | + atan_D_D : fn( p0 : real) : real; | |
| 17 | + exp_D_D : fn( p0 : real) : real; | |
| 18 | + log_D_D : fn( p0 : real) : real; | |
| 19 | + sqrt_D_D : fn( p0 : real) : real; | |
| 20 | + IEEEremainder_D_D_D : fn( p0 : real,p1 : real) : real; | |
| 21 | + ceil_D_D : fn( p0 : real) : real; | |
| 22 | + floor_D_D : fn( p0 : real) : real; | |
| 23 | + rint_D_D : fn( p0 : real) : real; | |
| 24 | + atan2_D_D_D : fn( p0 : real,p1 : real) : real; | |
| 25 | + pow_D_D_D : fn( p0 : real,p1 : real) : real; | |
| 26 | + | |
| 27 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,71 @@ | ||
| 1 | +implement Object_L; | |
| 2 | + | |
| 3 | +include "jni.m"; | |
| 4 | + jni : JNI; | |
| 5 | + ClassModule, | |
| 6 | + JString, | |
| 7 | + JArray, | |
| 8 | + JArrayI, | |
| 9 | + JArrayC, | |
| 10 | + JArrayB, | |
| 11 | + JArrayS, | |
| 12 | + JArrayJ, | |
| 13 | + JArrayF, | |
| 14 | + JArrayD, | |
| 15 | + JArrayZ, | |
| 16 | + JArrayJObject, | |
| 17 | + JArrayJString, | |
| 18 | + JClass, | |
| 19 | + JObject : import jni; | |
| 20 | + | |
| 21 | +#>> extra pre includes here | |
| 22 | + | |
| 23 | +#<< | |
| 24 | + | |
| 25 | +include "Object_L.m"; | |
| 26 | + | |
| 27 | +#>> extra post includes here | |
| 28 | + | |
| 29 | +#<< | |
| 30 | + | |
| 31 | +init( jni_p : JNI ) | |
| 32 | +{ | |
| 33 | + # save java native inteface mod instance | |
| 34 | + jni = jni_p; | |
| 35 | + #>>extra initialization here | |
| 36 | + #<< | |
| 37 | +} | |
| 38 | + | |
| 39 | +getClass_rClass( this : JObject) : JClass | |
| 40 | +{#>> | |
| 41 | + return( jni->GetObjectClass(this) ); | |
| 42 | +}#<< | |
| 43 | + | |
| 44 | +hashCode_I( this : JObject ) : int | |
| 45 | +{#>> | |
| 46 | + return( jni->IdentityHash( this ) ); | |
| 47 | +}#<< | |
| 48 | + | |
| 49 | +clone_rObject( this : JObject ) : JObject | |
| 50 | +{#>> | |
| 51 | + return( jni->DupObject( this ) ); | |
| 52 | +}#<< | |
| 53 | + | |
| 54 | +notify_V( this : JObject ) | |
| 55 | +{#>> | |
| 56 | + jni->jldr->monitornotify( this, 0 ); | |
| 57 | +}#<< | |
| 58 | + | |
| 59 | +notifyAll_V( this : JObject ) | |
| 60 | +{#>> | |
| 61 | + jni->jldr->monitornotify( this, 1 ); | |
| 62 | +}#<< | |
| 63 | + | |
| 64 | +wait_J_V( this : JObject, p0 : big) | |
| 65 | +{#>> | |
| 66 | + if ( p0 < big 0 ) | |
| 67 | + jni->ThrowException( "java.lang.IllegalArgumentException", "negative timeout value" ); | |
| 68 | + # limit to 30 bits of millisecond time. | |
| 69 | + duration := (int p0) & 16r3FFFFFFF; | |
| 70 | + jni->jldr->monitorwait( this, duration ); | |
| 71 | +}#<< | |
| @@ -0,0 +1,14 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +Object_L : module | |
| 4 | +{ | |
| 5 | + init : fn( jni_p : JNI ); | |
| 6 | + getClass_rClass : fn( this : JObject ) : JClass; | |
| 7 | + hashCode_I : fn( this : JObject ) : int; | |
| 8 | + clone_rObject : fn( this : JObject ) : JObject; | |
| 9 | + notify_V : fn( this : JObject ); | |
| 10 | + notifyAll_V : fn( this : JObject ); | |
| 11 | + wait_J_V : fn( this : JObject, p0 : big); | |
| 12 | + registerNatives_V : fn( this : JObject ); | |
| 13 | + | |
| 14 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,161 @@ | ||
| 1 | +implement Runtime_L; | |
| 2 | + | |
| 3 | +# javal v1.2 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JObject : import jni; | |
| 23 | + | |
| 24 | +#>> extra pre includes here | |
| 25 | + | |
| 26 | +#<< | |
| 27 | + | |
| 28 | +include "Runtime_L.m"; | |
| 29 | + | |
| 30 | +#>> extra post includes here | |
| 31 | + | |
| 32 | +#<< | |
| 33 | + | |
| 34 | +init( jni_p : JNI ) | |
| 35 | +{ | |
| 36 | + # save java native inteface mod instance | |
| 37 | + jni = jni_p; | |
| 38 | + #>>extra initialization here | |
| 39 | + #<< | |
| 40 | +} | |
| 41 | + | |
| 42 | +killgrp() | |
| 43 | +{ | |
| 44 | + # kill this process group | |
| 45 | + msg := array of byte "killgrp"; | |
| 46 | + pid := string jni->sys->pctl(0,nil); #my pid | |
| 47 | + | |
| 48 | + fd := jni->sys->open("#p/"+pid+"/ctl", Sys->OWRITE); | |
| 49 | + if(fd != nil) | |
| 50 | + jni->sys->write(fd, msg, len msg); | |
| 51 | + | |
| 52 | + #note: we silently fail if we could not open | |
| 53 | + #'#p' (i.e. because of NODEVS) or if the | |
| 54 | + #write fails | |
| 55 | +} | |
| 56 | + | |
| 57 | +exitInternal_I_V( this : ref Runtime_obj, p0 : int) | |
| 58 | +{#>> | |
| 59 | + # can't kill self, so spawn thread to kill group | |
| 60 | + spawn killgrp(); | |
| 61 | + # send nowhere until killed | |
| 62 | + chan of int <-= 666; | |
| 63 | + junk := (this,p0); #inferno does not have an exit code | |
| 64 | +}#<< | |
| 65 | + | |
| 66 | +runFinalizersOnExit0_Z_V( p0 : int) | |
| 67 | +{#>> | |
| 68 | + junk := (p0); | |
| 69 | +}#<< | |
| 70 | + | |
| 71 | +freeMemory_J( this : ref Runtime_obj) : big | |
| 72 | +{#>> | |
| 73 | + # open; read; parase; memory device | |
| 74 | + mfd := jni->sys->open("#c/memory", Sys->OREAD); | |
| 75 | + if ( mfd == nil ) | |
| 76 | + return(big 0); | |
| 77 | + buf := array[300] of byte; | |
| 78 | + n := jni->sys->read(mfd, buf, len buf); | |
| 79 | + if(n <= 0) | |
| 80 | + return(big 0); | |
| 81 | + (nil, arena) := jni->sys->tokenize(string buf[0:n], "\n"); | |
| 82 | + (used,limit) := (0,0); | |
| 83 | + # walk list of arena's looking for "heap" | |
| 84 | + while(arena != nil) | |
| 85 | + { | |
| 86 | + # break line into tokens | |
| 87 | + (nil,tok) := jni->sys->tokenize( hd arena, " " ); | |
| 88 | + used = int (hd tok); #first tok is amount used | |
| 89 | + tok = tl tok; | |
| 90 | + limit = int (hd tok); #second tok is total | |
| 91 | + name : string; | |
| 92 | + for(tok= tl tok; tok != nil; tok = tl tok) | |
| 93 | + name = hd tok; | |
| 94 | + | |
| 95 | + if ( name == "heap" ) | |
| 96 | + break; | |
| 97 | + arena = tl arena; | |
| 98 | + } | |
| 99 | + | |
| 100 | + # return the amount free | |
| 101 | + return( big (limit-used) ); | |
| 102 | + junk := (this); | |
| 103 | +}#<< | |
| 104 | + | |
| 105 | +totalMemory_J( this : ref Runtime_obj) : big | |
| 106 | +{#>> | |
| 107 | + # open; read; parase; memory device | |
| 108 | + mfd := jni->sys->open("#c/memory", Sys->OREAD); | |
| 109 | + if ( mfd == nil ) | |
| 110 | + return( big 0 ); | |
| 111 | + buf := array[300] of byte; | |
| 112 | + n := jni->sys->read(mfd, buf, len buf); | |
| 113 | + if(n <= 0) | |
| 114 | + return(big 0); | |
| 115 | + (nil, arena) := jni->sys->tokenize(string buf[0:n], "\n"); | |
| 116 | + limit := 0; | |
| 117 | + while(arena != nil) | |
| 118 | + { | |
| 119 | + # break line into tokens | |
| 120 | + (nil,tok) := jni->sys->tokenize( hd arena, " " ); | |
| 121 | + tok = tl tok; | |
| 122 | + limit = int (hd tok); #second tok is total | |
| 123 | + name : string; | |
| 124 | + for(tok= tl tok; tok != nil; tok = tl tok) | |
| 125 | + name = hd tok; | |
| 126 | + | |
| 127 | + if ( name == "heap" ) | |
| 128 | + break; | |
| 129 | + arena = tl arena; | |
| 130 | + } | |
| 131 | + | |
| 132 | + # return the total amount | |
| 133 | + return( big limit ); | |
| 134 | + junk := (this); | |
| 135 | +}#<< | |
| 136 | + | |
| 137 | +gc_V( this : ref Runtime_obj) | |
| 138 | +{#>> | |
| 139 | + # do nothing | |
| 140 | + junk := this; | |
| 141 | +}#<< | |
| 142 | + | |
| 143 | +runFinalization_V( this : ref Runtime_obj) | |
| 144 | +{#>> | |
| 145 | + # do nothing | |
| 146 | + junk := this; | |
| 147 | +}#<< | |
| 148 | + | |
| 149 | +traceInstructions_Z_V( this : ref Runtime_obj, p0 : int) | |
| 150 | +{#>> | |
| 151 | + # do nothing | |
| 152 | + return; | |
| 153 | + junk := (this,p0); | |
| 154 | +}#<< | |
| 155 | + | |
| 156 | +traceMethodCalls_Z_V( this : ref Runtime_obj, p0 : int) | |
| 157 | +{#>> | |
| 158 | + # doing nothing is a valid implementation | |
| 159 | + return; | |
| 160 | + junk := (this,p0); | |
| 161 | +}#<< | |
| @@ -0,0 +1,20 @@ | ||
| 1 | +# javal v1.2 generated file: edit with care | |
| 2 | + | |
| 3 | +Runtime_L : module | |
| 4 | +{ | |
| 5 | + Runtime_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + }; | |
| 9 | + | |
| 10 | + init : fn( jni_p : JNI ); | |
| 11 | + exitInternal_I_V : fn( this : ref Runtime_obj, p0 : int); | |
| 12 | + runFinalizersOnExit0_Z_V : fn( p0 : int); | |
| 13 | + freeMemory_J : fn( this : ref Runtime_obj) : big; | |
| 14 | + totalMemory_J : fn( this : ref Runtime_obj) : big; | |
| 15 | + gc_V : fn( this : ref Runtime_obj); | |
| 16 | + runFinalization_V : fn( this : ref Runtime_obj); | |
| 17 | + traceInstructions_Z_V : fn( this : ref Runtime_obj, p0 : int); | |
| 18 | + traceMethodCalls_Z_V : fn( this : ref Runtime_obj, p0 : int); | |
| 19 | + | |
| 20 | +}; | |
Empty file added.
Empty file added.
| @@ -0,0 +1,175 @@ | ||
| 1 | +implement SecurityManager_L; | |
| 2 | + | |
| 3 | +# javal v1.2 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JObject : import jni; | |
| 23 | + | |
| 24 | +#>> extra pre includes here | |
| 25 | + | |
| 26 | +#<< | |
| 27 | + | |
| 28 | +include "SecurityManager_L.m"; | |
| 29 | + | |
| 30 | +#>> extra post includes here | |
| 31 | + | |
| 32 | +#<< | |
| 33 | + | |
| 34 | +init( jni_p : JNI ) | |
| 35 | +{ | |
| 36 | + # save java native inteface mod instance | |
| 37 | + jni = jni_p; | |
| 38 | + #>>extra initialization here | |
| 39 | + #<< | |
| 40 | +} | |
| 41 | + | |
| 42 | +getClassContext_aClass( this : ref SecurityManager_obj) : JArrayJClass | |
| 43 | +{#>> | |
| 44 | + # | |
| 45 | + # return an array of classes that represent the classes of | |
| 46 | + # each method on the current call stack (presumably ignoring | |
| 47 | + # any native funtions). | |
| 48 | + # | |
| 49 | + jni->FatalError( "getClassContext() not implemented" ); | |
| 50 | + junk := this; | |
| 51 | + return(nil); | |
| 52 | +}#<< | |
| 53 | + | |
| 54 | +currentClassLoader_rClassLoader( this : ref SecurityManager_obj) : JObject | |
| 55 | +{#>> | |
| 56 | + # | |
| 57 | + # this returns the most recent class loader on the current call | |
| 58 | + # stack. Traditionally the call stack is walked and the class of | |
| 59 | + # each "active" method is checked to obtain its class loader (if | |
| 60 | + # any; null==root loader). The first such class loader we find | |
| 61 | + # is returned. | |
| 62 | + # | |
| 63 | + return(nil); #for now we don't walk back | |
| 64 | + junk := this; | |
| 65 | +}#<< | |
| 66 | + | |
| 67 | +classDepth_rString_I( this : ref SecurityManager_obj, p0 : JString) : int | |
| 68 | +{#>> | |
| 69 | + # | |
| 70 | + # walk the call stack looking for a method that resides in | |
| 71 | + # the class specified. | |
| 72 | + # | |
| 73 | + if ( p0 != nil ) | |
| 74 | + { | |
| 75 | + clname := p0.str; | |
| 76 | + # change any '.' to '/' | |
| 77 | + l := len clname; | |
| 78 | + for(x:=0;x<l; x++) | |
| 79 | + if ( clname[x] == '.' ) clname[x] = '/'; | |
| 80 | + | |
| 81 | + # attempt to open the local "prog" device (i.e. '#p') | |
| 82 | + # and read the call stack into an array of bytes | |
| 83 | + pid := jni->sys->pctl(0,nil); | |
| 84 | + progfile := "#p/"+ (string pid) +"/stack"; | |
| 85 | + fd := jni->sys->open( progfile, Sys->OREAD ); | |
| 86 | + if ( fd != nil ) | |
| 87 | + { | |
| 88 | + # must spin a thread to read my own call-stack | |
| 89 | + result := chan of array of byte; # channel for thd results | |
| 90 | + spawn ReadCallStack( fd, result ); | |
| 91 | + callstack := <- result; # wait for results | |
| 92 | + | |
| 93 | + (cnt,frame) := jni->sys->tokenize( string callstack, "\n" ); | |
| 94 | + if ( cnt > 0 ) | |
| 95 | + { | |
| 96 | + # walk frames looking for module-name/class-name match | |
| 97 | + depth := 0; | |
| 98 | + for( ; frame!=nil; frame=tl frame ) | |
| 99 | + { | |
| 100 | + # parse each line | |
| 101 | + (a,tok) := jni->sys->tokenize(hd frame, " "); | |
| 102 | + if ( a > 0 ) | |
| 103 | + { | |
| 104 | + #module name is last token | |
| 105 | + for( b:=0; b<a-1; b-- ) | |
| 106 | + tok = tl tok; | |
| 107 | + if ( (hd tok) == clname ) | |
| 108 | + return( depth ); | |
| 109 | + } | |
| 110 | + depth++; | |
| 111 | + } | |
| 112 | + } | |
| 113 | + } | |
| 114 | + | |
| 115 | + } | |
| 116 | + | |
| 117 | + return(-1); #if we are here we can't find the class | |
| 118 | + junk := (this); | |
| 119 | +}#<< | |
| 120 | + | |
| 121 | +classLoaderDepth_I( this : ref SecurityManager_obj) : int | |
| 122 | +{#>> | |
| 123 | + # | |
| 124 | + # return the number of frames back to the first class | |
| 125 | + # loader on the call stack. Return -1 if no classloaders. | |
| 126 | + # | |
| 127 | + return(-1); #for now we don't walk back | |
| 128 | + junk := this; | |
| 129 | +}#<< | |
| 130 | + | |
| 131 | +currentLoadedClass0_rClass( this : ref SecurityManager_obj) : JClass | |
| 132 | +{#>> | |
| 133 | + # | |
| 134 | + # return the first class on the call stack that was loaded | |
| 135 | + # with a class loader. | |
| 136 | + # | |
| 137 | + return( nil ); | |
| 138 | + junk := this; | |
| 139 | +}#<< | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | +ReadCallStack( fd : ref Sys->FD, result : chan of array of byte ) | |
| 145 | +{ | |
| 146 | + # read until eof | |
| 147 | + buf := array[8000] of byte; #about 10 frames | |
| 148 | + (n,ptr) := (0,0); | |
| 149 | + do | |
| 150 | + { | |
| 151 | + cur := len buf-ptr; | |
| 152 | + n = jni->sys->read(fd, buf[ptr:], cur); | |
| 153 | + ptr += n; | |
| 154 | + if ( n == cur ) | |
| 155 | + { | |
| 156 | + # need to read more | |
| 157 | + buf = ExtendBuf(buf); | |
| 158 | + } | |
| 159 | + | |
| 160 | + } while ( n != 0 ); | |
| 161 | + | |
| 162 | + result <- = buf[:ptr]; | |
| 163 | +} | |
| 164 | + | |
| 165 | +ExtendBuf( buf : array of byte ) : array of byte | |
| 166 | +{ | |
| 167 | + curlen := len buf; | |
| 168 | + newbuf := array[curlen + 8000] of byte; | |
| 169 | + | |
| 170 | + # copy old contents | |
| 171 | + for(x:=0; x<curlen; x++ ) | |
| 172 | + newbuf[x] = buf[x]; | |
| 173 | + | |
| 174 | + return( newbuf ); | |
| 175 | +} | |
| @@ -0,0 +1,19 @@ | ||
| 1 | +# javal v1.2 generated file: edit with care | |
| 2 | + | |
| 3 | +SecurityManager_L : module | |
| 4 | +{ | |
| 5 | + SecurityManager_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + inCheck : int; | |
| 9 | + initialized : int; | |
| 10 | + }; | |
| 11 | + | |
| 12 | + init : fn( jni_p : JNI ); | |
| 13 | + getClassContext_aClass : fn( this : ref SecurityManager_obj) : JArrayJClass; | |
| 14 | + currentClassLoader_rClassLoader : fn( this : ref SecurityManager_obj) : JObject; | |
| 15 | + classDepth_rString_I : fn( this : ref SecurityManager_obj, p0 : JString) : int; | |
| 16 | + classLoaderDepth_I : fn( this : ref SecurityManager_obj) : int; | |
| 17 | + currentLoadedClass0_rClass : fn( this : ref SecurityManager_obj) : JClass; | |
| 18 | + | |
| 19 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,359 @@ | ||
| 1 | +implement StringBuffer_L; | |
| 2 | + | |
| 3 | +# javal v1.4 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +# this module implements the class java.lang.StringBuffer | |
| 28 | +# the buffer is really a Limbo string type. In the original | |
| 29 | +# Java implementation an array of char was used and the array | |
| 30 | +# size was always >= to the buffer contents. In this version | |
| 31 | +# The limbo string represents only the buffer contents and | |
| 32 | +# contains no extra "padding". This is done because the | |
| 33 | +# Inferno implementation of string is optimized for string | |
| 34 | +# operations. Thus, the actual buffer contents is simply the | |
| 35 | +# length of the Limbo string; the original Java version | |
| 36 | +# maintained the buffer content size in the field 'count'. | |
| 37 | +# For conveience of the Java code, and to negate a call into | |
| 38 | +# the native Limbo, the 'count' field is maintained to always | |
| 39 | +# be the length of the Limbo string: e.g. "count=len Ivalue". | |
| 40 | +# | |
| 41 | +# In the Java version the character array can be shared with | |
| 42 | +# an instance of the Java String class, hence a flag for being | |
| 43 | +# shared. This is not the case for the Inferno implementation. | |
| 44 | +# whenever data is passed out it must be a copy of the 'Ivalue' | |
| 45 | +# string. | |
| 46 | +# | |
| 47 | +# When this was implemented synchronizatio of native methods | |
| 48 | +# was not complete, so this module assumes if a method should | |
| 49 | +# be synchronized it is done before entering the native method | |
| 50 | +# so each native method should be a private method and wrapped | |
| 51 | +# in Java code by a synchronized method (or block). | |
| 52 | +# | |
| 53 | +# The java.lang.StringBuffer class is serialzable. For Inferno | |
| 54 | +# since the internal structure has changed serialization must | |
| 55 | +# be explitily handled by this class. This is done by adding | |
| 56 | +# writeObject()/readObject() methods in the Java side to write | |
| 57 | +# and read in the expected format, so outside VM's do not know | |
| 58 | +# we have a differen implementation. | |
| 59 | +# | |
| 60 | + | |
| 61 | +#<< | |
| 62 | + | |
| 63 | +include "StringBuffer_L.m"; | |
| 64 | + | |
| 65 | +#>> extra post includes here | |
| 66 | +Value : import jni; | |
| 67 | +cast : Cast; | |
| 68 | + | |
| 69 | +#<< | |
| 70 | + | |
| 71 | +init( jni_p : JNI ) | |
| 72 | +{ | |
| 73 | + # save java native inteface mod instance | |
| 74 | + jni = jni_p; | |
| 75 | + #>>extra initialization here | |
| 76 | + cast = jni->CastMod(); | |
| 77 | + #<< | |
| 78 | +} | |
| 79 | + | |
| 80 | +setLength0_I_V( this : ref StringBuffer_obj, p0 : int) | |
| 81 | +{#>> | |
| 82 | + # p0 => length to set buf to; assume >=0 | |
| 83 | + | |
| 84 | + l := len this.Ivalue; | |
| 85 | + | |
| 86 | + if ( p0 < l ) # truncate | |
| 87 | + this.Ivalue = this.Ivalue[:p0]; | |
| 88 | + else { # pad with null characters | |
| 89 | + for( i := l; i < p0; i++ ) | |
| 90 | + this.Ivalue[i] = '\0'; | |
| 91 | + } | |
| 92 | + this.count = len this.Ivalue; | |
| 93 | +}#<< | |
| 94 | + | |
| 95 | +charAt0_I_C( this : ref StringBuffer_obj, p0 : int) : int | |
| 96 | +{#>> | |
| 97 | + # assume p0 is within the range 0..len this.Ivalue | |
| 98 | + return( this.Ivalue[p0] ); | |
| 99 | +}#<< | |
| 100 | + | |
| 101 | +getChars0_I_I_aC_I_V( this : ref StringBuffer_obj, p0 : int,p1 : int,p2 : JArrayC,p3 : int) | |
| 102 | +{#>> | |
| 103 | + # assume the index ranges are already checked | |
| 104 | + copy_count := (p1-p0); | |
| 105 | + dst_end := p3 + copy_count; | |
| 106 | + if ( dst_end > len p2.ary ) | |
| 107 | + jni->ThrowException( "java.lang.ArrayIndexOutOfBoundsException", "destination array not large enough" ); | |
| 108 | + | |
| 109 | + # copy one char at a time | |
| 110 | + for( (x,y) := (p3,p0); x < copy_count; junk:=(x++,y++) ) | |
| 111 | + p2.ary[x] = this.Ivalue[y]; | |
| 112 | + | |
| 113 | +}#<< | |
| 114 | + | |
| 115 | +setCharAt0_I_C_V( this : ref StringBuffer_obj, p0 : int,p1 : int) | |
| 116 | +{#>> | |
| 117 | + # assume index has been checked | |
| 118 | + this.Ivalue[p0] = p1; | |
| 119 | +}#<< | |
| 120 | + | |
| 121 | +reverse0_V( this : ref StringBuffer_obj) | |
| 122 | +{#>> | |
| 123 | + # reverse the string buffer contents | |
| 124 | + str := this.Ivalue[:]; # slice a copy | |
| 125 | + for( (x,y):=(0,(len str)-1); x<len str; junk:=(x++,y--) ) | |
| 126 | + this.Ivalue[x] = str[y]; | |
| 127 | + | |
| 128 | +}#<< | |
| 129 | + | |
| 130 | +append_int_I_V( this : ref StringBuffer_obj, p0 : int) | |
| 131 | +{#>> | |
| 132 | + # append the Ivalue to the string | |
| 133 | + this.Ivalue += string p0; | |
| 134 | + this.count = len this.Ivalue; | |
| 135 | +}#<< | |
| 136 | + | |
| 137 | +append_long_J_V( this : ref StringBuffer_obj, p0 : big) | |
| 138 | +{#>> | |
| 139 | + # append the Ivalue to the string | |
| 140 | + this.Ivalue += string p0; | |
| 141 | + this.count = len this.Ivalue; | |
| 142 | +}#<< | |
| 143 | + | |
| 144 | +append_str_rString_V( this : ref StringBuffer_obj, p0 : JString) | |
| 145 | +{#>> | |
| 146 | + # append the Ivalue to the string | |
| 147 | + val : string; | |
| 148 | + if ( p0 == nil ) | |
| 149 | + val = "null"; #this is what Java wants | |
| 150 | + else | |
| 151 | + val = p0.str; | |
| 152 | + | |
| 153 | + this.Ivalue += val; | |
| 154 | + this.count = len this.Ivalue; | |
| 155 | +}#<< | |
| 156 | + | |
| 157 | +append_chars_aC_I_I_V( this : ref StringBuffer_obj, p0 : JArrayC,p1 : int,p2 : int) | |
| 158 | +{#>> | |
| 159 | + # append the Ivalue to the string | |
| 160 | + if ( p0 == nil ) return; | |
| 161 | + | |
| 162 | + val := p0.ary[p1:p1+p2]; | |
| 163 | + l := len this.Ivalue; | |
| 164 | + for( x:=0; x < len val; x++ ) | |
| 165 | + this.Ivalue[l++] = val[x]; | |
| 166 | + this.count = len this.Ivalue; | |
| 167 | +}#<< | |
| 168 | + | |
| 169 | +append_ch_C_V( this : ref StringBuffer_obj, p0 : int) | |
| 170 | +{#>> | |
| 171 | + # append the Ivalue to the string | |
| 172 | + this.Ivalue[this.count] = p0; | |
| 173 | + this.count++; | |
| 174 | +}#<< | |
| 175 | + | |
| 176 | +append_float_F_V( this : ref StringBuffer_obj, p0 : real) | |
| 177 | +{#>> | |
| 178 | + # append the Ivalue to the string | |
| 179 | + s := string p0; | |
| 180 | + if(p0 == 0.0) | |
| 181 | + s += ".0"; | |
| 182 | + this.Ivalue += s; | |
| 183 | + this.count = len this.Ivalue; | |
| 184 | +}#<< | |
| 185 | + | |
| 186 | +append_double_D_V( this : ref StringBuffer_obj, p0 : real) | |
| 187 | +{#>> | |
| 188 | + # append the Ivalue to the string | |
| 189 | + s := string p0; | |
| 190 | + if(p0 == 0.0) | |
| 191 | + s += ".0"; | |
| 192 | + this.Ivalue += s; | |
| 193 | + this.count = len this.Ivalue; | |
| 194 | +}#<< | |
| 195 | + | |
| 196 | +insert_int_I_I_V( this : ref StringBuffer_obj, p0 : int,p1 : int) | |
| 197 | +{#>> | |
| 198 | + # insert 'p1' into the string the new string is | |
| 199 | + # left + p1 + right; where left is Ivalue[:p0] | |
| 200 | + # and right is Ivalue[p0:]. newright is | |
| 201 | + # p1+right | |
| 202 | + # assume args have been checked | |
| 203 | + # | |
| 204 | + newright := (string p1) + this.Ivalue[p0:]; | |
| 205 | + this.Ivalue = this.Ivalue[:p0] + newright; | |
| 206 | + this.count = len this.Ivalue; | |
| 207 | +}#<< | |
| 208 | + | |
| 209 | +insert_long_I_J_V( this : ref StringBuffer_obj, p0 : int,p1 : big) | |
| 210 | +{#>> | |
| 211 | + # insert 'p1' into the string the new string is | |
| 212 | + # left + p1 + right; where left is Ivalue[0:p0] | |
| 213 | + # and right is Ivalue[p0:count]. newright is | |
| 214 | + # p1+right | |
| 215 | + # | |
| 216 | + newright := (string p1) + this.Ivalue[p0:]; | |
| 217 | + this.Ivalue = this.Ivalue[:p0] + newright; | |
| 218 | + this.count = len this.Ivalue; | |
| 219 | +}#<< | |
| 220 | + | |
| 221 | +insert_str_I_rString_V( this : ref StringBuffer_obj, p0 : int,p1 : JString) | |
| 222 | +{#>> | |
| 223 | + # insert 'p1' into the string the new string is | |
| 224 | + # left + p1 + right; where left is Ivalue[0:p0] | |
| 225 | + # and right is Ivalue[p0:count]. newright is | |
| 226 | + # p1+right | |
| 227 | + # | |
| 228 | + val : string; | |
| 229 | + if ( p1 == nil ) | |
| 230 | + val = "null"; | |
| 231 | + else | |
| 232 | + val = p1.str; | |
| 233 | + newright := val + this.Ivalue[p0:]; | |
| 234 | + left := this.Ivalue[:p0]; | |
| 235 | + this.Ivalue = left + newright; | |
| 236 | + this.count = len this.Ivalue; | |
| 237 | +}#<< | |
| 238 | + | |
| 239 | +insert_chars_I_aC_V( this : ref StringBuffer_obj, p0 : int,p1 : JArrayC) | |
| 240 | +{#>> | |
| 241 | + # insert 'p1' into the string the new string is | |
| 242 | + # left + p1 + right; where left is Ivalue[:p0] | |
| 243 | + # and right is Ivalue[p0:]. newright is | |
| 244 | + # p1+right | |
| 245 | + # | |
| 246 | + if ( p1 == nil ) return; | |
| 247 | + | |
| 248 | + # get copy of old right part and lop it off | |
| 249 | + oldright := this.Ivalue[p0:]; | |
| 250 | + this.Ivalue = this.Ivalue[:p0]; | |
| 251 | + | |
| 252 | + # insert char array first | |
| 253 | + for( x:=0; x<len p1.ary; x++ ) | |
| 254 | + this.Ivalue[p0 + x] = p1.ary[x]; | |
| 255 | + | |
| 256 | + # now add the old right back | |
| 257 | + this.Ivalue += oldright; | |
| 258 | + this.count = len this.Ivalue; | |
| 259 | +}#<< | |
| 260 | + | |
| 261 | +insert_ch_I_C_V( this : ref StringBuffer_obj, p0 : int,p1 : int) | |
| 262 | +{#>> | |
| 263 | + # insert 'p1' into the string the new string is | |
| 264 | + # left + p1 + right; where left is Ivalue[:p0] | |
| 265 | + # and right is Ivalue[p0:]. newright is | |
| 266 | + # p1+right | |
| 267 | + # | |
| 268 | + newright: string; | |
| 269 | + newright[0] = p1; | |
| 270 | + newright += this.Ivalue[p0:]; | |
| 271 | + this.Ivalue = this.Ivalue[:p0] + newright; | |
| 272 | + this.count = len this.Ivalue; | |
| 273 | +}#<< | |
| 274 | + | |
| 275 | +insert_float_I_F_V( this : ref StringBuffer_obj, p0 : int,p1 : real) | |
| 276 | +{#>> | |
| 277 | + # insert 'p1' into the string the new string is | |
| 278 | + # left + p1 + right; where left is Ivalue[0:p0] | |
| 279 | + # and right is Ivalue[p0:count]. newright is | |
| 280 | + # p1+right | |
| 281 | + # | |
| 282 | + s := string p1; | |
| 283 | + if(p1 == 0.0) | |
| 284 | + s += ".0"; | |
| 285 | + newright := s + this.Ivalue[p0:]; | |
| 286 | + this.Ivalue = this.Ivalue[:p0] + newright; | |
| 287 | + this.count = len this.Ivalue; | |
| 288 | +}#<< | |
| 289 | + | |
| 290 | +insert_double_I_D_V( this : ref StringBuffer_obj, p0 : int,p1 : real) | |
| 291 | +{#>> | |
| 292 | + # insert 'p1' into the string the new string is | |
| 293 | + # left + p1 + right; where left is Ivalue[0:p0] | |
| 294 | + # and right is Ivalue[p0:count]. newright is | |
| 295 | + # p1+right | |
| 296 | + # | |
| 297 | + s := string p1; | |
| 298 | + if(p1 == 0.0) | |
| 299 | + s += ".0"; | |
| 300 | + newright := s + this.Ivalue[p0:]; | |
| 301 | + this.Ivalue = this.Ivalue[:p0] + newright; | |
| 302 | + this.count = len this.Ivalue; | |
| 303 | +}#<< | |
| 304 | + | |
| 305 | +get_string_rString( this : ref StringBuffer_obj) : JString | |
| 306 | +{#>> | |
| 307 | + return( jni->NewString( this.Ivalue[:] ) ); #return a copy | |
| 308 | +}#<< | |
| 309 | + | |
| 310 | +get_chars_aC( this : ref StringBuffer_obj) : JArrayC | |
| 311 | +{#>> | |
| 312 | + # return a char array | |
| 313 | + l := len this.Ivalue; | |
| 314 | + chars := array[l] of int; | |
| 315 | + for( x:=0; x<l; x++ ) | |
| 316 | + chars[x] = this.Ivalue[x]; | |
| 317 | + | |
| 318 | + return( jni->MkAChar( chars ) ); | |
| 319 | +}#<< | |
| 320 | + | |
| 321 | +# | |
| 322 | +# the next two functions are for serialization | |
| 323 | +# | |
| 324 | + | |
| 325 | +# | |
| 326 | +# write this.Ivalue (a Dis string) to an ObjectOutputStream as a char[] | |
| 327 | +# | |
| 328 | + | |
| 329 | +writeObject0_rObjectOutputStream_V(this : ref StringBuffer_obj, p0 : JObject) | |
| 330 | +{#>> | |
| 331 | + jaryc := jni->StringToAChar(this.Ivalue); | |
| 332 | + args := array[] of { | |
| 333 | + ref Value.TObject(cast->FromJArray(cast->IntToJArray(jaryc))) | |
| 334 | + }; | |
| 335 | + jni->CallMethod(p0, "writeObject", "(Ljava/lang/Object;)V", args); | |
| 336 | +}#<< | |
| 337 | + | |
| 338 | +# | |
| 339 | +# read a char[] from an ObjectInputStream and convert it to a Dis string | |
| 340 | +# | |
| 341 | + | |
| 342 | +readObject0_rObjectInputStream_V(this : ref StringBuffer_obj, p0 : JObject) | |
| 343 | +{#>> | |
| 344 | + jaryc : JArrayC; | |
| 345 | + | |
| 346 | + (val, ok) := jni->CallMethod(p0, "readObject", "()Ljava/lang/Object;", nil); | |
| 347 | + if(ok == JNI->OK) { | |
| 348 | + pick v := val { | |
| 349 | + TObject => | |
| 350 | + jaryc = cast->ToJArrayC(v.jobj); | |
| 351 | + } | |
| 352 | + } | |
| 353 | + if(jaryc == nil || len jaryc.ary < this.count) | |
| 354 | + jni->ThrowException("java.io.IOException", "bad StringBuffer object serialized"); | |
| 355 | + | |
| 356 | + # JavaSoft JVM serializes trailing null characters; we can ignore | |
| 357 | + for(i := 0; i < this.count; i++) | |
| 358 | + this.Ivalue[i] = jaryc.ary[i]; | |
| 359 | +}#<< | |
| @@ -0,0 +1,42 @@ | ||
| 1 | +# javal v1.4 generated file: edit with care | |
| 2 | + | |
| 3 | +##EDITED | |
| 4 | + | |
| 5 | +StringBuffer_L : module | |
| 6 | +{ | |
| 7 | + StringBuffer_obj : adt | |
| 8 | + { | |
| 9 | + cl_mod : ClassModule; | |
| 10 | + Ivalue : string; | |
| 11 | + buf_capacity : int; | |
| 12 | + value : array of int; | |
| 13 | + count : int; | |
| 14 | + shared : byte; | |
| 15 | + }; | |
| 16 | + | |
| 17 | + init : fn( jni_p : JNI ); | |
| 18 | + setLength0_I_V : fn( this : ref StringBuffer_obj, p0 : int); | |
| 19 | + charAt0_I_C : fn( this : ref StringBuffer_obj, p0 : int) : int; | |
| 20 | + getChars0_I_I_aC_I_V : fn( this : ref StringBuffer_obj, p0 : int,p1 : int,p2 : JArrayC,p3 : int); | |
| 21 | + setCharAt0_I_C_V : fn( this : ref StringBuffer_obj, p0 : int,p1 : int); | |
| 22 | + reverse0_V : fn( this : ref StringBuffer_obj); | |
| 23 | + append_int_I_V : fn( this : ref StringBuffer_obj, p0 : int); | |
| 24 | + append_long_J_V : fn( this : ref StringBuffer_obj, p0 : big); | |
| 25 | + append_str_rString_V : fn( this : ref StringBuffer_obj, p0 : JString); | |
| 26 | + append_chars_aC_I_I_V : fn( this : ref StringBuffer_obj, p0 : JArrayC,p1 : int,p2 : int); | |
| 27 | + append_ch_C_V : fn( this : ref StringBuffer_obj, p0 : int); | |
| 28 | + append_float_F_V : fn( this : ref StringBuffer_obj, p0 : real); | |
| 29 | + append_double_D_V : fn( this : ref StringBuffer_obj, p0 : real); | |
| 30 | + insert_int_I_I_V : fn( this : ref StringBuffer_obj, p0 : int,p1 : int); | |
| 31 | + insert_long_I_J_V : fn( this : ref StringBuffer_obj, p0 : int,p1 : big); | |
| 32 | + insert_str_I_rString_V : fn( this : ref StringBuffer_obj, p0 : int,p1 : JString); | |
| 33 | + insert_chars_I_aC_V : fn( this : ref StringBuffer_obj, p0 : int,p1 : JArrayC); | |
| 34 | + insert_ch_I_C_V : fn( this : ref StringBuffer_obj, p0 : int,p1 : int); | |
| 35 | + insert_float_I_F_V : fn( this : ref StringBuffer_obj, p0 : int,p1 : real); | |
| 36 | + insert_double_I_D_V : fn( this : ref StringBuffer_obj, p0 : int,p1 : real); | |
| 37 | + get_string_rString : fn( this : ref StringBuffer_obj) : JString; | |
| 38 | + get_chars_aC : fn( this : ref StringBuffer_obj) : JArrayC; | |
| 39 | + | |
| 40 | + writeObject0_rObjectOutputStream_V : fn(this : ref StringBuffer_obj, p0 : JObject); | |
| 41 | + readObject0_rObjectInputStream_V : fn(this : ref StringBuffer_obj, p0 : JObject); | |
| 42 | +}; | |
Empty file added.
| @@ -0,0 +1,517 @@ | ||
| 1 | +implement String_L; | |
| 2 | + | |
| 3 | +# javal v1.6 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +#<< | |
| 28 | + | |
| 29 | +include "String_L.m"; | |
| 30 | + | |
| 31 | +#>> extra post includes here | |
| 32 | +include "hash.m"; | |
| 33 | + | |
| 34 | +str : String; | |
| 35 | +hash : Hash; | |
| 36 | + | |
| 37 | +# | |
| 38 | +# the following are for the intern() method | |
| 39 | +# a pool of all Java String classes is maintained | |
| 40 | +# hashed on the actual string contents. For any | |
| 41 | +# given actual string the same Java String object | |
| 42 | +# should be returned. We maingain a hash table | |
| 43 | +# of String objects, hashed on the string value. | |
| 44 | +# | |
| 45 | +PSZ : con 31; | |
| 46 | +pool := array[PSZ] of list of JString; | |
| 47 | + | |
| 48 | +PoolAdd( jstr : JString ) | |
| 49 | +{ | |
| 50 | + idx := hash->fun1(jstr.str,PSZ); | |
| 51 | + pool[idx] = jstr :: pool[idx]; | |
| 52 | +} | |
| 53 | + | |
| 54 | +PoolGet( val : JString ) : JString | |
| 55 | +{ | |
| 56 | + # search for an existing object with same value | |
| 57 | + for( l := pool[hash->fun1(val.str,PSZ)]; l != nil; l = tl l ) | |
| 58 | + { | |
| 59 | + jstr := hd l; | |
| 60 | + if (jstr.str == val.str) | |
| 61 | + return( jstr ); | |
| 62 | + } | |
| 63 | + | |
| 64 | + # could not find so add this class | |
| 65 | + PoolAdd( val ); | |
| 66 | + return( val ); | |
| 67 | +} | |
| 68 | + | |
| 69 | +#<< | |
| 70 | + | |
| 71 | +init( jni_p : JNI ) | |
| 72 | +{ | |
| 73 | + # save java native inteface mod instance | |
| 74 | + jni = jni_p; | |
| 75 | + #>>extra initialization here | |
| 76 | + str = jni->str; | |
| 77 | + hash = load Hash Hash->PATH; | |
| 78 | + if ( hash == nil ) | |
| 79 | + jni->InitError( jni->sys->sprint( "java.lang.String: could not load %s: %r", Hash->PATH ) ); | |
| 80 | + #<< | |
| 81 | +} | |
| 82 | + | |
| 83 | +length_I( this : JString) : int | |
| 84 | +{#>> | |
| 85 | + return( len this.str ); | |
| 86 | +}#<< | |
| 87 | + | |
| 88 | +charAt_I_C( this : JString, p0 : int) : int | |
| 89 | +{#>> | |
| 90 | + if ((this.str == nil) || (p0 > (len this.str -1)) || (p0 < 0)) | |
| 91 | + jni->ThrowException( "java.lang.StringIndexOutOfBoundsException", string p0 ); | |
| 92 | + return( this.str[p0] ); | |
| 93 | +}#<< | |
| 94 | + | |
| 95 | +getChars_I_I_aC_I_V( this : JString, p0 : int,p1 : int,p2 : JArrayC,p3 : int) | |
| 96 | +{#>> | |
| 97 | + # fill the char array with each char from the string | |
| 98 | + | |
| 99 | + # do some checking first | |
| 100 | + if ( p0 < 0 ) | |
| 101 | + jni->ThrowException( "java.lang.StringIndexOutOfBoundsException", string p0 ); | |
| 102 | + if ( p1 > len this.str ) | |
| 103 | + jni->ThrowException( "java.lang.StringIndexOutOfBoundsException", string p1 ); | |
| 104 | + if ( p0 > p1 ) | |
| 105 | + jni->ThrowException( "java.lang.StringIndexOutOfBoundsException", string (p1-p0) ); | |
| 106 | + | |
| 107 | + # now check array and copy chars into | |
| 108 | + copy_count := p1-p0; # number of chars to copy | |
| 109 | + | |
| 110 | + #STD?? I will just throw an exception here if I know | |
| 111 | + # I will overwrite the array bounds. To really be | |
| 112 | + # legit I may need to copy upto the end and then throw | |
| 113 | + if ( (copy_count + p3) > (len p2.ary) ) | |
| 114 | + jni->ThrowException( "java.lang.ArrayIndexOutOfBoundsException", string (len p2.ary) ); | |
| 115 | + | |
| 116 | + # now copy chars from this string into | |
| 117 | + # the char array, starting at the indicated | |
| 118 | + # position (p3) of the char array. | |
| 119 | + for( x:=0; x<copy_count; x++ ) | |
| 120 | + p2.ary[p3+x] = this.str[p0+x]; | |
| 121 | + | |
| 122 | +}#<< | |
| 123 | + | |
| 124 | +equality_rString_Z_Z( this : JString, p0 : JString,p1 : int) : int | |
| 125 | +{#>> | |
| 126 | + if ( p0 == nil ) | |
| 127 | + return( JNI->FALSE ); | |
| 128 | + | |
| 129 | + if ( this.str == p0.str ) | |
| 130 | + return( JNI->TRUE ); | |
| 131 | + | |
| 132 | + # check if we should ignore case | |
| 133 | + if ( p1 ) | |
| 134 | + return( str->toupper(this.str) == str->toupper(p0.str) ); | |
| 135 | + | |
| 136 | + # strings not equal | |
| 137 | + return( JNI->FALSE ); | |
| 138 | + | |
| 139 | +}#<< | |
| 140 | + | |
| 141 | +compareTo_rString_I( this : JString, p0 : JString) : int | |
| 142 | +{#>> | |
| 143 | + # compare 'p0' to this. | |
| 144 | + # return: 0 => equal | |
| 145 | + # <0 => this < p0 | |
| 146 | + # >0 => this > p0 | |
| 147 | + | |
| 148 | + this_str := this.str; | |
| 149 | + other := p0.str; | |
| 150 | + | |
| 151 | + # simple equlity check | |
| 152 | + if ( this_str == other ) | |
| 153 | + return( 0 ); | |
| 154 | + | |
| 155 | + # otherwise, determine if "this" is | |
| 156 | + # lexicographically smaller than "other" | |
| 157 | + | |
| 158 | + this_len := len this_str; | |
| 159 | + other_len := len other; | |
| 160 | + min := 0; | |
| 161 | + if ( this_len < other_len ) | |
| 162 | + min = this_len; | |
| 163 | + else | |
| 164 | + min = other_len; | |
| 165 | + | |
| 166 | + # find char where strings differ | |
| 167 | + x:=0; | |
| 168 | + while( (x<min) && (this_str[x]==other[x]) ) x++; | |
| 169 | + | |
| 170 | + # is one string a proper prefix of the other? | |
| 171 | + if(x == min) | |
| 172 | + return this_len - other_len; | |
| 173 | + | |
| 174 | + # if some chars were common then "this" is | |
| 175 | + # smaller if the character where they differ | |
| 176 | + # has a smaller value than "other" | |
| 177 | + return( this_str[x] - other[x] ); | |
| 178 | +}#<< | |
| 179 | + | |
| 180 | +regionMatches_Z_I_rString_I_I_Z( this : JString, p0 : int,p1 : int,p2 : JString,p3 : int,p4 : int) : int | |
| 181 | +{#>> | |
| 182 | + # p0 => ignore case==1 | |
| 183 | + # p1 => this start index | |
| 184 | + # p2 => other string | |
| 185 | + # p3 => other start index | |
| 186 | + # p4 => length to compare | |
| 187 | + | |
| 188 | + # check params | |
| 189 | + if ( (p1<0) || (p1 > (len this.str - p4)) || | |
| 190 | + (p3<0) || (p3 > (len p2.str - p4)) ) | |
| 191 | + return( jni->FALSE ); | |
| 192 | + | |
| 193 | + this_str, other : string; | |
| 194 | + | |
| 195 | + this_last := (p1+p4); | |
| 196 | + other_last := (p3+p4); | |
| 197 | + | |
| 198 | + if ( int p0 == 1 ) | |
| 199 | + { | |
| 200 | + # ignore case | |
| 201 | + this_str = str->toupper(this.str[p1:this_last]); | |
| 202 | + other = str->toupper(p2.str[p3:other_last]); | |
| 203 | + } | |
| 204 | + else | |
| 205 | + { | |
| 206 | + # case sensitive | |
| 207 | + this_str = this.str[p1:this_last]; | |
| 208 | + other = p2.str[p3:other_last]; | |
| 209 | + } | |
| 210 | + | |
| 211 | + # now compare the two substrings | |
| 212 | + return( this_str == other ); | |
| 213 | +}#<< | |
| 214 | + | |
| 215 | +hashCode_I( this : JString) : int | |
| 216 | +{#>> | |
| 217 | + # hashcode of string as defined in JLS | |
| 218 | + strhash := 0; | |
| 219 | + this_str := this.str; | |
| 220 | + this_len := len this_str; | |
| 221 | + | |
| 222 | + if ( this_len <= 15 ) | |
| 223 | + { | |
| 224 | + for(x:=0; x<this_len; x++) | |
| 225 | + strhash = (strhash*37) + this_str[x]; | |
| 226 | + } | |
| 227 | + else | |
| 228 | + { | |
| 229 | + k := int (this_len/8); | |
| 230 | + for(x:=0; x < this_len; x+=k) | |
| 231 | + strhash = (strhash*39) + this_str[x]; | |
| 232 | + } | |
| 233 | + | |
| 234 | + return( strhash ); | |
| 235 | +}#<< | |
| 236 | + | |
| 237 | +substring_I_I_rString( this : JString, p0 : int,p1 : int) : JString | |
| 238 | +{#>> | |
| 239 | + # return string composed of chars p0..p1-1 both | |
| 240 | + # java and limbo allow the p1 to be (len this.str) | |
| 241 | + this_len := len this.str; | |
| 242 | + if ( (p0 < 0) || (p1 > this_len) || (p0 > p1) ) | |
| 243 | + jni->ThrowException( "java.lang.StringIndexOutOfBoundsException", | |
| 244 | + jni->sys->sprint( "len=%d begin=%d end=%d", this_len, p0, p1 ) ); | |
| 245 | + | |
| 246 | + return( jni->NewString( this.str[p0:p1] ) ); | |
| 247 | +}#<< | |
| 248 | + | |
| 249 | +concat_rString_rString( this : JString, p0 : JString) : JString | |
| 250 | +{#>> | |
| 251 | + if ( p0 == nil ) | |
| 252 | + jni->ThrowException( "java.lang.NullPointerException", "concat arg is null" ); | |
| 253 | + | |
| 254 | + # as defined in JLS: if p0 is 0 len return ref to this | |
| 255 | + if ( (len p0.str) == 0 ) | |
| 256 | + return( this ); | |
| 257 | + | |
| 258 | + # return a new string composed of this+p0 | |
| 259 | + return( jni->NewString( this.str + p0.str ) ); | |
| 260 | +}#<< | |
| 261 | + | |
| 262 | +replace_C_C_rString( this : JString, p0 : int,p1 : int) : JString | |
| 263 | +{#>> | |
| 264 | + # p0 => old char, p1 => new char | |
| 265 | + # if p0 does not exist in this then | |
| 266 | + # return reference to this | |
| 267 | + # otherwise return a new string which | |
| 268 | + # is composed of the 'this' with all | |
| 269 | + # old char's (p0) replaced with new chars (p1) | |
| 270 | + | |
| 271 | + newstr := this.str[:]; | |
| 272 | + found := 0; | |
| 273 | + for(x:=0; x<(len newstr); x++) | |
| 274 | + { | |
| 275 | + if ( newstr[x] == p0 ) | |
| 276 | + { | |
| 277 | + found = 1; | |
| 278 | + newstr[x] = p1; | |
| 279 | + } | |
| 280 | + } | |
| 281 | + | |
| 282 | + if ( ! found ) | |
| 283 | + return( this ); | |
| 284 | + | |
| 285 | + return( jni->NewString( newstr ) ); | |
| 286 | +}#<< | |
| 287 | + | |
| 288 | +trim_rString( this : JString) : JString | |
| 289 | +{#>> | |
| 290 | + # as defined in JLS | |
| 291 | + if ( this.str == "" ) | |
| 292 | + return( this ); | |
| 293 | + | |
| 294 | + this_str := this.str; | |
| 295 | + if ( (this_str[0] > '\u0020') && (this_str[len this_str-1] > '\u0020') ) | |
| 296 | + return( this ); | |
| 297 | + | |
| 298 | + # look for first char > \u0020 | |
| 299 | + for( x:=0; x<(len this_str); x++ ) | |
| 300 | + if ( this_str[x] > '\u0020' ) break; | |
| 301 | + | |
| 302 | + # if no chars < \u0020 found return a new "empty string" | |
| 303 | + if ( x == len this_str ) | |
| 304 | + return( jni->NewString( "" ) ); | |
| 305 | + | |
| 306 | + first := x; | |
| 307 | + | |
| 308 | + # look for last char > \u0020 | |
| 309 | + for( x=(len this_str -1); x >= 0; x-- ) | |
| 310 | + if ( this_str[x] > '\u0020' ) break; | |
| 311 | + | |
| 312 | + last := x; # this has to be at least ==first | |
| 313 | + | |
| 314 | + return( jni->NewString( this_str[first:last+1] ) ); | |
| 315 | + | |
| 316 | +}#<< | |
| 317 | + | |
| 318 | +intern_rString( this : JString) : JString | |
| 319 | +{#>> | |
| 320 | + # as defined in JLS | |
| 321 | + # need to maintain a private pool of String | |
| 322 | + # objects and return the same object for a | |
| 323 | + # given string | |
| 324 | + return( PoolGet( this ) ); | |
| 325 | +}#<< | |
| 326 | + | |
| 327 | +utfLength_I( this : JString) : int | |
| 328 | +{#>> | |
| 329 | + b : array of byte; | |
| 330 | + b = array of byte this.str; | |
| 331 | + return( len b ); | |
| 332 | +}#<< | |
| 333 | + | |
| 334 | +fill_aC_I_I_V( this : JString, p0 : JArrayC,p1 : int,p2 : int) | |
| 335 | +{#>> | |
| 336 | + # | |
| 337 | + # create a newstring from the array of int | |
| 338 | + # | |
| 339 | + | |
| 340 | + # check array length | |
| 341 | + if ( (p1+p2) > len p0.ary ) | |
| 342 | + jni->ThrowException( "java.lang.ArrayIndexOutOfBoundsException", string (len p0.ary) ); | |
| 343 | + | |
| 344 | + this.str = nil; # get rid of what is there | |
| 345 | + | |
| 346 | + # now append each char to the string value | |
| 347 | + # Lecuona correction: for( x:=0; x<(p2-p1); x++ ) | |
| 348 | + for( x:=0; x<p2; x++ ) | |
| 349 | + this.str[x] = p0.ary[x+p1]; | |
| 350 | +}#<< | |
| 351 | + | |
| 352 | +isPrefix_rString_I_Z( this : JString, p0 : JString,p1 : int) : int | |
| 353 | +{#>> | |
| 354 | + # p0 => string to compare | |
| 355 | + # p1 => start index | |
| 356 | + | |
| 357 | + # do some checking | |
| 358 | + if ( p0 == nil ) | |
| 359 | + jni->ThrowException( "java.lang.NullPointerException", "String.isPrefix()" ); | |
| 360 | + other_len := len p0.str; | |
| 361 | + endix := other_len + p1; # can overflow | |
| 362 | + if ( p1 < 0 || endix > len this.str || endix < 0 ) | |
| 363 | + return( jni->FALSE ); | |
| 364 | + if ( other_len == 0 ) | |
| 365 | + return( jni->TRUE ); # JLS defined | |
| 366 | + return( p0.str == this.str[p1:p1+other_len] ); | |
| 367 | +}#<< | |
| 368 | + | |
| 369 | +isSuffix_rString_Z( this : JString, p0 : JString) : int | |
| 370 | +{#>> | |
| 371 | + start := (len this.str) - (len p0.str); | |
| 372 | + if ( start < 0 ) | |
| 373 | + return( jni->FALSE ); | |
| 374 | + | |
| 375 | + return( p0.str == this.str[start:] ); | |
| 376 | +}#<< | |
| 377 | + | |
| 378 | +uppercase_rString( this : JString) : JString | |
| 379 | +{#>> | |
| 380 | + return( jni->NewString( str->toupper(this.str) ) ); | |
| 381 | +}#<< | |
| 382 | + | |
| 383 | +lowercase_rString( this : JString) : JString | |
| 384 | +{#>> | |
| 385 | + return( jni->NewString( str->tolower(this.str) ) ); | |
| 386 | +}#<< | |
| 387 | + | |
| 388 | +index_rString_I_I( this : JString, p0 : JString,p1 : int) : int | |
| 389 | +{#>> | |
| 390 | + # p0 => string to match | |
| 391 | + # p1 => index to start search from | |
| 392 | + # p2 => searche left-right=1 right-left=0 | |
| 393 | + this_str := this.str; | |
| 394 | + this_len := len this_str; | |
| 395 | + other := p0.str; | |
| 396 | + other_len := len other; | |
| 397 | + | |
| 398 | + # if other > this then it can't be a substring | |
| 399 | + if ( other_len > this_len ) | |
| 400 | + return( -1 ); | |
| 401 | + | |
| 402 | + # if start index <0 make it 0, if > len return -1 | |
| 403 | + from := 0; | |
| 404 | + if ( p1 > 0 ) | |
| 405 | + { | |
| 406 | + from = p1; | |
| 407 | + # this also handles p1 > this_len | |
| 408 | + # which will return -1 below, we | |
| 409 | + } | |
| 410 | + | |
| 411 | + # null string always matches | |
| 412 | + if ( other_len == 0 ) | |
| 413 | + return from; | |
| 414 | + | |
| 415 | + # determine char of this to stop searching on | |
| 416 | + stop_char := this_len - other_len; | |
| 417 | + | |
| 418 | + # look for first-char match then | |
| 419 | + # match the substring. | |
| 420 | + for( i:=from; i <= stop_char; i++ ) | |
| 421 | + if ( (this_str[i] == other[0]) && | |
| 422 | + (this_str[i:i+other_len] == other) ) | |
| 423 | + return( i ); | |
| 424 | + | |
| 425 | + # match failed | |
| 426 | + return( -1 ); | |
| 427 | +}#<< | |
| 428 | + | |
| 429 | +index_I_I_I( this : JString, p0 : int,p1 : int) : int | |
| 430 | +{#>> | |
| 431 | + # p0 => char to match | |
| 432 | + # p1 => start index | |
| 433 | + | |
| 434 | + this_str := this.str; | |
| 435 | + this_len := len this_str; | |
| 436 | + | |
| 437 | + # if start index <0 make it 0, if > len return -1 | |
| 438 | + from := 0; | |
| 439 | + if ( p1 > 0 ) | |
| 440 | + from = p1; | |
| 441 | + | |
| 442 | + # start from left, | |
| 443 | + # look for first match | |
| 444 | + for( i:=from; i < this_len; i++ ) | |
| 445 | + if ( this_str[i] == p0 ) | |
| 446 | + return( i ); | |
| 447 | + | |
| 448 | + # match failed | |
| 449 | + return( -1 ); | |
| 450 | +}#<< | |
| 451 | + | |
| 452 | +rindex_rString_I_Z_I( this : JString, p0 : JString,p1 : int,p2 : int) : int | |
| 453 | +{#>> | |
| 454 | + # p0 => string to match | |
| 455 | + # p1 => index to start search from | |
| 456 | + # p2 => 1 == search from end (ignore p1) | |
| 457 | + this_str := this.str; | |
| 458 | + this_len := len this_str; | |
| 459 | + other := p0.str; | |
| 460 | + other_len := len other; | |
| 461 | + | |
| 462 | + # if other > this then it can't be a substring | |
| 463 | + if ( other_len > this_len ) | |
| 464 | + return( -1 ); | |
| 465 | + | |
| 466 | + # if start index > this_len-other_len make it this_len-other_len | |
| 467 | + # if < 0 return -1 | |
| 468 | + from := this_len - other_len; | |
| 469 | + if ( (p2 != 1) && (p1 < from) ) | |
| 470 | + { | |
| 471 | + from = p1; | |
| 472 | + # this also handles the defined case | |
| 473 | + # of p1 < 0 is the same as p1==-1 and | |
| 474 | + # will return -1 below | |
| 475 | + } | |
| 476 | + | |
| 477 | + # start from end | |
| 478 | + if ( other_len == 0 ) | |
| 479 | + return( from ); # empty string always matches | |
| 480 | + | |
| 481 | + # look for first char match starting from right | |
| 482 | + # then match the substring | |
| 483 | + for( i:=from; i >= 0; i-- ) | |
| 484 | + if ( (this_str[i] == other[0]) && | |
| 485 | + (this_str[i:i+other_len] == other) ) | |
| 486 | + return(i); | |
| 487 | + | |
| 488 | + return(-1); #no match | |
| 489 | +}#<< | |
| 490 | + | |
| 491 | +rindex_I_I_Z_I( this : JString, p0 : int,p1 : int,p2 : int) : int | |
| 492 | +{#>> | |
| 493 | + # p0 => char to match | |
| 494 | + # p1 => start index | |
| 495 | + # p2 => 1 == scan from (len this.str -1) | |
| 496 | + | |
| 497 | + this_str := this.str; | |
| 498 | + | |
| 499 | + # if start index < 0 return -1, if > len this.str make it the length | |
| 500 | + from := len this_str - 1; | |
| 501 | + if ( (p2 != 1) && (p1 < from) ) | |
| 502 | + { | |
| 503 | + from = p1; | |
| 504 | + } | |
| 505 | + | |
| 506 | + # start from right | |
| 507 | + # look for first match | |
| 508 | + for( i:=from; i >= 0; i-- ) | |
| 509 | + if ( this_str[i] == p0 ) | |
| 510 | + return(i); | |
| 511 | + | |
| 512 | + # match failed | |
| 513 | + return( -1 ); | |
| 514 | +}#<< | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| @@ -0,0 +1,30 @@ | ||
| 1 | +# javal v1.6 generated file: edit with care | |
| 2 | + | |
| 3 | +String_L : module | |
| 4 | +{ | |
| 5 | + | |
| 6 | + init : fn( jni_p : JNI ); | |
| 7 | + length_I : fn( this : JString) : int; | |
| 8 | + charAt_I_C : fn( this : JString, p0 : int) : int; | |
| 9 | + getChars_I_I_aC_I_V : fn( this : JString, p0 : int,p1 : int,p2 : JArrayC,p3 : int); | |
| 10 | + equality_rString_Z_Z : fn( this : JString, p0 : JString,p1 : int) : int; | |
| 11 | + compareTo_rString_I : fn( this : JString, p0 : JString) : int; | |
| 12 | + regionMatches_Z_I_rString_I_I_Z : fn( this : JString, p0 : int,p1 : int,p2 : JString,p3 : int,p4 : int) : int; | |
| 13 | + hashCode_I : fn( this : JString) : int; | |
| 14 | + substring_I_I_rString : fn( this : JString, p0 : int,p1 : int) : JString; | |
| 15 | + concat_rString_rString : fn( this : JString, p0 : JString) : JString; | |
| 16 | + replace_C_C_rString : fn( this : JString, p0 : int,p1 : int) : JString; | |
| 17 | + trim_rString : fn( this : JString) : JString; | |
| 18 | + intern_rString : fn( this : JString) : JString; | |
| 19 | + utfLength_I : fn( this : JString) : int; | |
| 20 | + fill_aC_I_I_V : fn( this : JString, p0 : JArrayC,p1 : int,p2 : int); | |
| 21 | + isPrefix_rString_I_Z : fn( this : JString, p0 : JString,p1 : int) : int; | |
| 22 | + isSuffix_rString_Z : fn( this : JString, p0 : JString) : int; | |
| 23 | + uppercase_rString : fn( this : JString) : JString; | |
| 24 | + lowercase_rString : fn( this : JString) : JString; | |
| 25 | + index_rString_I_I : fn( this : JString, p0 : JString,p1 : int) : int; | |
| 26 | + index_I_I_I : fn( this : JString, p0 : int,p1 : int) : int; | |
| 27 | + rindex_rString_I_Z_I : fn( this : JString, p0 : JString,p1 : int,p2 : int) : int; | |
| 28 | + rindex_I_I_Z_I : fn( this : JString, p0 : int,p1 : int,p2 : int) : int; | |
| 29 | + | |
| 30 | +}; | |
Empty file added.
| @@ -0,0 +1,133 @@ | ||
| 1 | +implement System_L; | |
| 2 | + | |
| 3 | +# javal v1.2 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JObject : import jni; | |
| 23 | + | |
| 24 | +#>> extra pre includes here | |
| 25 | + | |
| 26 | +#<< | |
| 27 | + | |
| 28 | +include "System_L.m"; | |
| 29 | + | |
| 30 | +#>> extra post includes here | |
| 31 | +include "workdir.m"; | |
| 32 | + | |
| 33 | +cast : Cast; | |
| 34 | +system_class : JNI->ClassData; # java.lang.System class data | |
| 35 | + | |
| 36 | +#<< | |
| 37 | + | |
| 38 | +init( jni_p : JNI ) | |
| 39 | +{ | |
| 40 | + # save java native inteface mod instance | |
| 41 | + jni = jni_p; | |
| 42 | + #>>extra initialization here | |
| 43 | + system_class = jni->FindClass( "java/lang/System" ); | |
| 44 | + if ( system_class == nil ) | |
| 45 | + jni->InitError( "System_L.init(): failed to find System class" ); | |
| 46 | + | |
| 47 | + # we Cast in this module | |
| 48 | + cast = jni->CastMod(); | |
| 49 | + #<< | |
| 50 | +} | |
| 51 | + | |
| 52 | +setIn0_rInputStream_V( p0 : JObject) | |
| 53 | +{#>> | |
| 54 | + Value : import JNI; | |
| 55 | + val := ref Value.TObject(p0); | |
| 56 | + jni->SetStaticField( system_class, "in", val ); | |
| 57 | +}#<< | |
| 58 | + | |
| 59 | +setOut0_rPrintStream_V( p0 : JObject) | |
| 60 | +{#>> | |
| 61 | + Value : import JNI; | |
| 62 | + val := ref Value.TObject(p0); | |
| 63 | + jni->SetStaticField( system_class, "out", val ); | |
| 64 | +}#<< | |
| 65 | + | |
| 66 | +setErr0_rPrintStream_V( p0 : JObject) | |
| 67 | +{#>> | |
| 68 | + Value : import JNI; | |
| 69 | + val := ref Value.TObject(p0); | |
| 70 | + jni->SetStaticField( system_class, "err", val ); | |
| 71 | +}#<< | |
| 72 | + | |
| 73 | +currentTimeMillis_J( ) : big | |
| 74 | +{#>> | |
| 75 | + fd := jni->sys->open("#c/time", jni->sys->OREAD); | |
| 76 | + if(fd == nil) | |
| 77 | + return big 0; | |
| 78 | + buf := array[128] of byte; | |
| 79 | + n := jni->sys->read(fd, buf, len buf); | |
| 80 | + if(n < 0) | |
| 81 | + return big 0; | |
| 82 | + | |
| 83 | + return ( (big string buf[:n]) / big 1000 ); | |
| 84 | +}#<< | |
| 85 | + | |
| 86 | +arraycopy_rObject_I_rObject_I_I_V( p0 : JObject,p1 : int,p2 : JObject,p3 : int,p4 : int) | |
| 87 | +{#>> | |
| 88 | + jni->jldr->arraycopy( cast->ToJArray(p0), p1, cast->ToJArray(p2), p3, p4 ); | |
| 89 | +}#<< | |
| 90 | + | |
| 91 | +identityHashCode_rObject_I( p0 : JObject) : int | |
| 92 | +{#>> | |
| 93 | + return( jni->IdentityHash(p0) ); | |
| 94 | +}#<< | |
| 95 | + | |
| 96 | +GetUserName_rString( ) : JString | |
| 97 | +{#>> | |
| 98 | + # return the current inferno user | |
| 99 | + # name as a Java String | |
| 100 | + # | |
| 101 | + user_name : string; | |
| 102 | + | |
| 103 | + fd := jni->sys->open("#c/user", jni->sys->OREAD); | |
| 104 | + if(fd == nil) | |
| 105 | + user_name = "unknown"; | |
| 106 | + else { | |
| 107 | + buf := array[128] of byte; | |
| 108 | + n := jni->sys->read(fd, buf, len buf); | |
| 109 | + if(n < 0) | |
| 110 | + user_name = "unknown"; | |
| 111 | + else | |
| 112 | + user_name = string buf[:n]; | |
| 113 | + } | |
| 114 | + | |
| 115 | + # make java string from user name | |
| 116 | + return( jni->NewString( user_name ) ); | |
| 117 | +}#<< | |
| 118 | + | |
| 119 | +GetCWD_rString( ) : JString | |
| 120 | +{#>> | |
| 121 | + # return the current working directory | |
| 122 | + # as a Java String | |
| 123 | + # | |
| 124 | + # this fct is really only called once so | |
| 125 | + # just load Workdir right here | |
| 126 | + wdir := load Workdir Workdir->PATH; | |
| 127 | + if ( wdir == nil ) | |
| 128 | + jni->InitError( jni->sys->sprint( "java.lang.System: could not load %s: %r", Workdir->PATH ) ); | |
| 129 | + | |
| 130 | + return( jni->NewString( wdir->init() ) ); | |
| 131 | +}#<< | |
| 132 | + | |
| 133 | + | |
| @@ -0,0 +1,20 @@ | ||
| 1 | +# javal v1.2 generated file: edit with care | |
| 2 | + | |
| 3 | +System_L : module | |
| 4 | +{ | |
| 5 | + System_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + }; | |
| 9 | + | |
| 10 | + init : fn( jni_p : JNI ); | |
| 11 | + setIn0_rInputStream_V : fn( p0 : JObject); | |
| 12 | + setOut0_rPrintStream_V : fn( p0 : JObject); | |
| 13 | + setErr0_rPrintStream_V : fn( p0 : JObject); | |
| 14 | + currentTimeMillis_J : fn( ) : big; | |
| 15 | + arraycopy_rObject_I_rObject_I_I_V : fn( p0 : JObject,p1 : int,p2 : JObject,p3 : int,p4 : int); | |
| 16 | + identityHashCode_rObject_I : fn( p0 : JObject) : int; | |
| 17 | + GetUserName_rString : fn( ) : JString; | |
| 18 | + GetCWD_rString : fn( ) : JString; | |
| 19 | + | |
| 20 | +}; | |
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,455 @@ | ||
| 1 | +implement Thread_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +#<< | |
| 28 | + | |
| 29 | +include "Thread_L.m"; | |
| 30 | + | |
| 31 | +#>> extra post includes here | |
| 32 | + | |
| 33 | +sys : Sys; | |
| 34 | +jldr : JavaClassLoader; | |
| 35 | +cast : Cast; | |
| 36 | + | |
| 37 | +# following used for calling Thread.run() | |
| 38 | +threadclass : JNI->ClassData; #class data for java.lang.Thread | |
| 39 | +thread_run_idx : int; #method index for Thread.run() | |
| 40 | +thread_exit_idx : int; #method index for Thread.exit() | |
| 41 | + | |
| 42 | +# some imports | |
| 43 | +ThreadData : import jldr; | |
| 44 | + | |
| 45 | +#<< | |
| 46 | + | |
| 47 | +init( jni_p : JNI ) | |
| 48 | +{ | |
| 49 | + # save java native inteface mod instance | |
| 50 | + jni = jni_p; | |
| 51 | + #>>extra initialization here | |
| 52 | + | |
| 53 | + sys = jni->sys; | |
| 54 | + jldr = jni->jldr; | |
| 55 | + cast = jni->CastMod(); | |
| 56 | + | |
| 57 | + threadclass = jni->FindClass( "java.lang.Thread" ); | |
| 58 | + if ( threadclass == nil ) | |
| 59 | + jni->InitError( "Thread_L.init(): could not get thread class" ); | |
| 60 | + | |
| 61 | + Class : import jldr; | |
| 62 | + thread_run_idx = threadclass.findvmethod( "run", "()V" ); | |
| 63 | + if ( thread_run_idx == -1 ) | |
| 64 | + jni->InitError( "Thread_L.init(): could not locate Thread.run()" ); | |
| 65 | + | |
| 66 | + #thread_exit_idx = threadclass.findvmethod( "exit", "()V" ); | |
| 67 | + #if ( exit_idx == -1 ) | |
| 68 | + # jni->InitError( "Thread_L.init(): could not locate Thread.exit()" ); | |
| 69 | + #<< | |
| 70 | +} | |
| 71 | + | |
| 72 | +currentThread_rThread( ) : JThread | |
| 73 | +{#>> | |
| 74 | + e := ref Sys->Exception; | |
| 75 | + if ( sys->rescue("*",e) == Sys->HANDLER ) | |
| 76 | + { | |
| 77 | + # get the java thread object assocciated | |
| 78 | + # with this thread. it is stored in the | |
| 79 | + # class loader's thread structure. | |
| 80 | + thd_obj := jldr->getthreaddata().this; | |
| 81 | + if ( thd_obj != nil ) | |
| 82 | + return( cast->JObjToJThd(thd_obj) ); | |
| 83 | + sys->unrescue(); | |
| 84 | + } | |
| 85 | + else | |
| 86 | + sys->rescued(Sys->ONCE, nil); | |
| 87 | + | |
| 88 | + | |
| 89 | + # either we could not find the thread data | |
| 90 | + # or no "Thread" object was stored in it | |
| 91 | + # either way we are in bad shape | |
| 92 | + jni->FatalError( "could not get thread object" ); | |
| 93 | + | |
| 94 | + return(nil); | |
| 95 | +}#<< | |
| 96 | + | |
| 97 | +yield_V( ) | |
| 98 | +{#>> | |
| 99 | + jni->sys->sleep(0); | |
| 100 | +}#<< | |
| 101 | + | |
| 102 | +sleep_J_V( p0 : big) | |
| 103 | +{#>> | |
| 104 | + millis := int p0; | |
| 105 | + | |
| 106 | + if ( millis < 1 ) | |
| 107 | + { | |
| 108 | + if ( millis == 0 ) | |
| 109 | + { | |
| 110 | + # just yield thread | |
| 111 | + jni->sys->sleep(0); | |
| 112 | + return; | |
| 113 | + } | |
| 114 | + | |
| 115 | + # bad sleep value | |
| 116 | + jni->ThrowException( "java.lang.IllegalArgumentException", "timeout value is negative" ); | |
| 117 | + } | |
| 118 | + jldr->sleep( millis ); | |
| 119 | +}#<< | |
| 120 | + | |
| 121 | +start_V( this : JThread) | |
| 122 | +{#>> | |
| 123 | + thdobj := cast->JThdToJObj(this); | |
| 124 | + | |
| 125 | + # grab the lock on the thread object to ensure | |
| 126 | + # no state is changed while we are starting the | |
| 127 | + # thread. | |
| 128 | +# jni->MonitorEnter( thdobj ); | |
| 129 | + | |
| 130 | + if ( (this.stillborn == byte 0) && (this.PrivateInfo == nil) ) | |
| 131 | + { | |
| 132 | + # spawn a limbo fct as the java | |
| 133 | + # thread's starting point. | |
| 134 | + ok := chan of int; | |
| 135 | + spawn javathreadinit( this, ok ); | |
| 136 | + | |
| 137 | + # wait for thread to init then we can | |
| 138 | + # continue. Note we hold a lock and | |
| 139 | + # the thread will change some state | |
| 140 | + # and notify us before the java run() | |
| 141 | + # method is invoked. The purpose is to | |
| 142 | + # allow for state information to be updated | |
| 143 | + # while we have the lock. | |
| 144 | + status := <- ok; | |
| 145 | + | |
| 146 | + #status == 0 is an err | |
| 147 | + # == 1 is ok | |
| 148 | + | |
| 149 | + if ( status == 0 ) | |
| 150 | + { | |
| 151 | + this.stillborn = byte 1; | |
| 152 | + this.PrivateInfo = nil; | |
| 153 | + } | |
| 154 | + | |
| 155 | + } | |
| 156 | +# jni->MonitorExit( thdobj ); | |
| 157 | +}#<< | |
| 158 | + | |
| 159 | +isInterrupted_Z_Z( this : JThread, p0 : int) : int | |
| 160 | +{#>> | |
| 161 | + old_flag := int this.was_interrupted; | |
| 162 | + | |
| 163 | + if ( old_flag ) | |
| 164 | + this.was_interrupted = byte p0; | |
| 165 | + return( old_flag ); | |
| 166 | +}#<< | |
| 167 | + | |
| 168 | +isAlive_Z( this : JThread) : int | |
| 169 | +{#>> | |
| 170 | + thd := this.PrivateInfo; | |
| 171 | + if ( (this.stillborn == byte 0) && (thd != nil) ) | |
| 172 | + { | |
| 173 | + # JLS does not require that we actually determine | |
| 174 | + # the "os" thread is alive, just that the object | |
| 175 | + # state indicates it is | |
| 176 | + return( JNI->TRUE ); | |
| 177 | + } | |
| 178 | + | |
| 179 | + # looks like thread is not alive | |
| 180 | + return( jni->FALSE ); | |
| 181 | +}#<< | |
| 182 | + | |
| 183 | +countStackFrames_I( this : JThread) : int | |
| 184 | +{#>> | |
| 185 | + junk := this; | |
| 186 | + # need to do some /prog work | |
| 187 | + return( 0 ); | |
| 188 | +}#<< | |
| 189 | + | |
| 190 | +setPriority0_I_V( this : JThread, p0 : int) | |
| 191 | +{#>> | |
| 192 | + # just save the priority, a dis thread | |
| 193 | + # has no priority | |
| 194 | + this.priority = p0; | |
| 195 | +}#<< | |
| 196 | + | |
| 197 | +stop0_rObject_V( this : JThread, p0 : JObject) | |
| 198 | +{#>> | |
| 199 | + # the calling thread is attempting to throw an | |
| 200 | + # exception at "this" thread (i.e. the one represented | |
| 201 | + # by this thread object. make sure that thread at least | |
| 202 | + # appears to be running and throw the exceptio at it | |
| 203 | + | |
| 204 | + thd := this.PrivateInfo; | |
| 205 | + stillborn := this.stillborn; | |
| 206 | + | |
| 207 | + # prevent a start or re-start | |
| 208 | + this.stillborn = byte 1; | |
| 209 | + | |
| 210 | + if ( (stillborn == byte 0) && (thd != nil) ) | |
| 211 | + { | |
| 212 | + # throw the exception (p0) at the thread | |
| 213 | + jldr->stop( thd, p0 ); | |
| 214 | + } | |
| 215 | + | |
| 216 | +}#<< | |
| 217 | + | |
| 218 | +suspend0_V( this : JThread) | |
| 219 | +{#>> | |
| 220 | + # the calling thread wants to suspend | |
| 221 | + # the "this" thread. | |
| 222 | + thd := this.PrivateInfo; | |
| 223 | + if ( (this.stillborn == byte 0) && (thd != nil) ) | |
| 224 | + jldr->suspend( thd ); | |
| 225 | + | |
| 226 | +}#<< | |
| 227 | + | |
| 228 | +resume0_V( this : JThread) | |
| 229 | +{#>> | |
| 230 | + # the calling thread wants to resume | |
| 231 | + # the "this" thread. | |
| 232 | + thd := this.PrivateInfo; | |
| 233 | + if ( (this.stillborn == byte 0) && (thd != nil) ) | |
| 234 | + jldr->resume( thd ); | |
| 235 | +}#<< | |
| 236 | + | |
| 237 | +interrupt0_V( this : JThread) | |
| 238 | +{#>> | |
| 239 | + # the calling thread wants to interrupt | |
| 240 | + # the "this" thread. | |
| 241 | + thd := this.PrivateInfo; | |
| 242 | + if ( (this.stillborn == byte 0) && (thd != nil) ) | |
| 243 | + jldr->interrupt( thd ); | |
| 244 | +}#<< | |
| 245 | + | |
| 246 | +lowinit_rThread_V( p0 : JThread) | |
| 247 | +{#>> | |
| 248 | + # this fct is called once during the static init of the | |
| 249 | + # java.lang.Thread object. 'p0' is the "root thread" object | |
| 250 | + # which must be associated witht the Dis thread which is | |
| 251 | + # calling this fuction -- i.e. associate the 'p0' java thread | |
| 252 | + # object with the current Dis thread. 'p1' is the same thread | |
| 253 | + # object, just with the type JObject which allows us to store | |
| 254 | + # it off in the JavaClassLoader->ThreadData structure associated | |
| 255 | + # with the calling Dis thread. | |
| 256 | + | |
| 257 | + # since this is the root thread make a root thread group by | |
| 258 | + # creating an instance of ThreadGroup and calling its private | |
| 259 | + # default constructor. | |
| 260 | + thd_grp_cl := jni->FindClass( "java.lang.ThreadGroup" ); | |
| 261 | + if ( thd_grp_cl == nil ) | |
| 262 | + jni->FatalError( "could not obtain ThreadGroup class" ); | |
| 263 | + | |
| 264 | + thd_grp := jni->NewObject( thd_grp_cl ); | |
| 265 | + if ( thd_grp == nil ) | |
| 266 | + jni->FatalError( "could not created root threadgroup" ); | |
| 267 | + p0.group = thd_grp; | |
| 268 | + | |
| 269 | + # get the ThreadData structure for the calling thread | |
| 270 | + thd := jldr->getthreaddata(); | |
| 271 | + thd.this = cast->JThdToJObj(p0); # save java object in thread data | |
| 272 | + p0.PrivateInfo = thd; # save thread data in java object | |
| 273 | + | |
| 274 | +}#<< | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | +##### private functions used by the Thread_L module | |
| 281 | + | |
| 282 | +# | |
| 283 | +# this function is the first function of all java | |
| 284 | +# threads, except for the first thread which is | |
| 285 | +# controlled by the JavaClassLoader module. | |
| 286 | +# | |
| 287 | +# jthd : the Java thread object associated with this | |
| 288 | +# Dis thread. | |
| 289 | +# | |
| 290 | +# ok : use this channel to notify "spawner" that | |
| 291 | +# we are under-way. send 0==fail; 1==ok | |
| 292 | +# | |
| 293 | +javathreadinit( jthd : JNI->JThread, ok : chan of int ) | |
| 294 | +{ | |
| 295 | + # create a JavaClassLoader->ThreadData structure | |
| 296 | + # and "register" it with the class loader. | |
| 297 | + | |
| 298 | + thd := jldr->getthreaddata(); | |
| 299 | + | |
| 300 | + if ( thd.this != nil ) | |
| 301 | + { | |
| 302 | + # this should be nil, else the java thread | |
| 303 | + # already is set for this Dis thread and we | |
| 304 | + # are in some screwed-up state. | |
| 305 | + ok <-= 0; | |
| 306 | + return; | |
| 307 | + } | |
| 308 | + | |
| 309 | + # now fill in the java thread obj (after | |
| 310 | + # the putthreaddata so any init is not affected | |
| 311 | + thdobj := cast->JThdToJObj( jthd ); | |
| 312 | + thd.this = thdobj; | |
| 313 | + | |
| 314 | + # now save the ThreadData in the java object in order | |
| 315 | + # to allow a lookup from the other diretion | |
| 316 | + jthd.PrivateInfo = thd; | |
| 317 | + | |
| 318 | + # set our daemon thread status | |
| 319 | + if ( jthd.daemon == JNI->BTRUE ) | |
| 320 | + jldr->daemonize(); | |
| 321 | + | |
| 322 | + # notify spawner we are under-way | |
| 323 | + ok <- = 1; | |
| 324 | + | |
| 325 | + # we need to catch any exceptions in order | |
| 326 | + # to clean up the thread object's state | |
| 327 | + ee := ref Sys->Exception; | |
| 328 | + if ( sys->rescue( "*", ee ) == Sys->HANDLER ) | |
| 329 | + { | |
| 330 | + | |
| 331 | + # call Thread.run() or Runnable.run() | |
| 332 | + Run( jthd, thdobj ); | |
| 333 | + | |
| 334 | + # call Thread.exit() | |
| 335 | + (mod,idx) := jni->FindMethod( threadclass, "exit", "()V", JNI->METH_PRIVATE ); | |
| 336 | + jni->jassist->mcall1( mod, idx, thdobj ); | |
| 337 | + sys->unrescue(); | |
| 338 | + } | |
| 339 | + else | |
| 340 | + { | |
| 341 | + # clear exception | |
| 342 | + sys->rescued( Sys->ONCE, nil ); | |
| 343 | + | |
| 344 | + # thread threw an unhandled exception so | |
| 345 | + # call the ThreadGroup.uncaughtException() | |
| 346 | + # method. | |
| 347 | + UncaughtException( jthd, thdobj, ee ); | |
| 348 | + } | |
| 349 | + | |
| 350 | + # java thread clean up | |
| 351 | + | |
| 352 | + jni->jldr->monitorenter( thdobj ); ##LOCK thread object | |
| 353 | + { | |
| 354 | + | |
| 355 | + jthd.stillborn = byte 1; # prevent re-run | |
| 356 | + | |
| 357 | + # notify ALL "waiters" (which includes any Thread.join()'s) | |
| 358 | + jni->jldr->monitornotify( thdobj, 1 ); | |
| 359 | + } | |
| 360 | + jni->jldr->monitorexit( thdobj ); ##UNLOCK thread object | |
| 361 | + | |
| 362 | + # clean up thread structures | |
| 363 | + jldr->delthreaddata(); | |
| 364 | + thd.this = nil; | |
| 365 | + jthd.PrivateInfo = nil; | |
| 366 | +} | |
| 367 | + | |
| 368 | + | |
| 369 | +# | |
| 370 | +# if the thread object contains a "registered" Runnable | |
| 371 | +# object then execute that Runnable's run() method, else | |
| 372 | +# execute the Thread's run() method (which should be | |
| 373 | +# overridden. | |
| 374 | +# | |
| 375 | +Run( jthd : JNI->JThread, thdobj : JObject ) | |
| 376 | +{ | |
| 377 | + Class : import jldr; | |
| 378 | + class : JNI->ClassData; | |
| 379 | + run_idx := thread_run_idx; #default to Thread.run() | |
| 380 | + obj := thdobj; #this obj for run() call | |
| 381 | + | |
| 382 | + if ( jthd.target != nil ) | |
| 383 | + { | |
| 384 | + # the thread has a registered Runnable | |
| 385 | + # object, find its run() method | |
| 386 | + class = jni->GetObjectClassData( jthd.target ); | |
| 387 | + run_idx = class.findvmethod( "run", "()V" ); | |
| 388 | + if ( run_idx == -1 ) | |
| 389 | + return; | |
| 390 | + obj = jthd.target; #set 'this' to the runnable obj | |
| 391 | + } | |
| 392 | + else | |
| 393 | + { | |
| 394 | + # use the thread object's run() | |
| 395 | + class = jni->GetObjectClassData(thdobj); | |
| 396 | + } | |
| 397 | + | |
| 398 | + run_method := class.virtualmethods[run_idx]; | |
| 399 | + | |
| 400 | + # do the run() | |
| 401 | + jni->jassist->mcall1( run_method.class.mod, run_method.field.value, obj ); | |
| 402 | +} | |
| 403 | + | |
| 404 | +# | |
| 405 | +# If the thread's ThreadGroup is a subclass of java.lang.ThreadGroup | |
| 406 | +# then invoke that class'es "uncaughtException" method. This | |
| 407 | +# method is called whenever a thread does not handle an exception. | |
| 408 | +# The method is passed an instance of the Thread along with the | |
| 409 | +# "throwable" (i.e. exception). | |
| 410 | +# | |
| 411 | +UncaughtException( jthd : JThread, thdobj : JObject, ee : ref Sys->Exception ) | |
| 412 | +{ | |
| 413 | + tgrp_cl := jni->GetObjectClassData( jthd.group ); | |
| 414 | + | |
| 415 | + # | |
| 416 | + # if the thread group is the default thread group | |
| 417 | + # class, then we will handle the excepition here | |
| 418 | + # which is to simply do nothing. | |
| 419 | + # | |
| 420 | + if ( tgrp_cl.name != "java/lang/ThreadGroup" ) | |
| 421 | + { | |
| 422 | + # call method, protected against exceptions | |
| 423 | + # since we must still clean-up the thread | |
| 424 | + eee := ref Sys->Exception; | |
| 425 | + if ( sys->rescue( "*", eee ) == Sys->HANDLER ) | |
| 426 | + { | |
| 427 | + # find the uncaughtException method for the thd-grp | |
| 428 | + (mod,idx) := jni->FindMethod( tgrp_cl, "uncaughtException", | |
| 429 | + "(Ljava.lang.Thread;Ljava.lang.Throwable;)V", | |
| 430 | + JNI->METH_VIRTUAL ); | |
| 431 | + if ( mod != nil ) | |
| 432 | + { | |
| 433 | + # call the uncaughException handler | |
| 434 | + Value : import jni; | |
| 435 | + args := array[] of | |
| 436 | + { | |
| 437 | + ref Value.TObject(thdobj), #the thread | |
| 438 | + ref Value.TObject(jldr->culprit(ee)) #the exception | |
| 439 | + }; | |
| 440 | + | |
| 441 | + # do the call | |
| 442 | + ##LATER nil := jni->LowCall( mod, idx, jthd.group, args ); | |
| 443 | + } | |
| 444 | + sys->unrescue(); | |
| 445 | + } | |
| 446 | + else | |
| 447 | + { | |
| 448 | + # if we get an exception here just return | |
| 449 | + # and let the thread finish cleanup. | |
| 450 | + sys->rescued( Sys->ONCE, nil ); | |
| 451 | + } | |
| 452 | + } | |
| 453 | + | |
| 454 | +} | |
| 455 | + | |
| @@ -0,0 +1,21 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +Thread_L : module | |
| 4 | +{ | |
| 5 | + | |
| 6 | + init : fn( jni_p : JNI ); | |
| 7 | + currentThread_rThread : fn( ) : JThread; | |
| 8 | + yield_V : fn( ); | |
| 9 | + sleep_J_V : fn( p0 : big); | |
| 10 | + start_V : fn( this : JThread); | |
| 11 | + isInterrupted_Z_Z : fn( this : JThread, p0 : int) : int; | |
| 12 | + isAlive_Z : fn( this : JThread) : int; | |
| 13 | + countStackFrames_I : fn( this : JThread) : int; | |
| 14 | + setPriority0_I_V : fn( this : JThread, p0 : int); | |
| 15 | + stop0_rObject_V : fn( this : JThread, p0 : JObject); | |
| 16 | + suspend0_V : fn( this : JThread); | |
| 17 | + resume0_V : fn( this : JThread); | |
| 18 | + interrupt0_V : fn( this : JThread); | |
| 19 | + lowinit_rThread_V : fn( p0 : JThread); | |
| 20 | + | |
| 21 | +}; | |
Empty file added.
| @@ -0,0 +1,96 @@ | ||
| 1 | +implement Throwable_L; | |
| 2 | + | |
| 3 | +# javal v1.2 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JObject : import jni; | |
| 23 | + | |
| 24 | +#>> extra pre includes here | |
| 25 | + | |
| 26 | +#<< | |
| 27 | + | |
| 28 | +include "Throwable_L.m"; | |
| 29 | + | |
| 30 | +#>> extra post includes here | |
| 31 | + | |
| 32 | +#<< | |
| 33 | + | |
| 34 | +init( jni_p : JNI ) | |
| 35 | +{ | |
| 36 | + # save java native inteface mod instance | |
| 37 | + jni = jni_p; | |
| 38 | + #>>extra initialization here | |
| 39 | + #<< | |
| 40 | +} | |
| 41 | + | |
| 42 | +printStackTrace0_rObject_V( this : ref Throwable_obj, p0 : JObject) | |
| 43 | +{#>> | |
| 44 | + Value : import jni; | |
| 45 | + jldr := jni->jldr; | |
| 46 | + Object : import jldr; | |
| 47 | + | |
| 48 | + if ( this.backtrace != nil ) | |
| 49 | + { | |
| 50 | + args := array[] of | |
| 51 | + { | |
| 52 | + ref Value.TObject( jni->NewStringObject( string this.backtrace ) ) | |
| 53 | + }; | |
| 54 | + (nil,nil):=jni->CallMethod( p0, "println", "(Ljava/lang/String;)V", args ); | |
| 55 | + # ignore any erros | |
| 56 | + } | |
| 57 | + | |
| 58 | +}#<< | |
| 59 | + | |
| 60 | +fillInStackTrace_rThrowable( this : ref Throwable_obj) : ref Throwable_obj | |
| 61 | +{#>> | |
| 62 | + # attempt to open the local "prog" device (i.e. '#p') | |
| 63 | + # and read the call stack into an array of bytes | |
| 64 | + pid := jni->sys->pctl(0,nil); | |
| 65 | + progfile := "#p/"+ (string pid) +"/stack"; | |
| 66 | + fd := jni->sys->open( progfile, Sys->OREAD ); | |
| 67 | + if ( fd != nil ) | |
| 68 | + { | |
| 69 | + # must spin a thread to read my own call-stack | |
| 70 | + result := chan of array of byte; # channel for thd results | |
| 71 | + spawn ReadCallStack( fd, result ); | |
| 72 | + this.backtrace = <- result; # wait for results | |
| 73 | + | |
| 74 | + } | |
| 75 | + else | |
| 76 | + this.backtrace = array of byte jni->sys->sprint("could not open %s:%r\n", progfile ); | |
| 77 | + | |
| 78 | + return( this ); | |
| 79 | +}#<< | |
| 80 | + | |
| 81 | +####### private functions | |
| 82 | + | |
| 83 | + | |
| 84 | +ReadCallStack( fd : ref Sys->FD, result : chan of array of byte ) | |
| 85 | +{ | |
| 86 | + buf := array[8000] of byte; #about 10 frames | |
| 87 | + n := jni->sys->read(fd, buf, len buf - 1); | |
| 88 | + fd = nil; | |
| 89 | + if(n < 0) | |
| 90 | + buf = array of byte jni->sys->sprint("could not read call-stack:%r\n"); | |
| 91 | + else | |
| 92 | + buf[n] = byte 0; | |
| 93 | + | |
| 94 | + result <- = buf[:n+1]; | |
| 95 | +} | |
| 96 | + | |
| @@ -0,0 +1,16 @@ | ||
| 1 | +# javal v1.2 generated file: edit with care | |
| 2 | + | |
| 3 | +Throwable_L : module | |
| 4 | +{ | |
| 5 | + Throwable_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + backtrace : array of byte; | |
| 9 | + detailMessage : JString; | |
| 10 | + }; | |
| 11 | + | |
| 12 | + init : fn( jni_p : JNI ); | |
| 13 | + printStackTrace0_rObject_V : fn( this : ref Throwable_obj, p0 : JObject); | |
| 14 | + fillInStackTrace_rThrowable : fn( this : ref Throwable_obj) : ref Throwable_obj; | |
| 15 | + | |
| 16 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,152 @@ | ||
| 1 | +<../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + reflect\ | |
| 5 | + | |
| 6 | +TARG=\ | |
| 7 | + AbstractMethodError.dis\ | |
| 8 | + ArithmeticException.dis\ | |
| 9 | +# for ArrayIndexOutOfBoundsException.dis\ | |
| 10 | + ++5KkA5LRlUzD1nsDM8Mj.dis\ | |
| 11 | + ArrayStoreException.dis\ | |
| 12 | + Boolean.dis\ | |
| 13 | + Byte.dis\ | |
| 14 | + Character.dis\ | |
| 15 | + Class.dis\ | |
| 16 | + ClassCastException.dis\ | |
| 17 | + ClassCircularityError.dis\ | |
| 18 | + ClassFormatError.dis\ | |
| 19 | + ClassLoader.dis\ | |
| 20 | +# for ClassNotFoundException.dis\ | |
| 21 | + S1vm8N5TePhsu3h1FO7yj.dis\ | |
| 22 | +# for CloneNotSupportedException.dis\ | |
| 23 | + wmF21yXDq7VxPRRLc7v5t.dis\ | |
| 24 | + Cloneable.dis\ | |
| 25 | + Compiler.dis\ | |
| 26 | + Double.dis\ | |
| 27 | + Error.dis\ | |
| 28 | + Exception.dis\ | |
| 29 | +# for ExceptionInInitializerError.dis\ | |
| 30 | + Ub2BD3PjJRDSI4wyZi7ID.dis\ | |
| 31 | + Float.dis\ | |
| 32 | + IllegalAccessError.dis\ | |
| 33 | +# for IllegalAccessException.dis\ | |
| 34 | + ClJ4BmIE1TECvv1qdqbQN.dis\ | |
| 35 | +# for IllegalArgumentException.dis\ | |
| 36 | + Z07h8c1IAX5LIjYbhqgGl.dis\ | |
| 37 | +# for IllegalMonitorStateException.dis\ | |
| 38 | + 375fcBxmum6K8ZSGn7W2N.dis\ | |
| 39 | + IllegalStateException.dis\ | |
| 40 | +# for IllegalThreadStateException.dis\ | |
| 41 | + 1PLXdCFiGoZkxBoL8Bo0P.dis\ | |
| 42 | +# for IncompatibleClassChangeError.dis\ | |
| 43 | + FiACrRolKM+iZTikdgUFa.dis\ | |
| 44 | +# for IndexOutOfBoundsException.dis\ | |
| 45 | + IKsPHNdWGHpuZGqgvYD4e.dis\ | |
| 46 | + InfernoProcess.dis\ | |
| 47 | + InstantiationError.dis\ | |
| 48 | +# for InstantiationException.dis\ | |
| 49 | + jhj+E2mCFNmQ2VUL0zYp8.dis\ | |
| 50 | + Integer.dis\ | |
| 51 | + InternalError.dis\ | |
| 52 | + InterruptedException.dis\ | |
| 53 | + LinkageError.dis\ | |
| 54 | + Long.dis\ | |
| 55 | + Math.dis\ | |
| 56 | +# for NegativeArraySizeException.dis\ | |
| 57 | + iu6-cux1hLK1GoPKq9m1l.dis\ | |
| 58 | + NoClassDefFoundError.dis\ | |
| 59 | + NoSuchFieldError.dis\ | |
| 60 | + NoSuchFieldException.dis\ | |
| 61 | + NoSuchMethodError.dis\ | |
| 62 | + NoSuchMethodException.dis\ | |
| 63 | + NullPointerException.dis\ | |
| 64 | + NullSecurityManager.dis\ | |
| 65 | + Number.dis\ | |
| 66 | + NumberFormatException.dis\ | |
| 67 | + Object.dis\ | |
| 68 | + OutOfMemoryError.dis\ | |
| 69 | + Process.dis\ | |
| 70 | + Runnable.dis\ | |
| 71 | + Runtime.dis\ | |
| 72 | + RuntimeException.dis\ | |
| 73 | + SecurityException.dis\ | |
| 74 | + SecurityManager.dis\ | |
| 75 | + Short.dis\ | |
| 76 | + StackOverflowError.dis\ | |
| 77 | + String.dis\ | |
| 78 | + StringBuffer.dis\ | |
| 79 | +# for StringIndexOutOfBoundsException.dis\ | |
| 80 | + 5ZD+zz0io892VFWeXUN1a.dis\ | |
| 81 | + System.dis\ | |
| 82 | + Thread.dis\ | |
| 83 | + ThreadDeath.dis\ | |
| 84 | + ThreadGroup.dis\ | |
| 85 | + Throwable.dis\ | |
| 86 | + UnknownError.dis\ | |
| 87 | + UnsatisfiedLinkError.dis\ | |
| 88 | + VerifyError.dis\ | |
| 89 | + VirtualMachineError.dis\ | |
| 90 | + Void.dis\ | |
| 91 | +# Limbo code\ | |
| 92 | + Character_L.dis\ | |
| 93 | + ClassLoader_L.dis\ | |
| 94 | + Class_L.dis\ | |
| 95 | + Double_L.dis\ | |
| 96 | + Float_L.dis\ | |
| 97 | + InfernoProcess_L.dis\ | |
| 98 | + Math_L.dis\ | |
| 99 | + Object_L.dis\ | |
| 100 | + Runtime_L.dis\ | |
| 101 | + SecurityManager_L.dis\ | |
| 102 | + StringBuffer_L.dis\ | |
| 103 | + String_L.dis\ | |
| 104 | + System_L.dis\ | |
| 105 | + Thread_L.dis\ | |
| 106 | + Throwable_L.dis\ | |
| 107 | + unicode_table.dis\ | |
| 108 | + | |
| 109 | +MODULES=\ | |
| 110 | + $ROOT/java/module/classloader.m\ | |
| 111 | + $ROOT/java/module/jni.m\ | |
| 112 | + $ROOT/java/module/cast.m\ | |
| 113 | + Character_L.m\ | |
| 114 | + ClassLoader_L.m\ | |
| 115 | + Class_L.m\ | |
| 116 | + Double_L.m\ | |
| 117 | + Float_L.m\ | |
| 118 | + InfernoProcess_L.m\ | |
| 119 | + Math_L.m\ | |
| 120 | + Object_L.m\ | |
| 121 | + Runtime_L.m\ | |
| 122 | + SecurityManager_L.m\ | |
| 123 | + StringBuffer_L.m\ | |
| 124 | + String_L.m\ | |
| 125 | + System_L.m\ | |
| 126 | + Thread_L.m\ | |
| 127 | + Throwable_L.m\ | |
| 128 | + unicode_table.m\ | |
| 129 | + | |
| 130 | +SYSMODULES=\ | |
| 131 | + draw.m\ | |
| 132 | + hash.m\ | |
| 133 | + keyring.m\ | |
| 134 | + loader.m\ | |
| 135 | + math.m\ | |
| 136 | + string.m\ | |
| 137 | + sys.m\ | |
| 138 | + | |
| 139 | +DISBIN=$ROOT/java/dis/java/java/lang | |
| 140 | + | |
| 141 | +<$ROOT/mkfiles/mkjava | |
| 142 | +<$ROOT/mkfiles/mksubdirs | |
| 143 | + | |
| 144 | +LIMBOINCL=\ | |
| 145 | + $LIMBOINCL\ | |
| 146 | + -I$ROOT/java/pkg\ | |
| 147 | + | |
| 148 | +unicode_table.dis: unicode_table.b | |
| 149 | + limbo $LIMBOINCL -gw unicode_table.b | |
| 150 | + | |
| 151 | +NullSecurityManager.dis: SecurityManager.class | |
| 152 | + j2d NullSecurityManager.class | |
Empty file added.
| @@ -0,0 +1,417 @@ | ||
| 1 | +implement Array_L; | |
| 2 | + | |
| 3 | +# javal v1.5 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | + ClassData, | |
| 28 | + Value : import jni; | |
| 29 | + | |
| 30 | + jldr : JavaClassLoader; | |
| 31 | + | |
| 32 | +#<< | |
| 33 | + | |
| 34 | +include "Array_L.m"; | |
| 35 | + | |
| 36 | +#>> extra post includes here | |
| 37 | + | |
| 38 | +include "reflect.m"; | |
| 39 | + refl : Reflect; | |
| 40 | + widen : import refl; | |
| 41 | + | |
| 42 | +array_class : ClassData; | |
| 43 | + | |
| 44 | +badindex := "java.lang.ArrayIndexOutOfBoundsException"; | |
| 45 | +illegalarg := "java.lang.IllegalArgumentException"; | |
| 46 | +nullptr := "java.lang.NullPointerException"; | |
| 47 | + | |
| 48 | + cast : Cast; | |
| 49 | + | |
| 50 | +#<< | |
| 51 | + | |
| 52 | +init( jni_p : JNI ) | |
| 53 | +{ | |
| 54 | + # save java native inteface mod instance | |
| 55 | + jni = jni_p; | |
| 56 | + #>>extra initialization here | |
| 57 | + array_class = jni->FindClass("inferno/vm/Array"); | |
| 58 | + | |
| 59 | + jldr = jni->jldr; | |
| 60 | + cast = jni->CastMod(); | |
| 61 | + refl = load Reflect Reflect->PATH; | |
| 62 | + if ( refl == nil ) | |
| 63 | + jni->InitError( jni->sys->sprint( "java.lang.reflect.Array: could not load %s: %r", Reflect->PATH ) ); | |
| 64 | + else | |
| 65 | + refl->init(jni); | |
| 66 | + | |
| 67 | + #<< | |
| 68 | +} | |
| 69 | + | |
| 70 | +getLength_rObject_I( p0 : JObject) : int | |
| 71 | +{#>> | |
| 72 | + # p0 - must be a Java array; if not, exceptions are thrown | |
| 73 | + # Returns the integer length of the array. | |
| 74 | + | |
| 75 | + if ( p0 == nil ) | |
| 76 | + jni->ThrowException(nullptr, ""); | |
| 77 | + if ( jni->IsArray(p0) == JNI->FALSE) | |
| 78 | + jni->ThrowException(illegalarg, "Not an array"); | |
| 79 | + return jni->GetArrayLength(cast->ToJArray(p0)); | |
| 80 | +}#<< | |
| 81 | + | |
| 82 | +get_rObject_I_rObject( p0 : JObject,p1 : int) : JObject | |
| 83 | +{#>> | |
| 84 | + # p0 - a Java object, which must be an array, else exception occurs. | |
| 85 | + # p1 - an index into the array, >= 0 and < length of array | |
| 86 | + # Returns the element at that index. If the array is of a primitive | |
| 87 | + # type, it is put in an appropriate wrapper class instance. | |
| 88 | + | |
| 89 | + checksOK(p0, p1); | |
| 90 | + | |
| 91 | + # | |
| 92 | + # Need to figure out what kind of an array this is, then get the | |
| 93 | + # requested element and convert it to an appropriate JObject. | |
| 94 | + # | |
| 95 | + (typ, elem) := GetArrayElement(p0, p1); | |
| 96 | + #(typ, elem) := jni->GetArrayElement(p0, p1); | |
| 97 | + | |
| 98 | + if ( typ == 0 ) # array of Objects. good. | |
| 99 | + return elem.Object(); | |
| 100 | + | |
| 101 | + if ( typ >= JNI->T_BOOLEAN && typ <= JNI->T_LONG ) | |
| 102 | + return refl->ValueToObject(elem); | |
| 103 | + | |
| 104 | + return nil; | |
| 105 | +}#<< | |
| 106 | + | |
| 107 | +getBoolean_rObject_I_Z( p0 : JObject,p1 : int) : int | |
| 108 | +{#>> | |
| 109 | + # p0 - a Java object, which must be an array, else exception occurs. | |
| 110 | + # p1 - an index into the array, >= 0 and < length of array | |
| 111 | + # Returns the element at that index as a boolean value. If the array | |
| 112 | + # is not an array of something that can be converted to a boolean by | |
| 113 | + # widening (and for boolean that's nothing), then getprim will throw | |
| 114 | + # an exception. | |
| 115 | + | |
| 116 | + return getprim(p0, p1, JNI->T_BOOLEAN, "boolean").Boolean(); | |
| 117 | +}#<< | |
| 118 | + | |
| 119 | +getByte_rObject_I_B( p0 : JObject,p1 : int) : int | |
| 120 | +{#>> | |
| 121 | + # See comments in getBoolean_rObject_I_Z, above | |
| 122 | + | |
| 123 | + return getprim(p0, p1, JNI->T_BYTE, "byte").Byte(); | |
| 124 | +}#<< | |
| 125 | + | |
| 126 | +getChar_rObject_I_C( p0 : JObject,p1 : int) : int | |
| 127 | +{#>> | |
| 128 | + # See comments in getBoolean_rObject_I_Z, above | |
| 129 | + | |
| 130 | + return getprim(p0, p1, JNI->T_CHAR, "char").Char(); | |
| 131 | +}#<< | |
| 132 | + | |
| 133 | +getShort_rObject_I_S( p0 : JObject,p1 : int) : int | |
| 134 | +{#>> | |
| 135 | + # See comments in getBoolean_rObject_I_Z, above | |
| 136 | + | |
| 137 | + return getprim(p0, p1, JNI->T_SHORT, "short").Short(); | |
| 138 | +}#<< | |
| 139 | + | |
| 140 | +getInt_rObject_I_I( p0 : JObject,p1 : int) : int | |
| 141 | +{#>> | |
| 142 | + # See comments in getBoolean_rObject_I_Z, above | |
| 143 | + | |
| 144 | + return getprim(p0, p1, JNI->T_INT, "int").Int(); | |
| 145 | +}#<< | |
| 146 | + | |
| 147 | +getLong_rObject_I_J( p0 : JObject,p1 : int) : big | |
| 148 | +{#>> | |
| 149 | + # See comments in getBoolean_rObject_I_Z, above | |
| 150 | + | |
| 151 | + return getprim(p0, p1, JNI->T_LONG, "long").Long(); | |
| 152 | +}#<< | |
| 153 | + | |
| 154 | +getFloat_rObject_I_F( p0 : JObject,p1 : int) : real | |
| 155 | +{#>> | |
| 156 | + # See comments in getBoolean_rObject_I_Z, above | |
| 157 | + | |
| 158 | + return getprim(p0, p1, JNI->T_FLOAT, "float").Float(); | |
| 159 | +}#<< | |
| 160 | + | |
| 161 | +getDouble_rObject_I_D( p0 : JObject,p1 : int) : real | |
| 162 | +{#>> | |
| 163 | + # See comments in getBoolean_rObject_I_Z, above | |
| 164 | + | |
| 165 | + return getprim(p0, p1, JNI->T_DOUBLE, "double").Double(); | |
| 166 | +}#<< | |
| 167 | + | |
| 168 | +set_rObject_I_rObject_V( p0 : JObject,p1 : int,p2 : JObject) | |
| 169 | +{#>> | |
| 170 | + # p0 - a Java array. If null or not an array, exception. | |
| 171 | + # p1 - index into the array. If < 0 or >= length of array, exception. | |
| 172 | + # p2 - a value to put into the array at the specified index. If p0 is | |
| 173 | + # an array of JObject, p2 must be an instance of the appropriate | |
| 174 | + # class. If p0 is an array of a primitive Java type, then p2 must | |
| 175 | + # be a wrapper of a primitive type that can be converted to the | |
| 176 | + # the array's type by widening. | |
| 177 | + | |
| 178 | + checksOK(p0, p1); | |
| 179 | + | |
| 180 | + objarray := cast->ToJArray(p0); | |
| 181 | + typ := objarray.primitive; | |
| 182 | + if ( typ == 0 ) { # an Object array | |
| 183 | + if ( jni->IsInstanceOf(p2, objarray.class) == JNI->TRUE ) { | |
| 184 | + cast->JArrayToObject(objarray).ary[p1] = p2; | |
| 185 | + return; | |
| 186 | + } | |
| 187 | + } | |
| 188 | + else if ( typ >= JNI->T_BOOLEAN && typ <= JNI->T_LONG ) { | |
| 189 | + (stype, val) := refl->GetVal(p2); | |
| 190 | + if ( stype != 0 && (val = widen(stype, typ, val)) != nil ) { | |
| 191 | + SetArrayElement(p0, p1, val); | |
| 192 | + return; | |
| 193 | + } | |
| 194 | + } | |
| 195 | + jni->ThrowException(illegalarg, "Argument can't be cast to array element"); | |
| 196 | +}#<< | |
| 197 | + | |
| 198 | +setBoolean_rObject_I_Z_V( p0 : JObject,p1 : int,p2 : int) | |
| 199 | +{#>> | |
| 200 | + # p0[p1] = p2 | |
| 201 | + # where p2 is a boolean value, and it must be possible to convert it by | |
| 202 | + # widening to the type array p0. | |
| 203 | + | |
| 204 | + putprim(p0, p1, JNI->T_BOOLEAN, "boolean", ref Value.TBoolean(p2)); | |
| 205 | +}#<< | |
| 206 | + | |
| 207 | +setByte_rObject_I_B_V( p0 : JObject,p1 : int,p2 : int) | |
| 208 | +{#>> | |
| 209 | + # see comments for setBoolean_rObject_I_Z_V, above. | |
| 210 | + | |
| 211 | + putprim(p0, p1, JNI->T_BYTE, "byte", ref Value.TByte(p2)); | |
| 212 | +}#<< | |
| 213 | + | |
| 214 | +setChar_rObject_I_C_V( p0 : JObject,p1 : int,p2 : int) | |
| 215 | +{#>> | |
| 216 | + # see comments for setBoolean_rObject_I_Z_V, above. | |
| 217 | + | |
| 218 | + putprim(p0, p1, JNI->T_CHAR, "char", ref Value.TChar(p2)); | |
| 219 | +}#<< | |
| 220 | + | |
| 221 | +setShort_rObject_I_S_V( p0 : JObject,p1 : int,p2 : int) | |
| 222 | +{#>> | |
| 223 | + # see comments for setBoolean_rObject_I_Z_V, above. | |
| 224 | + | |
| 225 | + putprim(p0, p1, JNI->T_SHORT, "short", ref Value.TShort(p2)); | |
| 226 | +}#<< | |
| 227 | + | |
| 228 | +setInt_rObject_I_I_V( p0 : JObject,p1 : int,p2 : int) | |
| 229 | +{#>> | |
| 230 | + # see comments for setBoolean_rObject_I_Z_V, above. | |
| 231 | + | |
| 232 | + putprim(p0, p1, JNI->T_INT, "int", ref Value.TInt(p2)); | |
| 233 | +}#<< | |
| 234 | + | |
| 235 | +setLong_rObject_I_J_V( p0 : JObject,p1 : int,p2 : big) | |
| 236 | +{#>> | |
| 237 | + # see comments for setBoolean_rObject_I_Z_V, above. | |
| 238 | + | |
| 239 | + putprim(p0, p1, JNI->T_LONG, "long", ref Value.TLong(p2)); | |
| 240 | +}#<< | |
| 241 | + | |
| 242 | +setFloat_rObject_I_F_V( p0 : JObject,p1 : int,p2 : real) | |
| 243 | +{#>> | |
| 244 | + # see comments for setBoolean_rObject_I_Z_V, above. | |
| 245 | + | |
| 246 | + putprim(p0, p1, JNI->T_FLOAT, "float", ref Value.TFloat(p2)); | |
| 247 | +}#<< | |
| 248 | + | |
| 249 | +setDouble_rObject_I_D_V( p0 : JObject,p1 : int,p2 : real) | |
| 250 | +{#>> | |
| 251 | + # see comments for setBoolean_rObject_I_Z_V, above. | |
| 252 | + | |
| 253 | + putprim(p0, p1, JNI->T_DOUBLE, "double", ref Value.TDouble(p2)); | |
| 254 | +}#<< | |
| 255 | + | |
| 256 | +newArray(jclass: JClass, bounds: array of int): JObject | |
| 257 | +{ | |
| 258 | + # Create a Java array whose components belong to class jclass. | |
| 259 | + # jclass may be a class object representing a primitive type. | |
| 260 | + # bounds gives the length of each dimension. | |
| 261 | + | |
| 262 | + dims := len bounds; | |
| 263 | + cldata: ClassData; | |
| 264 | + | |
| 265 | + # See if the class represents a primitive type. | |
| 266 | + typ := jni->PrimitiveIndex(jclass, 1); | |
| 267 | + | |
| 268 | + # If jclass represents an array, then component type of array | |
| 269 | + # being created is component type of jclass. | |
| 270 | + s := jclass.aryname; | |
| 271 | + if(s != nil) { | |
| 272 | + # count [s in aryname | |
| 273 | + n := 1; | |
| 274 | + while(s[n] == '[') | |
| 275 | + n++; | |
| 276 | + dims += n; | |
| 277 | + typ = refl->SigToType(s[n:]); | |
| 278 | + if(typ == 0) | |
| 279 | + cldata = jni->FindClass(s[n+1:len s - 1]); | |
| 280 | + } else if(typ == 0) { # jclass is not array and not primitive | |
| 281 | + cldata = jclass.class; | |
| 282 | + } | |
| 283 | + | |
| 284 | + return cast->FromJArray(jldr->multianewarray(dims, cldata, typ, bounds)); | |
| 285 | +} | |
| 286 | + | |
| 287 | +newArray_rClass_I_rObject( p0 : JClass,p1 : int) : JObject | |
| 288 | +{#>> | |
| 289 | + if ( p0 == nil ) | |
| 290 | + jni->ThrowException(nullptr, ""); | |
| 291 | + | |
| 292 | + return newArray(p0, array [1] of { p1 }); | |
| 293 | +}#<< | |
| 294 | + | |
| 295 | +multiNewArray_rClass_aI_rObject( p0 : JClass,p1 : JArrayI) : JObject | |
| 296 | +{#>> | |
| 297 | + if ( p0 == nil || p1 == nil ) | |
| 298 | + jni->ThrowException(nullptr, ""); | |
| 299 | + | |
| 300 | + ln := len p1.ary; | |
| 301 | + | |
| 302 | + if ( ln < 1 || ln > 255 ) | |
| 303 | + jni->ThrowException(illegalarg, "dimensions out of range [1,255]"); | |
| 304 | + | |
| 305 | + return newArray(p0, p1.ary); | |
| 306 | +}#<< | |
| 307 | + | |
| 308 | +# An argument verification routine for use by native methods. The | |
| 309 | +# first argument must be non-null, and a Java array. (These conditions | |
| 310 | +# are actually check by calling getLength_rObject.) The second | |
| 311 | +# argument must be a valid index into that array. There is no return | |
| 312 | +# value: if the conditions above are not met, an exception is thrown; | |
| 313 | +# hence the routine does not return in this case. A successful return | |
| 314 | +# indicates the arguments are O.K. | |
| 315 | +# | |
| 316 | +checksOK(o : JObject, ix : int) | |
| 317 | +{ | |
| 318 | + if ( ix >= getLength_rObject_I(o) || ix < 0 ) | |
| 319 | + jni->ThrowException(badindex, "Illegal index"); | |
| 320 | + return; | |
| 321 | +} | |
| 322 | +# | |
| 323 | +# Gets element 'index' of Java array 'o' and returns it as a ref Value | |
| 324 | +# of the type corresponding to Java type index 'want'. String 's' | |
| 325 | +# is used only in creating the exception message, and should correspond | |
| 326 | +# to 'want'. o must be non-null and refer to a Java array, index must | |
| 327 | +# within range, and the array must be of a primitive type that can | |
| 328 | +# be made into the requested type by a widening conversion. If any of | |
| 329 | +# these conditions are not met, an exception is thrown. | |
| 330 | +# | |
| 331 | +getprim( o : JObject, index : int, want : int, s : string) : ref Value | |
| 332 | +{ | |
| 333 | + checksOK(o, index); | |
| 334 | + | |
| 335 | + (typ, elem) := GetArrayElement(o, index); | |
| 336 | + if ( (wider := widen(typ, want, elem)) == nil ) { | |
| 337 | + if ( s != nil ) | |
| 338 | + jni->ThrowException(illegalarg, "Can't cast array element to " + s); | |
| 339 | + else | |
| 340 | + jni->ThrowException(illegalarg, "Can't cast array element"); | |
| 341 | + } | |
| 342 | + return wider; | |
| 343 | +} | |
| 344 | +# | |
| 345 | +# Sets element 'index' of Java array 'o' to the ref Value 'val' | |
| 346 | +# of the type corresponding to Java type index 'have'. String 's' | |
| 347 | +# is used only in creating the exception message, and should correspond | |
| 348 | +# to 'have'. o must be non-null and refer to a Java array, index must | |
| 349 | +# within range, and the array must be of a primitive type that can | |
| 350 | +# be made from the provided type by a widening conversion. If any of | |
| 351 | +# these conditions are not met, an exception is thrown. | |
| 352 | +# | |
| 353 | +putprim( o : JObject, index : int, have : int, s : string, val : ref Value) | |
| 354 | +{ | |
| 355 | + checksOK(o, index); | |
| 356 | + | |
| 357 | + typ := cast->ToJArray(o).primitive; | |
| 358 | + if ( (val = widen(have, typ, val)) == nil ) { | |
| 359 | + if ( s != nil ) | |
| 360 | + jni->ThrowException(illegalarg, | |
| 361 | + "Can't put input value into " + s + " array"); | |
| 362 | + else | |
| 363 | + jni->ThrowException(illegalarg, | |
| 364 | + "Can't put input value into array"); | |
| 365 | + } | |
| 366 | + SetArrayElement(o, index, val); | |
| 367 | + #jni->SetArrayElement(o, index, val); | |
| 368 | +} | |
| 369 | +# | |
| 370 | +# Get the element at index from the Java array o and return it in | |
| 371 | +# in an appropriate member of the Value union. | |
| 372 | +# The arguments should have been verified before calling this function. | |
| 373 | +# | |
| 374 | +GetArrayElement( o : JObject, index : int ) : (int, ref Value) | |
| 375 | +{ | |
| 376 | + a := cast->ToJArray(o); | |
| 377 | + val : ref Value; | |
| 378 | + case a.primitive { | |
| 379 | + 0 => | |
| 380 | + val = ref Value.TObject(cast->JArrayToObject(a).ary[index]); | |
| 381 | + JNI->T_BOOLEAN => | |
| 382 | + val = ref Value.TBoolean(int cast->JArrayToByte(a).ary[index]); | |
| 383 | + JNI->T_BYTE => | |
| 384 | + val = ref Value.TByte(int cast->JArrayToByte(a).ary[index]); | |
| 385 | + JNI->T_CHAR => | |
| 386 | + val = ref Value.TChar(cast->JArrayToInt(a).ary[index]); | |
| 387 | + JNI->T_SHORT => | |
| 388 | + val = ref Value.TShort(cast->JArrayToInt(a).ary[index]); | |
| 389 | + JNI->T_INT => | |
| 390 | + val = ref Value.TInt(cast->JArrayToInt(a).ary[index]); | |
| 391 | + JNI->T_LONG => | |
| 392 | + val = ref Value.TLong(cast->JArrayToBig(a).ary[index]); | |
| 393 | + JNI->T_FLOAT => | |
| 394 | + val = ref Value.TFloat(cast->JArrayToReal(a).ary[index]); | |
| 395 | + JNI->T_DOUBLE => | |
| 396 | + val = ref Value.TDouble(cast->JArrayToReal(a).ary[index]); | |
| 397 | + } | |
| 398 | + return (a.primitive, val); | |
| 399 | +} | |
| 400 | +# | |
| 401 | +# Set the element at index from the Java array o to 'val', | |
| 402 | +# The arguments should have been verified before calling this function. | |
| 403 | +# | |
| 404 | +SetArrayElement( o : JObject, index : int, val : ref Value) | |
| 405 | +{ | |
| 406 | + a := cast->ToJArray(o); | |
| 407 | + pick sw := val { | |
| 408 | + TBoolean => cast->JArrayToByte(a).ary[index] = byte sw.jboolean; | |
| 409 | + TByte => cast->JArrayToByte(a).ary[index] = byte sw.jbyte; | |
| 410 | + TChar => cast->JArrayToInt(a).ary[index] = sw.jchar; | |
| 411 | + TShort => cast->JArrayToInt(a).ary[index] = sw.jshort; | |
| 412 | + TInt => cast->JArrayToInt(a).ary[index] = sw.jint; | |
| 413 | + TLong => cast->JArrayToBig(a).ary[index] = sw.jlong; | |
| 414 | + TFloat => cast->JArrayToReal(a).ary[index] = sw.jfloat; | |
| 415 | + TDouble => cast->JArrayToReal(a).ary[index] = sw.jdouble; | |
| 416 | + } | |
| 417 | +} | |
| @@ -0,0 +1,33 @@ | ||
| 1 | +# javal v1.5 generated file: edit with care | |
| 2 | + | |
| 3 | +Array_L : module | |
| 4 | +{ | |
| 5 | + Array_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + }; | |
| 9 | + | |
| 10 | + init : fn( jni_p : JNI ); | |
| 11 | + getLength_rObject_I : fn( p0 : JObject) : int; | |
| 12 | + get_rObject_I_rObject : fn( p0 : JObject,p1 : int) : JObject; | |
| 13 | + getBoolean_rObject_I_Z : fn( p0 : JObject,p1 : int) : int; | |
| 14 | + getByte_rObject_I_B : fn( p0 : JObject,p1 : int) : int; | |
| 15 | + getChar_rObject_I_C : fn( p0 : JObject,p1 : int) : int; | |
| 16 | + getShort_rObject_I_S : fn( p0 : JObject,p1 : int) : int; | |
| 17 | + getInt_rObject_I_I : fn( p0 : JObject,p1 : int) : int; | |
| 18 | + getLong_rObject_I_J : fn( p0 : JObject,p1 : int) : big; | |
| 19 | + getFloat_rObject_I_F : fn( p0 : JObject,p1 : int) : real; | |
| 20 | + getDouble_rObject_I_D : fn( p0 : JObject,p1 : int) : real; | |
| 21 | + set_rObject_I_rObject_V : fn( p0 : JObject,p1 : int,p2 : JObject); | |
| 22 | + setBoolean_rObject_I_Z_V : fn( p0 : JObject,p1 : int,p2 : int); | |
| 23 | + setByte_rObject_I_B_V : fn( p0 : JObject,p1 : int,p2 : int); | |
| 24 | + setChar_rObject_I_C_V : fn( p0 : JObject,p1 : int,p2 : int); | |
| 25 | + setShort_rObject_I_S_V : fn( p0 : JObject,p1 : int,p2 : int); | |
| 26 | + setInt_rObject_I_I_V : fn( p0 : JObject,p1 : int,p2 : int); | |
| 27 | + setLong_rObject_I_J_V : fn( p0 : JObject,p1 : int,p2 : big); | |
| 28 | + setFloat_rObject_I_F_V : fn( p0 : JObject,p1 : int,p2 : real); | |
| 29 | + setDouble_rObject_I_D_V : fn( p0 : JObject,p1 : int,p2 : real); | |
| 30 | + newArray_rClass_I_rObject : fn( p0 : JClass,p1 : int) : JObject; | |
| 31 | + multiNewArray_rClass_aI_rObject : fn( p0 : JClass,p1 : JArrayI) : JObject; | |
| 32 | + | |
| 33 | +}; | |
Empty file added.
| @@ -0,0 +1,90 @@ | ||
| 1 | +implement Constructor_L; | |
| 2 | + | |
| 3 | +include "jni.m"; | |
| 4 | + jni : JNI; | |
| 5 | + ClassModule, | |
| 6 | + JString, | |
| 7 | + JArray, | |
| 8 | + JArrayI, | |
| 9 | + JArrayC, | |
| 10 | + JArrayB, | |
| 11 | + JArrayS, | |
| 12 | + JArrayJ, | |
| 13 | + JArrayF, | |
| 14 | + JArrayD, | |
| 15 | + JArrayZ, | |
| 16 | + JArrayJObject, | |
| 17 | + JArrayJClass, | |
| 18 | + JArrayJString, | |
| 19 | + JClass, | |
| 20 | + JObject : import jni; | |
| 21 | + | |
| 22 | +#>> extra pre includes here | |
| 23 | + | |
| 24 | + Value, | |
| 25 | + ClassData, | |
| 26 | + jldr : import jni; | |
| 27 | + | |
| 28 | + Object : import jldr; | |
| 29 | + | |
| 30 | +#<< | |
| 31 | + | |
| 32 | +include "Constructor_L.m"; | |
| 33 | + | |
| 34 | +#>> extra post includes here | |
| 35 | + | |
| 36 | +illegalarg := "java.lang.IllegalArgumentException"; | |
| 37 | +nullptr := "java.lang.NullPointerException"; | |
| 38 | + | |
| 39 | +include "reflect.m"; | |
| 40 | + refl : Reflect; | |
| 41 | + widen : import refl; | |
| 42 | + | |
| 43 | +#<< | |
| 44 | + | |
| 45 | +init( jni_p : JNI ) | |
| 46 | +{ | |
| 47 | + # save java native inteface mod instance | |
| 48 | + jni = jni_p; | |
| 49 | + #>>extra initialization here | |
| 50 | + refl = load Reflect Reflect->PATH; | |
| 51 | + if ( refl == nil ) | |
| 52 | + jni->InitError( jni->sys->sprint( "java.lang.reflect.Constructor: could not load %s: %r", Reflect->PATH ) ); | |
| 53 | + else | |
| 54 | + refl->init(jni); | |
| 55 | + #<< | |
| 56 | +} | |
| 57 | + | |
| 58 | +getModifiers_I( this : ref Constructor_obj) : int | |
| 59 | +{#>> | |
| 60 | + # | |
| 61 | + # Assume that lower part of slot has modifier bits. | |
| 62 | + # | |
| 63 | + return this.slot & 16rffff; | |
| 64 | +}#<< | |
| 65 | + | |
| 66 | +newInstance_aObject_rObject( this : ref Constructor_obj, p0 : JArrayJObject) : JObject | |
| 67 | +{#>> | |
| 68 | + # this - a Constructor object representing a constructor of some class | |
| 69 | + # p0 - a Java array of Objects, containing argument values for the | |
| 70 | + # the constructor | |
| 71 | + # Returns a new instance, constructed by the 'this' constructor. | |
| 72 | + # | |
| 73 | + # Check inputs and build the argument list. | |
| 74 | + # | |
| 75 | + args := refl->BuildArgList(this.parameterTypes, p0); | |
| 76 | + # | |
| 77 | + # Allocate a new object, then do the call. | |
| 78 | + # | |
| 79 | + newobj := jni->AllocObject(this.clazz.class); | |
| 80 | + | |
| 81 | + # Eventually may be able to do something like | |
| 82 | + # (result, ok) = jni->CallConstruct(newobj, this.slot, args); | |
| 83 | + | |
| 84 | + fld := this.clazz.class.initmethods[this.slot >> 16]; | |
| 85 | + (nil, ok) := jni->CallMethod(newobj, fld.field, fld.signature, args); | |
| 86 | + | |
| 87 | + if ( ok == JNI->OK ) | |
| 88 | + return newobj; | |
| 89 | + return nil; | |
| 90 | +}#<< | |
| @@ -0,0 +1,18 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +Constructor_L : module | |
| 4 | +{ | |
| 5 | + Constructor_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + clazz : JClass; | |
| 9 | + slot : int; | |
| 10 | + parameterTypes : JArrayJClass; | |
| 11 | + exceptionTypes : JArrayJClass; | |
| 12 | + }; | |
| 13 | + | |
| 14 | + init : fn( jni_p : JNI ); | |
| 15 | + getModifiers_I : fn( this : ref Constructor_obj) : int; | |
| 16 | + newInstance_aObject_rObject : fn( this : ref Constructor_obj, p0 : JArrayJObject) : JObject; | |
| 17 | + | |
| 18 | +}; | |
Empty file added.
| @@ -0,0 +1,469 @@ | ||
| 1 | +implement Field_L; | |
| 2 | + | |
| 3 | +# javal v1.5 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | + Value, | |
| 28 | + ClassData : import jni; | |
| 29 | + jldr : JavaClassLoader; | |
| 30 | + Object, | |
| 31 | + Class : import jldr; | |
| 32 | + | |
| 33 | +#<< | |
| 34 | + | |
| 35 | +include "Field_L.m"; | |
| 36 | + | |
| 37 | +#>> extra post includes here | |
| 38 | + | |
| 39 | +include "reflect.m"; | |
| 40 | + refl : Reflect; | |
| 41 | + | |
| 42 | +STATIC, NONSTATIC : con iota; | |
| 43 | + | |
| 44 | +illegalacc, | |
| 45 | +illegalarg, | |
| 46 | +nullptr : string; | |
| 47 | + | |
| 48 | +#<< | |
| 49 | + | |
| 50 | +init( jni_p : JNI ) | |
| 51 | +{ | |
| 52 | + # save java native inteface mod instance | |
| 53 | + jni = jni_p; | |
| 54 | + #>>extra initialization here | |
| 55 | + jldr = jni->jldr; | |
| 56 | + | |
| 57 | + illegalacc = "java.lang.IllegalAccessException"; | |
| 58 | + illegalarg = "java.lang.IllegalArgumentException"; | |
| 59 | + nullptr = "java.lang.NullPointerException"; | |
| 60 | + | |
| 61 | + refl = load Reflect Reflect->PATH; | |
| 62 | + if ( refl == nil ) | |
| 63 | + jni->InitError( jni->sys->sprint( "java.lang.reflect.Field: could not load %s: %r", Reflect->PATH ) ); | |
| 64 | + else | |
| 65 | + refl->init(jni); | |
| 66 | + | |
| 67 | + #<< | |
| 68 | +} | |
| 69 | + | |
| 70 | +getModifiers_I( this : ref Field_obj) : int | |
| 71 | +{#>> | |
| 72 | + # | |
| 73 | + # Assume that lower part of slot points has modifier bits. | |
| 74 | + # | |
| 75 | + return this.slot & 16rffff; | |
| 76 | +}#<< | |
| 77 | + | |
| 78 | +get_rObject_rObject( this : ref Field_obj, p0 : JObject) : JObject | |
| 79 | +{#>> | |
| 80 | + val := getChecks(this, p0); | |
| 81 | + | |
| 82 | + typ := refl->ValType(val); | |
| 83 | + | |
| 84 | + if ( typ == 0 ) # array of Objects. good. | |
| 85 | + return val.Object(); | |
| 86 | + | |
| 87 | + if ( typ >= JNI->T_BOOLEAN && typ <= JNI->T_LONG ) | |
| 88 | + return refl->ValueToObject(val); | |
| 89 | + return nil; | |
| 90 | +}#<< | |
| 91 | + | |
| 92 | +getBoolean_rObject_Z( this : ref Field_obj, p0 : JObject) : int | |
| 93 | +{#>> | |
| 94 | + val := getChecks(this, p0); | |
| 95 | + | |
| 96 | + pick sw := val { | |
| 97 | + TBoolean => return sw.jboolean; | |
| 98 | + } | |
| 99 | + jni->ThrowException(illegalarg, "Can't convert to boolean"); | |
| 100 | + return JNI->FALSE; | |
| 101 | +}#<< | |
| 102 | + | |
| 103 | +getByte_rObject_B( this : ref Field_obj, p0 : JObject) : int | |
| 104 | +{#>> | |
| 105 | + val := getChecks(this, p0); | |
| 106 | + | |
| 107 | + pick sw := val { | |
| 108 | + TByte => return sw.jbyte; | |
| 109 | + } | |
| 110 | + jni->ThrowException(illegalarg, "Can't convert to byte"); | |
| 111 | + return JNI->FALSE; | |
| 112 | +}#<< | |
| 113 | + | |
| 114 | +getChar_rObject_C( this : ref Field_obj, p0 : JObject) : int | |
| 115 | +{#>> | |
| 116 | + val := getChecks(this, p0); | |
| 117 | + | |
| 118 | + pick sw := val { | |
| 119 | + TChar => return sw.jchar; | |
| 120 | + } | |
| 121 | + jni->ThrowException(illegalarg, "Can't convert to char"); | |
| 122 | + return 0; | |
| 123 | +}#<< | |
| 124 | + | |
| 125 | +getShort_rObject_S( this : ref Field_obj, p0 : JObject) : int | |
| 126 | +{#>> | |
| 127 | + val := getChecks(this, p0); | |
| 128 | + | |
| 129 | + pick sw := val { | |
| 130 | + TByte => return int sw.jbyte; | |
| 131 | + TShort => return sw.jshort; | |
| 132 | + } | |
| 133 | + jni->ThrowException(illegalarg, "Can't convert to short"); | |
| 134 | + return 0; | |
| 135 | +}#<< | |
| 136 | + | |
| 137 | +getInt_rObject_I( this : ref Field_obj, p0 : JObject) : int | |
| 138 | +{#>> | |
| 139 | + val := getChecks(this, p0); | |
| 140 | + | |
| 141 | + pick sw := val { | |
| 142 | + TByte => return int sw.jbyte; | |
| 143 | + TChar => return sw.jchar; | |
| 144 | + TShort => return sw.jshort; | |
| 145 | + TInt => return sw.jint; | |
| 146 | + } | |
| 147 | + jni->ThrowException(illegalarg, "Can't convert to int"); | |
| 148 | + return 0; | |
| 149 | +}#<< | |
| 150 | + | |
| 151 | +getLong_rObject_J( this : ref Field_obj, p0 : JObject) : big | |
| 152 | +{#>> | |
| 153 | + val := getChecks(this, p0); | |
| 154 | + | |
| 155 | + pick sw := val { | |
| 156 | + TByte => return big sw.jbyte; | |
| 157 | + TChar => return big sw.jchar; | |
| 158 | + TShort => return big sw.jshort; | |
| 159 | + TInt => return big sw.jint; | |
| 160 | + TLong => return sw.jlong; | |
| 161 | + } | |
| 162 | + jni->ThrowException(illegalarg, "Can't convert to long"); | |
| 163 | + return big 0; | |
| 164 | +}#<< | |
| 165 | + | |
| 166 | +getFloat_rObject_F( this : ref Field_obj, p0 : JObject) : real | |
| 167 | +{#>> | |
| 168 | + val := getChecks(this, p0); | |
| 169 | + | |
| 170 | + pick sw := val { | |
| 171 | + TByte => return real sw.jbyte; | |
| 172 | + TChar => return real sw.jchar; | |
| 173 | + TShort => return real sw.jshort; | |
| 174 | + TInt => return real sw.jint; | |
| 175 | + TLong => return real sw.jlong; | |
| 176 | + TFloat => return sw.jfloat; | |
| 177 | + } | |
| 178 | + jni->ThrowException(illegalarg, "Can't convert to float"); | |
| 179 | + return 0.0; | |
| 180 | +}#<< | |
| 181 | + | |
| 182 | +getDouble_rObject_D( this : ref Field_obj, p0 : JObject) : real | |
| 183 | +{#>> | |
| 184 | + val := getChecks(this, p0); | |
| 185 | + | |
| 186 | + pick sw := val { | |
| 187 | + TByte => return real sw.jbyte; | |
| 188 | + TChar => return real sw.jchar; | |
| 189 | + TShort => return real sw.jshort; | |
| 190 | + TInt => return real sw.jint; | |
| 191 | + TLong => return real sw.jlong; | |
| 192 | + TFloat => return sw.jfloat; | |
| 193 | + TDouble => return sw.jdouble; | |
| 194 | + } | |
| 195 | + jni->ThrowException(illegalarg, "Can't convert to double"); | |
| 196 | + return 0.0; | |
| 197 | +}#<< | |
| 198 | + | |
| 199 | +set_rObject_rObject_V( this : ref Field_obj, p0 : JObject,p1 : JObject) | |
| 200 | +{#>> | |
| 201 | + want := putChecks(this, p0); | |
| 202 | + clazz := jni->GetObjectClass(p1); | |
| 203 | + | |
| 204 | + if ( want == 0 ) { # field value is Object | |
| 205 | + p := ref Value.TObject; | |
| 206 | + if ( jni->IsAssignable(clazz, this.clazz) == JNI->TRUE ) { | |
| 207 | + p.jobj = p1; | |
| 208 | + SetField(this, p0, p); | |
| 209 | + return; | |
| 210 | + } | |
| 211 | + else { | |
| 212 | + jni->ThrowException(illegalarg, "Can't safely cast"); | |
| 213 | + return; | |
| 214 | + } | |
| 215 | + } | |
| 216 | + # The field is a primitive type. Then p1 better be a wrapper for that | |
| 217 | + # type. (Or is it okay if it's a wrapper for something that can be | |
| 218 | + # safely cast to the target type?) | |
| 219 | + # | |
| 220 | + # is p1 a Boolean object, or sub-classed from a Boolean object, | |
| 221 | + # or a String with value "true" or "false" ? | |
| 222 | + # | |
| 223 | + (typ, val) := refl->GetVal(p1); | |
| 224 | + if ( typ == 0 || (val = refl->widen(typ, want, val)) == nil ) { | |
| 225 | + jni->ThrowException(illegalarg, "Object can't be cast to needed type"); | |
| 226 | + return; | |
| 227 | + } | |
| 228 | + SetField(this, p0, val); | |
| 229 | + return; | |
| 230 | +}#<< | |
| 231 | + | |
| 232 | +setBoolean_rObject_Z_V( this : ref Field_obj, p0 : JObject,p1 : int) | |
| 233 | +{#>> | |
| 234 | + want := putChecks(this, p0); | |
| 235 | + | |
| 236 | +# | |
| 237 | +# Note that if the field's signature is "Ljava.lang.Boolean;", | |
| 238 | +# we could create an appropriate Object and assign it. | |
| 239 | +# But it isn't clear if that is what's wanted. | |
| 240 | +# A similar argument applies for the other set<Type> functions. | |
| 241 | +# | |
| 242 | + p : ref Value; | |
| 243 | + case want { | |
| 244 | + JNI->T_BOOLEAN => p = ref Value.TBoolean(p1); | |
| 245 | + * => | |
| 246 | + jni->ThrowException(illegalarg, "Can't convert from boolean"); | |
| 247 | + return; | |
| 248 | + } | |
| 249 | + SetField(this, p0, p); | |
| 250 | +}#<< | |
| 251 | + | |
| 252 | +setByte_rObject_B_V( this : ref Field_obj, p0 : JObject,p1 : int) | |
| 253 | +{#>> | |
| 254 | + want := putChecks(this, p0); | |
| 255 | + | |
| 256 | + p : ref Value; | |
| 257 | + case want { | |
| 258 | + JNI->T_BYTE => p = ref Value.TByte(p1); | |
| 259 | + JNI->T_SHORT => p = ref Value.TShort(int p1); | |
| 260 | + JNI->T_INT => p = ref Value.TInt(int p1); | |
| 261 | + JNI->T_LONG => p = ref Value.TLong(big p1); | |
| 262 | + JNI->T_FLOAT => p = ref Value.TFloat(real p1); | |
| 263 | + JNI->T_DOUBLE => p = ref Value.TDouble(real p1); | |
| 264 | + * => | |
| 265 | + jni->ThrowException(illegalarg, "Can't convert from byte"); | |
| 266 | + return; | |
| 267 | + } | |
| 268 | + SetField(this, p0, p); | |
| 269 | +}#<< | |
| 270 | + | |
| 271 | +setChar_rObject_C_V( this : ref Field_obj, p0 : JObject,p1 : int) | |
| 272 | +{#>> | |
| 273 | + want := putChecks(this, p0); | |
| 274 | + | |
| 275 | + p : ref Value; | |
| 276 | + case want { | |
| 277 | + JNI->T_CHAR => p = ref Value.TChar(p1); | |
| 278 | + * => | |
| 279 | + jni->ThrowException(illegalarg, "Can't convert from char"); | |
| 280 | + return; | |
| 281 | + } | |
| 282 | + SetField(this, p0, p); | |
| 283 | +}#<< | |
| 284 | + | |
| 285 | +setShort_rObject_S_V( this : ref Field_obj, p0 : JObject,p1 : int) | |
| 286 | +{#>> | |
| 287 | + want := putChecks(this, p0); | |
| 288 | + | |
| 289 | + p : ref Value; | |
| 290 | + case want { | |
| 291 | + JNI->T_SHORT => p = ref Value.TShort(p1); | |
| 292 | + JNI->T_INT => p = ref Value.TInt(p1); | |
| 293 | + JNI->T_LONG => p = ref Value.TLong(big p1); | |
| 294 | + JNI->T_FLOAT => p = ref Value.TFloat(real p1); | |
| 295 | + JNI->T_DOUBLE => p = ref Value.TDouble(real p1); | |
| 296 | + * => | |
| 297 | + jni->ThrowException(illegalarg, "Can't convert from short"); | |
| 298 | + return; | |
| 299 | + } | |
| 300 | + SetField(this, p0, p); | |
| 301 | +}#<< | |
| 302 | + | |
| 303 | +setInt_rObject_I_V( this : ref Field_obj, p0 : JObject,p1 : int) | |
| 304 | +{#>> | |
| 305 | + want := putChecks(this, p0); | |
| 306 | + | |
| 307 | + p : ref Value; | |
| 308 | + case want { | |
| 309 | + JNI->T_INT => p = ref Value.TInt(p1); | |
| 310 | + JNI->T_LONG => p = ref Value.TLong(big p1); | |
| 311 | + JNI->T_FLOAT => p = ref Value.TFloat(real p1); | |
| 312 | + JNI->T_DOUBLE => p = ref Value.TDouble(real p1); | |
| 313 | + * => | |
| 314 | + jni->ThrowException(illegalarg, "Can't convert from int"); | |
| 315 | + return; | |
| 316 | + } | |
| 317 | + SetField(this, p0, p); | |
| 318 | +}#<< | |
| 319 | + | |
| 320 | +setLong_rObject_J_V( this : ref Field_obj, p0 : JObject,p1 : big) | |
| 321 | +{#>> | |
| 322 | + want := putChecks(this, p0); | |
| 323 | + | |
| 324 | + p : ref Value; | |
| 325 | + case want { | |
| 326 | + JNI->T_LONG => p = ref Value.TLong(p1); | |
| 327 | + JNI->T_FLOAT => p = ref Value.TFloat(real p1); | |
| 328 | + JNI->T_DOUBLE => p = ref Value.TDouble(real p1); | |
| 329 | + * => | |
| 330 | + jni->ThrowException(illegalarg, "Can't convert from long"); | |
| 331 | + return; | |
| 332 | + } | |
| 333 | + SetField(this, p0, p); | |
| 334 | +}#<< | |
| 335 | + | |
| 336 | +setFloat_rObject_F_V( this : ref Field_obj, p0 : JObject,p1 : real) | |
| 337 | +{#>> | |
| 338 | + want := putChecks(this, p0); | |
| 339 | + | |
| 340 | + p : ref Value; | |
| 341 | + case want { | |
| 342 | + JNI->T_FLOAT => p = ref Value.TFloat(p1); | |
| 343 | + JNI->T_DOUBLE => p = ref Value.TDouble(p1); | |
| 344 | + * => | |
| 345 | + jni->ThrowException(illegalarg, "Can't convert from float"); | |
| 346 | + return; | |
| 347 | + } | |
| 348 | + SetField(this, p0, p); | |
| 349 | +}#<< | |
| 350 | + | |
| 351 | +setDouble_rObject_D_V( this : ref Field_obj, p0 : JObject,p1 : real) | |
| 352 | +{#>> | |
| 353 | + want := putChecks(this, p0); | |
| 354 | + | |
| 355 | + p : ref Value; | |
| 356 | + case want { | |
| 357 | + JNI->T_DOUBLE => p = ref Value.TDouble(p1); | |
| 358 | + * => | |
| 359 | + jni->ThrowException(illegalarg, "Can't convert from double"); | |
| 360 | + return; | |
| 361 | + } | |
| 362 | + SetField(this, p0, p); | |
| 363 | +}#<< | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | +getChecks( this : ref Field_obj, p0 : JObject) : ref Value | |
| 368 | +{ | |
| 369 | + if ( (this.slot & jldr->ACC_STATIC) == 0 && p0 == nil ) | |
| 370 | + jni->ThrowException(nullptr, "reading field of null Object"); | |
| 371 | + | |
| 372 | + # See if the target object is the same as the one declaring the field. | |
| 373 | + # this.clazz.class_data is ref to a classloader.Class adt | |
| 374 | + | |
| 375 | + cldata := this.clazz.class; | |
| 376 | + if ( (this.slot & jldr->ACC_STATIC) == 0 && jni->IsInstanceOf(p0, cldata) != JNI->TRUE ) { | |
| 377 | + jni->ThrowException(illegalarg, | |
| 378 | + "Object is not an instance of this class"); | |
| 379 | + return nil; | |
| 380 | + } | |
| 381 | + | |
| 382 | + if ( (this.slot & jldr->ACC_PUBLIC) == 0 ) | |
| 383 | + jni->ThrowException(illegalacc, "reading non-public field"); | |
| 384 | + | |
| 385 | + if ( this.slot & jldr->ACC_STATIC ) | |
| 386 | + return GetStat(cldata, this.slot); | |
| 387 | + else | |
| 388 | + return GetField(p0, this.slot); | |
| 389 | +} | |
| 390 | + | |
| 391 | +putChecks( this : ref Field_obj, p0 : JObject) : int | |
| 392 | +{ | |
| 393 | + if ( (this.slot & jldr->ACC_STATIC) == 0 && p0 == nil ) | |
| 394 | + jni->ThrowException(nullptr, "writing field of null Object"); | |
| 395 | + | |
| 396 | + # See if the target object is the same as the one declaring the field. | |
| 397 | + # this.clazz.class_data is ref to a classloader.Class adt | |
| 398 | + | |
| 399 | + cldata := this.clazz.class; | |
| 400 | + if ( (this.slot & jldr->ACC_STATIC) == 0 && jni->IsInstanceOf(p0, cldata) != JNI->TRUE ) { | |
| 401 | + jni->ThrowException(illegalarg, | |
| 402 | + "Object is not an instance of this class"); | |
| 403 | + return 0; | |
| 404 | + } | |
| 405 | + | |
| 406 | + if ( (this.slot & jldr->ACC_PUBLIC) == 0 || (this.slot & jldr->ACC_FINAL) != 0 ) | |
| 407 | + jni->ThrowException(illegalacc, "writing non-public or final field"); | |
| 408 | + | |
| 409 | + if ( this.slot & jldr->ACC_STATIC ) | |
| 410 | + return refl->SigToType(cldata.staticdata[this.slot >> 16].signature); | |
| 411 | + else { | |
| 412 | + flds := cldata.objectdata; | |
| 413 | + for ( i := (this.slot >> 16); i > 0; i--) | |
| 414 | + flds = tl flds; | |
| 415 | + return refl->SigToType((hd flds).signature); | |
| 416 | + } | |
| 417 | + return 0; | |
| 418 | +} | |
| 419 | + | |
| 420 | +checkMemberAccess(which : int) | |
| 421 | +{ | |
| 422 | + return; | |
| 423 | +} | |
| 424 | + | |
| 425 | +SetField(this : ref Field_obj, o : JObject, v : ref Value) | |
| 426 | +{ | |
| 427 | + cldata := this.clazz.class; | |
| 428 | + if ( (this.slot & jldr->ACC_STATIC) != 0 ) { | |
| 429 | + fld := cldata.staticdata[this.slot >> 16]; | |
| 430 | + jni->SetStaticField(cldata, fld.field, v); | |
| 431 | + } | |
| 432 | + else { | |
| 433 | + flds := cldata.objectdata; | |
| 434 | + for ( i := (this.slot >> 16); i > 0; i-- ) | |
| 435 | + flds = tl flds; | |
| 436 | + fld := hd flds; | |
| 437 | + jni->SetObjField(o, fld.field, v); | |
| 438 | + } | |
| 439 | +} | |
| 440 | + | |
| 441 | +widen(have, want : string, val : ref Value) : ref Value | |
| 442 | +{ | |
| 443 | + if ( have == want ) | |
| 444 | + return val; | |
| 445 | + havetype := refl->SigToType(have); | |
| 446 | + wanttype := refl->SigToType(want); | |
| 447 | + return refl->widen(havetype, wanttype, val); | |
| 448 | +} | |
| 449 | +# | |
| 450 | +# Eventually JNI may provide a funtions to do this more directly. | |
| 451 | +# | |
| 452 | +GetStat(cldata : ClassData, slot : int) : ref Value | |
| 453 | +{ | |
| 454 | + fld := cldata.staticdata[slot >> 16]; | |
| 455 | + return jni->GetStaticField(cldata, fld.field, fld.signature); | |
| 456 | +} | |
| 457 | +# | |
| 458 | +# Eventually JNI may provide a funtions to do this more directly. | |
| 459 | +# It would probably know what to do about privatemethods, if anything. | |
| 460 | +# | |
| 461 | +GetField(obj : JObject, slot : int) : ref Value | |
| 462 | +{ | |
| 463 | + flds := obj.class().objectdata; | |
| 464 | + for ( i := (slot >> 16); i > 0; i-- ) | |
| 465 | + flds = tl flds; | |
| 466 | + fld := hd flds; | |
| 467 | + return jni->GetObjField(obj, fld.field, fld.signature); | |
| 468 | +} | |
| 469 | + | |
| @@ -0,0 +1,35 @@ | ||
| 1 | +# javal v1.5 generated file: edit with care | |
| 2 | + | |
| 3 | +Field_L : module | |
| 4 | +{ | |
| 5 | + Field_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + clazz : JClass; | |
| 9 | + slot : int; | |
| 10 | + name : JString; | |
| 11 | + type_j : JClass; | |
| 12 | + }; | |
| 13 | + | |
| 14 | + init : fn( jni_p : JNI ); | |
| 15 | + getModifiers_I : fn( this : ref Field_obj) : int; | |
| 16 | + get_rObject_rObject : fn( this : ref Field_obj, p0 : JObject) : JObject; | |
| 17 | + getBoolean_rObject_Z : fn( this : ref Field_obj, p0 : JObject) : int; | |
| 18 | + getByte_rObject_B : fn( this : ref Field_obj, p0 : JObject) : int; | |
| 19 | + getChar_rObject_C : fn( this : ref Field_obj, p0 : JObject) : int; | |
| 20 | + getShort_rObject_S : fn( this : ref Field_obj, p0 : JObject) : int; | |
| 21 | + getInt_rObject_I : fn( this : ref Field_obj, p0 : JObject) : int; | |
| 22 | + getLong_rObject_J : fn( this : ref Field_obj, p0 : JObject) : big; | |
| 23 | + getFloat_rObject_F : fn( this : ref Field_obj, p0 : JObject) : real; | |
| 24 | + getDouble_rObject_D : fn( this : ref Field_obj, p0 : JObject) : real; | |
| 25 | + set_rObject_rObject_V : fn( this : ref Field_obj, p0 : JObject,p1 : JObject); | |
| 26 | + setBoolean_rObject_Z_V : fn( this : ref Field_obj, p0 : JObject,p1 : int); | |
| 27 | + setByte_rObject_B_V : fn( this : ref Field_obj, p0 : JObject,p1 : int); | |
| 28 | + setChar_rObject_C_V : fn( this : ref Field_obj, p0 : JObject,p1 : int); | |
| 29 | + setShort_rObject_S_V : fn( this : ref Field_obj, p0 : JObject,p1 : int); | |
| 30 | + setInt_rObject_I_V : fn( this : ref Field_obj, p0 : JObject,p1 : int); | |
| 31 | + setLong_rObject_J_V : fn( this : ref Field_obj, p0 : JObject,p1 : big); | |
| 32 | + setFloat_rObject_F_V : fn( this : ref Field_obj, p0 : JObject,p1 : real); | |
| 33 | + setDouble_rObject_D_V : fn( this : ref Field_obj, p0 : JObject,p1 : real); | |
| 34 | + | |
| 35 | +}; | |
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,117 @@ | ||
| 1 | +implement Method_L; | |
| 2 | + | |
| 3 | +include "jni.m"; | |
| 4 | + jni : JNI; | |
| 5 | + ClassModule, | |
| 6 | + JString, | |
| 7 | + JArray, | |
| 8 | + JArrayI, | |
| 9 | + JArrayC, | |
| 10 | + JArrayB, | |
| 11 | + JArrayS, | |
| 12 | + JArrayJ, | |
| 13 | + JArrayF, | |
| 14 | + JArrayD, | |
| 15 | + JArrayZ, | |
| 16 | + JArrayJObject, | |
| 17 | + JArrayJClass, | |
| 18 | + JArrayJString, | |
| 19 | + JClass, | |
| 20 | + JObject : import jni; | |
| 21 | + | |
| 22 | +#>> extra pre includes here | |
| 23 | + | |
| 24 | + Value, | |
| 25 | + ClassData, | |
| 26 | + jldr : import jni; | |
| 27 | + | |
| 28 | + Object : import jldr; | |
| 29 | + | |
| 30 | +#<< | |
| 31 | + | |
| 32 | +include "Method_L.m"; | |
| 33 | + | |
| 34 | +#>> extra post includes here | |
| 35 | + | |
| 36 | +illegalarg := "java.lang.IllegalArgumentException"; | |
| 37 | +nullptr := "java.lang.NullPointerException"; | |
| 38 | + | |
| 39 | +include "reflect.m"; | |
| 40 | + refl : Reflect; | |
| 41 | + widen : import refl; | |
| 42 | + | |
| 43 | +#<< | |
| 44 | + | |
| 45 | +init( jni_p : JNI ) | |
| 46 | +{ | |
| 47 | + # save java native inteface mod instance | |
| 48 | + jni = jni_p; | |
| 49 | + #>>extra initialization here | |
| 50 | + refl = load Reflect Reflect->PATH; | |
| 51 | + if ( refl == nil ) | |
| 52 | + jni->InitError( jni->sys->sprint( "java.lang.reflect.Method: could not load %s: %r", Reflect->PATH ) ); | |
| 53 | + else | |
| 54 | + refl->init(jni); | |
| 55 | + #<< | |
| 56 | +} | |
| 57 | + | |
| 58 | +getModifiers_I( this : ref Method_obj) : int | |
| 59 | +{#>> | |
| 60 | + # | |
| 61 | + # Assume that lower part of slot has modifier bits. | |
| 62 | + # | |
| 63 | + return this.slot & 16rffff; | |
| 64 | +}#<< | |
| 65 | + | |
| 66 | +invoke_rObject_aObject_rObject( this : ref Method_obj, p0 : JObject,p1 : JArrayJObject) : JObject | |
| 67 | +{#>> | |
| 68 | + # this - a Method object. The corresponding method should be invoked for | |
| 69 | + # p0 - an Object which should contain that method, with | |
| 70 | + # p1 - a Java array of Objects that are the arguments to the method. | |
| 71 | + # Can be null if the method has no arguments. | |
| 72 | + # Returns an object reflecting the value returned by the method call. | |
| 73 | + # | |
| 74 | + # First do some checking. If 'this' is a static method, p0 is ignored, | |
| 75 | + # otherwise it must an instance of the class in which the method is | |
| 76 | + # declared. | |
| 77 | + # | |
| 78 | + if ( (this.slot & JNI->ACC_STATIC) == 0 ) { # not static | |
| 79 | + if ( p0 == nil ) | |
| 80 | + jni->ThrowException(nullptr, "Must supply an instance"); | |
| 81 | + if ( jni->IsInstanceOf(p0, this.clazz.class) == JNI->FALSE ) | |
| 82 | + jni->ThrowException(illegalarg, "Method not in object"); | |
| 83 | + } | |
| 84 | + # | |
| 85 | + # Check inputs and build the argument list. | |
| 86 | + # | |
| 87 | + args := refl->BuildArgList(this.parameterTypes, p1); | |
| 88 | + # | |
| 89 | + # Do the call. | |
| 90 | + # | |
| 91 | + result : ref Value; | |
| 92 | + ok : int; | |
| 93 | + if ( this.slot & JNI->ACC_STATIC ) { | |
| 94 | + fld := this.clazz.class.staticmethods[this.slot >> 16]; | |
| 95 | + (result, ok) = jni->CallStatic(this.clazz.class, fld.field, | |
| 96 | + fld.signature, args); | |
| 97 | + } | |
| 98 | + else { | |
| 99 | + fld : ref JavaClassLoader->Field; | |
| 100 | + if ( (this.slot & JNI->ACC_PRIVATE) != 0 ) | |
| 101 | + fld = p0.class().privatemethods[this.slot >> 16]; | |
| 102 | + else | |
| 103 | + fld = p0.class().virtualmethods[this.slot >> 16].field; | |
| 104 | + (result, ok) = jni->CallMethod(p0, fld.field, fld.signature, args); | |
| 105 | + } | |
| 106 | + # | |
| 107 | + # If necessary, wrap the answer up as an Object. | |
| 108 | + # | |
| 109 | + if ( ok == JNI->OK && result != nil ) { | |
| 110 | + typ := refl->ValType(result); | |
| 111 | + if ( typ >= JNI->T_BOOLEAN && typ <= JNI->T_LONG ) | |
| 112 | + return refl->ValueToObject(result); | |
| 113 | + else | |
| 114 | + return result.Object(); | |
| 115 | + } | |
| 116 | + return nil; | |
| 117 | +}#<< | |
| @@ -0,0 +1,20 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +Method_L : module | |
| 4 | +{ | |
| 5 | + Method_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + clazz : JClass; | |
| 9 | + slot : int; | |
| 10 | + name : JString; | |
| 11 | + returnType : JClass; | |
| 12 | + parameterTypes : JArrayJClass; | |
| 13 | + exceptionTypes : JArrayJClass; | |
| 14 | + }; | |
| 15 | + | |
| 16 | + init : fn( jni_p : JNI ); | |
| 17 | + getModifiers_I : fn( this : ref Method_obj) : int; | |
| 18 | + invoke_rObject_aObject_rObject : fn( this : ref Method_obj, p0 : JObject,p1 : JArrayJObject) : JObject; | |
| 19 | + | |
| 20 | +}; | |
Empty file added.
| @@ -0,0 +1,46 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + Array.dis\ | |
| 5 | + Constructor.dis\ | |
| 6 | + Field.dis\ | |
| 7 | +# for InvocationTargetException.dis\ | |
| 8 | + esaAWjdsByqq9cEPQZTRT.dis\ | |
| 9 | + Member.dis\ | |
| 10 | + Method.dis\ | |
| 11 | + Modifier.dis\ | |
| 12 | +# Limbo code\ | |
| 13 | + Array_L.dis\ | |
| 14 | + Constructor_L.dis\ | |
| 15 | + Field_L.dis\ | |
| 16 | + Method_L.dis\ | |
| 17 | + reflect.dis\ | |
| 18 | + | |
| 19 | +MODULES=\ | |
| 20 | + $ROOT/java/module/classloader.m\ | |
| 21 | + $ROOT/java/module/jni.m\ | |
| 22 | + $ROOT/java/module/cast.m\ | |
| 23 | + Array_L.m\ | |
| 24 | + Constructor_L.m\ | |
| 25 | + Field_L.m\ | |
| 26 | + Method_L.m\ | |
| 27 | + reflect.m\ | |
| 28 | + | |
| 29 | +SYSMODULES=\ | |
| 30 | + draw.m\ | |
| 31 | + hash.m\ | |
| 32 | + keyring.m\ | |
| 33 | + loader.m\ | |
| 34 | + math.m\ | |
| 35 | + string.m\ | |
| 36 | + sys.m\ | |
| 37 | + | |
| 38 | +DISBIN=$ROOT/java/dis/java/java/lang/reflect | |
| 39 | + | |
| 40 | +<$ROOT/mkfiles/mkjava | |
| 41 | + | |
| 42 | +reflect.dis: reflect.b | |
| 43 | + limbo $LIMBOINCL -gw reflect.b | |
| 44 | + | |
| 45 | +esaAWjdsByqq9cEPQZTRT.dis: InvocationTargetException.class | |
| 46 | + j2d InvocationTargetException.class | |
| @@ -0,0 +1,327 @@ | ||
| 1 | +implement Reflect; | |
| 2 | + | |
| 3 | +include "jni.m"; | |
| 4 | + jni : JNI; | |
| 5 | + cast : Cast; | |
| 6 | + | |
| 7 | + JObject, | |
| 8 | + JClass, | |
| 9 | + JArrayJClass, | |
| 10 | + JArrayJObject, | |
| 11 | + Value : import jni; | |
| 12 | + OK, | |
| 13 | + ERR, | |
| 14 | + TRUE, | |
| 15 | + FALSE, | |
| 16 | + #T_OBJECT, T_ARRAY, | |
| 17 | + T_BOOLEAN, | |
| 18 | + T_BYTE, | |
| 19 | + T_CHAR, | |
| 20 | + T_SHORT, | |
| 21 | + T_INT, | |
| 22 | + T_LONG, | |
| 23 | + T_FLOAT, | |
| 24 | + T_DOUBLE : import JNI; | |
| 25 | + | |
| 26 | + ClassData : import JNI; | |
| 27 | + | |
| 28 | +include "reflect.m"; | |
| 29 | + | |
| 30 | +wrapper_class := array[T_LONG-T_BOOLEAN+1] of ClassData; | |
| 31 | +wrapper_name := array[] of { "Boolean", | |
| 32 | + "Character", | |
| 33 | + "Float", | |
| 34 | + "Double", | |
| 35 | + "Byte", | |
| 36 | + "Short", | |
| 37 | + "Integer", | |
| 38 | + "Long" }; | |
| 39 | +type_string := "ZCFDBSIJ"; | |
| 40 | + | |
| 41 | +illegalarg := "java.lang.IllegalArgumentException"; | |
| 42 | +nullptr := "java.lang.NullPointerException"; | |
| 43 | + | |
| 44 | +init(jni_m : JNI) { | |
| 45 | + jni = jni_m; | |
| 46 | + for ( i := 0; i <= T_LONG - T_BOOLEAN; i++ ) | |
| 47 | + wrapper_class[i] = jni->FindClass("java/lang/" + wrapper_name[i]); | |
| 48 | + cast = jni->CastMod(); | |
| 49 | +} | |
| 50 | + | |
| 51 | +widen(have, want : int, val : ref Value) : ref Value | |
| 52 | +{ | |
| 53 | + if ( have == want ) | |
| 54 | + return val; | |
| 55 | + havetype := have; | |
| 56 | + wanttype := want; | |
| 57 | + valint : int; | |
| 58 | + valbig : big; | |
| 59 | + valreal : real; | |
| 60 | + if ( havetype == 0 || wanttype == 0 ) | |
| 61 | + return nil; | |
| 62 | + pick sw := val { | |
| 63 | + TByte => | |
| 64 | + valint = int sw.jbyte; | |
| 65 | + valbig = big valint; | |
| 66 | + valreal = real valint; | |
| 67 | + TShort => | |
| 68 | + valint = sw.jshort; | |
| 69 | + valbig = big valint; | |
| 70 | + valreal = real valint; | |
| 71 | + TChar => | |
| 72 | + valint = sw.jchar; | |
| 73 | + valbig = big valint; | |
| 74 | + valreal = real valint; | |
| 75 | + TInt => | |
| 76 | + valint = sw.jint; | |
| 77 | + valbig = big valint; | |
| 78 | + valreal = real valint; | |
| 79 | + TLong => | |
| 80 | + valbig = sw.jlong; | |
| 81 | + valreal = real valbig; | |
| 82 | + TFloat => | |
| 83 | + valreal = sw.jfloat; | |
| 84 | + } | |
| 85 | + case ( wanttype ) { | |
| 86 | + T_BOOLEAN or T_BYTE or T_CHAR => | |
| 87 | + return nil; | |
| 88 | + T_SHORT => | |
| 89 | + case ( havetype ) { | |
| 90 | + T_BYTE => | |
| 91 | + sw := ref Value.TShort; | |
| 92 | + sw.jshort = valint; | |
| 93 | + val = sw; | |
| 94 | + * => | |
| 95 | + return nil; | |
| 96 | + } | |
| 97 | + T_INT => | |
| 98 | + case ( havetype ) { | |
| 99 | + T_BYTE or T_SHORT or T_CHAR => | |
| 100 | + sw := ref Value.TInt; | |
| 101 | + sw.jint = valint; | |
| 102 | + val = sw; | |
| 103 | + * => | |
| 104 | + return nil; | |
| 105 | + } | |
| 106 | + T_LONG => | |
| 107 | + case ( havetype ) { | |
| 108 | + T_BYTE or T_SHORT or T_CHAR or T_INT => | |
| 109 | + sw := ref Value.TLong; | |
| 110 | + sw.jlong = valbig; | |
| 111 | + val = sw; | |
| 112 | + * => | |
| 113 | + return nil; | |
| 114 | + } | |
| 115 | + T_FLOAT => | |
| 116 | + case ( havetype ) { | |
| 117 | + T_BYTE or T_SHORT or T_CHAR or T_INT or T_LONG => | |
| 118 | + sw := ref Value.TFloat; | |
| 119 | + sw.jfloat = valreal; | |
| 120 | + val = sw; | |
| 121 | + * => | |
| 122 | + return nil; | |
| 123 | + } | |
| 124 | + T_DOUBLE => | |
| 125 | + case ( havetype ) { | |
| 126 | + T_BYTE or T_SHORT or T_CHAR or T_INT or T_LONG or T_FLOAT => | |
| 127 | + sw := ref Value.TDouble; | |
| 128 | + sw.jdouble = valreal; | |
| 129 | + val = sw; | |
| 130 | + * => | |
| 131 | + return nil; | |
| 132 | + } | |
| 133 | + } | |
| 134 | + return val; | |
| 135 | +} | |
| 136 | +BuildArgList(parms : JArrayJClass, arg : JArrayJObject) : array of ref Value | |
| 137 | +{ | |
| 138 | + # | |
| 139 | + # First do some checking. | |
| 140 | + # | |
| 141 | + l := 0; | |
| 142 | + formal: array of JClass; | |
| 143 | + actual: array of JObject; | |
| 144 | + args: array of ref Value; | |
| 145 | + if ( parms != nil ) { | |
| 146 | + if ( arg == nil ) | |
| 147 | + jni->ThrowException(nullptr, "constructor requires parameters"); | |
| 148 | + if ( len parms.ary != len arg.ary ) | |
| 149 | + jni->ThrowException(illegalarg, "Wrong number of args"); | |
| 150 | + l = len parms.ary; | |
| 151 | + formal = parms.ary; # array of JClass | |
| 152 | + actual = arg.ary; # array of JObject | |
| 153 | + args = array[l] of ref Value; | |
| 154 | + } | |
| 155 | + else # There are no formal parameters | |
| 156 | + if ( arg != nil && len arg.ary != 0 ) # But there are actual arguments | |
| 157 | + jni->ThrowException(illegalarg, "Wrong number of args"); | |
| 158 | + | |
| 159 | + # | |
| 160 | + # March through the arguments, checking for type as we go. | |
| 161 | + # | |
| 162 | + for ( i := 0; i < l; i++ ) { | |
| 163 | + # | |
| 164 | + # Is the formal parameter a primitive? | |
| 165 | + # | |
| 166 | + if ( (want := jni->PrimitiveIndex(formal[i], 1)) > 0 ) { | |
| 167 | + # | |
| 168 | + # Actual parameter should be (derived from) a wrapper, and | |
| 169 | + # be able to be widened to the formal parameter type. | |
| 170 | + # | |
| 171 | + (typ, parmval) := GetVal(actual[i]); | |
| 172 | + if ( (val := widen(want, typ, parmval)) != nil ) | |
| 173 | + args[i] = val; | |
| 174 | + else | |
| 175 | + jni->ThrowException(illegalarg, "Argument " + string (i+1) + | |
| 176 | + ", can't cast"); | |
| 177 | + } | |
| 178 | + else if ( jni->IsInstanceOf(actual[i], formal[i].class) == JNI->TRUE ) { | |
| 179 | + val := ref Value.TObject; | |
| 180 | + val.jobj = actual[i]; | |
| 181 | + args[i] = val; | |
| 182 | + } | |
| 183 | + else | |
| 184 | + jni->ThrowException(illegalarg, "Argument " + string (i+1) + | |
| 185 | + " wrong type"); | |
| 186 | + } | |
| 187 | + return args; | |
| 188 | +} | |
| 189 | +# | |
| 190 | +# Return a JClass corresponding to the Java type t. | |
| 191 | +# | |
| 192 | +Class(t : int) : JClass | |
| 193 | +{ | |
| 194 | + if ( t < T_BOOLEAN || t > T_LONG ) | |
| 195 | + return nil; | |
| 196 | + return jni->GetClassObject(wrapper_class[t - T_BOOLEAN]); | |
| 197 | +} | |
| 198 | +# | |
| 199 | +# Return a Class Object corresponding to the Java type t. | |
| 200 | +# | |
| 201 | +ClassObject(t : int) : JObject | |
| 202 | +{ | |
| 203 | + return cast->FromJClass(Class(t)); | |
| 204 | +} | |
| 205 | +# | |
| 206 | +# Given the java type, get the Class object representing this | |
| 207 | +# type, and return as a Value. | |
| 208 | +# | |
| 209 | +GetPrimitiveClass(typ : int) : ref Value | |
| 210 | +{ | |
| 211 | + return jni->GetStaticField(wrapper_class[typ - T_BOOLEAN], "TYPE", | |
| 212 | + "Ljava/lang/Class;"); | |
| 213 | +} | |
| 214 | +# | |
| 215 | +# If the Object o is a wrapper for a Java primitive type, return the | |
| 216 | +# primitive value (in a Value adt) and the type index. | |
| 217 | +# Otherwise, return 0 and a nil Value. | |
| 218 | +# | |
| 219 | +GetVal(o : JObject) : (int, ref Value) | |
| 220 | +{ | |
| 221 | + j := T_BOOLEAN; | |
| 222 | + for ( i := j; i <= T_LONG; i++ ) { | |
| 223 | + if ( jni->IsInstanceOf(o, wrapper_class[i-j]) == TRUE ) { | |
| 224 | + val := jni->GetObjField(o, "value", type_string[i-j:i-j+1]); | |
| 225 | + return (i, val); | |
| 226 | + } | |
| 227 | + } | |
| 228 | + return (0, nil); | |
| 229 | +} | |
| 230 | +# | |
| 231 | +# Convert a signature to a java type index. | |
| 232 | +# | |
| 233 | +SigToType(sig : string) : int | |
| 234 | +{ | |
| 235 | + index : int; | |
| 236 | + case sig[0] { | |
| 237 | + 'Z' => | |
| 238 | + index = T_BOOLEAN; | |
| 239 | + 'B' => | |
| 240 | + index = T_BYTE; | |
| 241 | + 'C' => | |
| 242 | + index = T_CHAR; | |
| 243 | + 'S' => | |
| 244 | + index = T_SHORT; | |
| 245 | + 'I' => | |
| 246 | + index = T_INT; | |
| 247 | + 'J' => | |
| 248 | + index = T_LONG; | |
| 249 | + 'F' => | |
| 250 | + index = T_FLOAT; | |
| 251 | + 'D' => | |
| 252 | + index = T_DOUBLE; | |
| 253 | + * => | |
| 254 | + index = 0; | |
| 255 | + } | |
| 256 | + return index; | |
| 257 | +} | |
| 258 | +# | |
| 259 | +# Convert a java type index to a signature. | |
| 260 | +# | |
| 261 | +TypeToSig(typ : int) : string | |
| 262 | +{ | |
| 263 | + if ( typ < T_BOOLEAN || typ > T_LONG ) | |
| 264 | + return nil; | |
| 265 | + return type_string[typ-T_BOOLEAN:typ-T_BOOLEAN+1]; | |
| 266 | +} | |
| 267 | +# | |
| 268 | +# Convert a Java type character to its corresponding type name. | |
| 269 | +# | |
| 270 | +TypeCharToName(c : int) : string | |
| 271 | +{ | |
| 272 | + tname : string; | |
| 273 | + case c { | |
| 274 | + 'Z' => | |
| 275 | + tname = "boolean"; | |
| 276 | + 'B' => | |
| 277 | + tname = "byte"; | |
| 278 | + 'C' => | |
| 279 | + tname = "char"; | |
| 280 | + 'S' => | |
| 281 | + tname = "short"; | |
| 282 | + 'I' => | |
| 283 | + tname = "int"; | |
| 284 | + 'J' => | |
| 285 | + tname = "long"; | |
| 286 | + 'F' => | |
| 287 | + tname = "float"; | |
| 288 | + 'D' => | |
| 289 | + tname = "double"; | |
| 290 | + * => | |
| 291 | + tname = "blah"; | |
| 292 | + } | |
| 293 | + return tname; | |
| 294 | +} | |
| 295 | +# | |
| 296 | +# Calculate the type index of the quantity in val. If it isn't a | |
| 297 | +# Java primitive type, return 0; | |
| 298 | +# | |
| 299 | +ValType(val : ref Value) : int | |
| 300 | +{ | |
| 301 | + pick sw := val { | |
| 302 | + TBoolean => return T_BOOLEAN; | |
| 303 | + TByte => return T_BYTE; | |
| 304 | + TChar => return T_CHAR; | |
| 305 | + TShort => return T_SHORT; | |
| 306 | + TInt => return T_INT; | |
| 307 | + TLong => return T_LONG; | |
| 308 | + TFloat => return T_FLOAT; | |
| 309 | + TDouble => return T_DOUBLE; | |
| 310 | + * => return 0; | |
| 311 | + } | |
| 312 | +} | |
| 313 | +# | |
| 314 | +# Create a wrapper Object for the primitive Java value corresponding | |
| 315 | +# to the argument. | |
| 316 | +# | |
| 317 | +ValueToObject(val : ref Value) : JObject | |
| 318 | +{ | |
| 319 | + typ := ValType(val); | |
| 320 | + j := T_BOOLEAN; | |
| 321 | + jobj := jni->AllocObject(wrapper_class[typ - j]); | |
| 322 | + sig := "(" + type_string[typ-j:typ-j+1] + ")V"; | |
| 323 | + (nil, ok) := jni->CallMethod(jobj, "<init>", sig, array[] of { val }); | |
| 324 | + if ( ok == OK ) | |
| 325 | + return jobj; | |
| 326 | + return nil; | |
| 327 | +} | |
| @@ -0,0 +1,19 @@ | ||
| 1 | +Reflect : module { | |
| 2 | + | |
| 3 | + PATH : con "/dis/java/java/lang/reflect/reflect.dis"; | |
| 4 | + | |
| 5 | + init : fn(jni_m : JNI); | |
| 6 | + widen : fn(havetype, wanttype : int, val : ref Value) : ref Value; | |
| 7 | + BuildArgList: fn(parms : JArrayJClass, arg : JArrayJObject) | |
| 8 | + : array of ref Value; | |
| 9 | + Class : fn(t : int) : JClass; | |
| 10 | + ClassObject : fn(t : int) : JObject; | |
| 11 | + GetPrimitiveClass : fn(typ : int) : ref Value; | |
| 12 | + GetVal : fn(o : JObject) : (int, ref Value); | |
| 13 | + SigToType : fn(sig : string) : int; | |
| 14 | + TypeToSig : fn(typ : int) : string; | |
| 15 | + TypeCharToName : fn(c : int) : string; | |
| 16 | + ValType : fn(val : ref Value) : int; | |
| 17 | + ValueToObject : fn(val : ref Value) : JObject; | |
| 18 | + | |
| 19 | +}; | |
| @@ -0,0 +1,1285 @@ | ||
| 1 | +implement UnicodeTable; | |
| 2 | + | |
| 3 | +include "unicode_table.m"; | |
| 4 | + | |
| 5 | +# | |
| 6 | +# the following is lifted from JavaSoft's java | |
| 7 | +# source for java.lang.Character. The Limbo | |
| 8 | +# compiler produces a more compact file then Java | |
| 9 | +# | |
| 10 | + | |
| 11 | +# The character properties are currently encoded into 32 bits in the following manner: | |
| 12 | +# 10 bits signed offset used for converting case | |
| 13 | +# 1 bit if 1, adding the signed offset converts the character to lowercase | |
| 14 | +# 1 bit if 1, subtracting the signed offset converts the character to uppercase | |
| 15 | +# 1 bit if 1, this character has a titlecase equivalent (possibly itself) | |
| 16 | +# 3 bits 0 may not be part of an identifier | |
| 17 | +# 1 ignorable control; may continue a Unicode identifier or Java identifier | |
| 18 | +# 2 may continue a Java identifier but not a Unicode identifier (unused) | |
| 19 | +# 3 may continue a Unicode identifier or Java identifier | |
| 20 | +# 4 is a Java whitespace character | |
| 21 | +# 5 may start or continue a Java identifier; | |
| 22 | +# may continue but not start a Unicode identifier (underscores) | |
| 23 | +# 6 may start or continue a Java identifier but not a Unicode identifier ($) | |
| 24 | +# 7 may start or continue a Unicode identifier or Java identifier | |
| 25 | +# Thus: | |
| 26 | +# 5, 6, 7 may start a Java identifier | |
| 27 | +# 1, 2, 3, 5, 6, 7 may continue a Java identifier | |
| 28 | +# 7 may start a Unicode identifier | |
| 29 | +# 1, 3, 5, 7 may continue a Unicode identifier | |
| 30 | +# 1 is ignorable within an identifier | |
| 31 | +# 4 is Java whitespace | |
| 32 | +# 2 bits 0 this character has no numeric property | |
| 33 | +# 1 adding the digit offset to the character code and then | |
| 34 | +# masking with 16r1F will produce the desired numeric value | |
| 35 | +# 2 this character has a "strange" numeric value | |
| 36 | +# 3 a Java supradecimal digit: adding the digit offset to the | |
| 37 | +# character code, then masking with 16r1F, then adding 10 | |
| 38 | +# will produce the desired numeric value | |
| 39 | +# 5 bits digit offset | |
| 40 | +# 4 bits reserved for future use | |
| 41 | +# 5 bits character type | |
| 42 | +# | |
| 43 | + | |
| 44 | +# The X table has 1024 entries for a total of 1024 bytes. | |
| 45 | + | |
| 46 | +X = array[] of { | |
| 47 | + 0, 1, 2, 3, 4, 5, 6, 7, # 16r0000 | |
| 48 | + 8, 9, 10, 11, 12, 13, 14, 15, # 16r0200 | |
| 49 | + 16, 17, 18, 19, 20, 21, 22, 23, # 16r0400 | |
| 50 | + 24, 25, 26, 27, 28, 28, 28, 28, # 16r0600 | |
| 51 | + 28, 28, 28, 28, 29, 30, 31, 32, # 16r0800 | |
| 52 | + 33, 34, 35, 36, 37, 38, 39, 40, # 16r0A00 | |
| 53 | + 41, 42, 43, 44, 45, 46, 28, 28, # 16r0C00 | |
| 54 | + 47, 48, 49, 50, 51, 52, 53, 28, # 16r0E00 | |
| 55 | + 28, 28, 54, 55, 56, 57, 58, 59, # 16r1000 | |
| 56 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r1200 | |
| 57 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r1400 | |
| 58 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r1600 | |
| 59 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r1800 | |
| 60 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r1A00 | |
| 61 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r1C00 | |
| 62 | + 60, 60, 61, 62, 63, 64, 65, 66, # 16r1E00 | |
| 63 | + 67, 68, 69, 70, 71, 72, 73, 74, # 16r2000 | |
| 64 | + 75, 75, 75, 76, 77, 78, 28, 28, # 16r2200 | |
| 65 | + 79, 80, 81, 82, 83, 83, 84, 85, # 16r2400 | |
| 66 | + 86, 85, 28, 28, 87, 88, 89, 28, # 16r2600 | |
| 67 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r2800 | |
| 68 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r2A00 | |
| 69 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r2C00 | |
| 70 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r2E00 | |
| 71 | + 90, 91, 92, 93, 94, 56, 95, 28, # 16r3000 | |
| 72 | + 96, 97, 98, 99, 83, 100, 83, 101, # 16r3200 | |
| 73 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r3400 | |
| 74 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r3600 | |
| 75 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r3800 | |
| 76 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r3A00 | |
| 77 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r3C00 | |
| 78 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r3E00 | |
| 79 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r4000 | |
| 80 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r4200 | |
| 81 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r4400 | |
| 82 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r4600 | |
| 83 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r4800 | |
| 84 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r4A00 | |
| 85 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16r4C00 | |
| 86 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r4E00 | |
| 87 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r5000 | |
| 88 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r5200 | |
| 89 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r5400 | |
| 90 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r5600 | |
| 91 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r5800 | |
| 92 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r5A00 | |
| 93 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r5C00 | |
| 94 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r5E00 | |
| 95 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r6000 | |
| 96 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r6200 | |
| 97 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r6400 | |
| 98 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r6600 | |
| 99 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r6800 | |
| 100 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r6A00 | |
| 101 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r6C00 | |
| 102 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r6E00 | |
| 103 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r7000 | |
| 104 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r7200 | |
| 105 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r7400 | |
| 106 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r7600 | |
| 107 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r7800 | |
| 108 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r7A00 | |
| 109 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r7C00 | |
| 110 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r7E00 | |
| 111 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r8000 | |
| 112 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r8200 | |
| 113 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r8400 | |
| 114 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r8600 | |
| 115 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r8800 | |
| 116 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r8A00 | |
| 117 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r8C00 | |
| 118 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r8E00 | |
| 119 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r9000 | |
| 120 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r9200 | |
| 121 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r9400 | |
| 122 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r9600 | |
| 123 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r9800 | |
| 124 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r9A00 | |
| 125 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16r9C00 | |
| 126 | + 56, 56, 56, 56, 56, 56, 102, 28, # 16r9E00 | |
| 127 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16rA000 | |
| 128 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16rA200 | |
| 129 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16rA400 | |
| 130 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16rA600 | |
| 131 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16rA800 | |
| 132 | + 28, 28, 28, 28, 28, 28, 28, 28, # 16rAA00 | |
| 133 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rAC00 | |
| 134 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rAE00 | |
| 135 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rB000 | |
| 136 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rB200 | |
| 137 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rB400 | |
| 138 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rB600 | |
| 139 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rB800 | |
| 140 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rBA00 | |
| 141 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rBC00 | |
| 142 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rBE00 | |
| 143 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rC000 | |
| 144 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rC200 | |
| 145 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rC400 | |
| 146 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rC600 | |
| 147 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rC800 | |
| 148 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rCA00 | |
| 149 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rCC00 | |
| 150 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rCE00 | |
| 151 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rD000 | |
| 152 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rD200 | |
| 153 | + 56, 56, 56, 56, 56, 56, 56, 56, # 16rD400 | |
| 154 | + 56, 56, 56, 56, 56, 56, 103, 28, # 16rD600 | |
| 155 | + 104, 104, 104, 104, 104, 104, 104, 104, # 16rD800 | |
| 156 | + 104, 104, 104, 104, 104, 104, 104, 104, # 16rDA00 | |
| 157 | + 104, 104, 104, 104, 104, 104, 104, 104, # 16rDC00 | |
| 158 | + 104, 104, 104, 104, 104, 104, 104, 104, # 16rDE00 | |
| 159 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rE000 | |
| 160 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rE200 | |
| 161 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rE400 | |
| 162 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rE600 | |
| 163 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rE800 | |
| 164 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rEA00 | |
| 165 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rEC00 | |
| 166 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rEE00 | |
| 167 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rF000 | |
| 168 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rF200 | |
| 169 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rF400 | |
| 170 | + 105, 105, 105, 105, 105, 105, 105, 105, # 16rF600 | |
| 171 | + 105, 105, 105, 105, 56, 56, 56, 56, # 16rF800 | |
| 172 | + 106, 28, 28, 28, 107, 108, 109, 110, # 16rFA00 | |
| 173 | + 56, 56, 56, 56, 111, 112, 113, 114, # 16rFC00 | |
| 174 | + 115, 116, 56, 117, 118, 119, 120, 121 # 16rFE00 | |
| 175 | + }; | |
| 176 | + | |
| 177 | +# The Y table has 7808 entries for a total of 7808 bytes. | |
| 178 | + | |
| 179 | +Y = array[] of { | |
| 180 | + 0, 0, 0, 0, 0, 0, 0, 0, # 0 | |
| 181 | + 0, 1, 1, 1, 1, 1, 0, 0, # 0 | |
| 182 | + 0, 0, 0, 0, 0, 0, 0, 0, # 0 | |
| 183 | + 0, 0, 0, 0, 1, 1, 1, 1, # 0 | |
| 184 | + 2, 3, 3, 3, 4, 3, 3, 3, # 0 | |
| 185 | + 5, 6, 3, 7, 3, 8, 3, 3, # 0 | |
| 186 | + 9, 9, 9, 9, 9, 9, 9, 9, # 0 | |
| 187 | + 9, 9, 3, 3, 7, 7, 7, 3, # 0 | |
| 188 | + 3, 10, 10, 10, 10, 10, 10, 10, # 1 | |
| 189 | + 10, 10, 10, 10, 10, 10, 10, 10, # 1 | |
| 190 | + 10, 10, 10, 10, 10, 10, 10, 10, # 1 | |
| 191 | + 10, 10, 10, 5, 3, 6, 11, 12, # 1 | |
| 192 | + 11, 13, 13, 13, 13, 13, 13, 13, # 1 | |
| 193 | + 13, 13, 13, 13, 13, 13, 13, 13, # 1 | |
| 194 | + 13, 13, 13, 13, 13, 13, 13, 13, # 1 | |
| 195 | + 13, 13, 13, 5, 7, 6, 7, 0, # 1 | |
| 196 | + 0, 0, 0, 0, 0, 0, 0, 0, # 2 | |
| 197 | + 0, 0, 0, 0, 0, 0, 0, 0, # 2 | |
| 198 | + 0, 0, 0, 0, 0, 0, 0, 0, # 2 | |
| 199 | + 0, 0, 0, 0, 0, 0, 0, 0, # 2 | |
| 200 | + 14, 3, 4, 4, 4, 4, 15, 15, # 2 | |
| 201 | + 11, 15, 16, 5, 7, 8, 15, 11, # 2 | |
| 202 | + 15, 7, 17, 17, 11, 16, 15, 3, # 2 | |
| 203 | + 11, 18, 16, 6, 19, 19, 19, 3, # 2 | |
| 204 | + 20, 20, 20, 20, 20, 20, 20, 20, # 3 | |
| 205 | + 20, 20, 20, 20, 20, 20, 20, 20, # 3 | |
| 206 | + 20, 20, 20, 20, 20, 20, 20, 7, # 3 | |
| 207 | + 20, 20, 20, 20, 20, 20, 20, 16, # 3 | |
| 208 | + 21, 21, 21, 21, 21, 21, 21, 21, # 3 | |
| 209 | + 21, 21, 21, 21, 21, 21, 21, 21, # 3 | |
| 210 | + 21, 21, 21, 21, 21, 21, 21, 7, # 3 | |
| 211 | + 21, 21, 21, 21, 21, 21, 21, 22, # 3 | |
| 212 | + 23, 24, 23, 24, 23, 24, 23, 24, # 4 | |
| 213 | + 23, 24, 23, 24, 23, 24, 23, 24, # 4 | |
| 214 | + 23, 24, 23, 24, 23, 24, 23, 24, # 4 | |
| 215 | + 23, 24, 23, 24, 23, 24, 23, 24, # 4 | |
| 216 | + 23, 24, 23, 24, 23, 24, 23, 24, # 4 | |
| 217 | + 23, 24, 23, 24, 23, 24, 23, 24, # 4 | |
| 218 | + 25, 26, 23, 24, 23, 24, 23, 24, # 4 | |
| 219 | + 16, 23, 24, 23, 24, 23, 24, 23, # 4 | |
| 220 | + 24, 23, 24, 23, 24, 23, 24, 23, # 5 | |
| 221 | + 24, 16, 23, 24, 23, 24, 23, 24, # 5 | |
| 222 | + 23, 24, 23, 24, 23, 24, 23, 24, # 5 | |
| 223 | + 23, 24, 23, 24, 23, 24, 23, 24, # 5 | |
| 224 | + 23, 24, 23, 24, 23, 24, 23, 24, # 5 | |
| 225 | + 23, 24, 23, 24, 23, 24, 23, 24, # 5 | |
| 226 | + 23, 24, 23, 24, 23, 24, 23, 24, # 5 | |
| 227 | + 27, 23, 24, 23, 24, 23, 24, 28, # 5 | |
| 228 | + 16, 29, 23, 24, 23, 24, 30, 23, # 6 | |
| 229 | + 24, 31, 31, 23, 24, 16, 32, 32, # 6 | |
| 230 | + 33, 23, 24, 31, 34, 16, 35, 36, # 6 | |
| 231 | + 23, 24, 16, 16, 35, 37, 16, 38, # 6 | |
| 232 | + 23, 24, 23, 24, 23, 24, 38, 23, # 6 | |
| 233 | + 24, 39, 40, 16, 23, 24, 39, 23, # 6 | |
| 234 | + 24, 41, 41, 23, 24, 23, 24, 42, # 6 | |
| 235 | + 23, 24, 16, 40, 23, 24, 40, 40, # 6 | |
| 236 | + 40, 40, 40, 40, 43, 44, 45, 43, # 7 | |
| 237 | + 44, 45, 43, 44, 45, 23, 24, 23, # 7 | |
| 238 | + 24, 23, 24, 23, 24, 23, 24, 23, # 7 | |
| 239 | + 24, 23, 24, 23, 24, 16, 23, 24, # 7 | |
| 240 | + 23, 24, 23, 24, 23, 24, 23, 24, # 7 | |
| 241 | + 23, 24, 23, 24, 23, 24, 23, 24, # 7 | |
| 242 | + 16, 43, 44, 45, 23, 24, 46, 46, # 7 | |
| 243 | + 46, 46, 23, 24, 23, 24, 23, 24, # 7 | |
| 244 | + 23, 24, 23, 24, 23, 24, 23, 24, # 8 | |
| 245 | + 23, 24, 23, 24, 23, 24, 23, 24, # 8 | |
| 246 | + 23, 24, 23, 24, 23, 24, 23, 24, # 8 | |
| 247 | + 46, 46, 46, 46, 46, 46, 46, 46, # 8 | |
| 248 | + 46, 46, 46, 46, 46, 46, 46, 46, # 8 | |
| 249 | + 46, 46, 46, 46, 46, 46, 46, 46, # 8 | |
| 250 | + 46, 46, 46, 46, 46, 46, 46, 46, # 8 | |
| 251 | + 46, 46, 46, 46, 46, 46, 46, 46, # 8 | |
| 252 | + 46, 46, 46, 46, 46, 46, 46, 46, # 9 | |
| 253 | + 46, 46, 46, 46, 46, 46, 46, 46, # 9 | |
| 254 | + 16, 16, 16, 47, 48, 16, 49, 49, # 9 | |
| 255 | + 50, 50, 16, 51, 16, 16, 16, 16, # 9 | |
| 256 | + 49, 16, 16, 52, 16, 16, 16, 16, # 9 | |
| 257 | + 53, 54, 16, 16, 16, 16, 16, 54, # 9 | |
| 258 | + 16, 16, 55, 16, 16, 16, 16, 16, # 9 | |
| 259 | + 16, 16, 16, 16, 16, 16, 16, 16, # 9 | |
| 260 | + 16, 16, 16, 56, 16, 16, 16, 16, # 10 | |
| 261 | + 56, 16, 57, 57, 16, 16, 16, 16, # 10 | |
| 262 | + 16, 16, 58, 16, 16, 16, 16, 16, # 10 | |
| 263 | + 16, 16, 16, 16, 16, 16, 16, 16, # 10 | |
| 264 | + 16, 16, 16, 16, 16, 16, 16, 16, # 10 | |
| 265 | + 16, 46, 46, 46, 46, 46, 46, 46, # 10 | |
| 266 | + 59, 59, 59, 59, 59, 59, 59, 59, # 10 | |
| 267 | + 59, 11, 11, 59, 59, 59, 59, 59, # 10 | |
| 268 | + 59, 59, 11, 11, 11, 11, 11, 11, # 11 | |
| 269 | + 11, 11, 11, 11, 11, 11, 11, 11, # 11 | |
| 270 | + 59, 59, 11, 11, 11, 11, 11, 11, # 11 | |
| 271 | + 11, 11, 11, 11, 11, 11, 11, 46, # 11 | |
| 272 | + 59, 59, 59, 59, 59, 11, 11, 11, # 11 | |
| 273 | + 11, 11, 46, 46, 46, 46, 46, 46, # 11 | |
| 274 | + 46, 46, 46, 46, 46, 46, 46, 46, # 11 | |
| 275 | + 46, 46, 46, 46, 46, 46, 46, 46, # 11 | |
| 276 | + 60, 60, 60, 60, 60, 60, 60, 60, # 12 | |
| 277 | + 60, 60, 60, 60, 60, 60, 60, 60, # 12 | |
| 278 | + 60, 60, 60, 60, 60, 60, 60, 60, # 12 | |
| 279 | + 60, 60, 60, 60, 60, 60, 60, 60, # 12 | |
| 280 | + 60, 60, 60, 60, 60, 60, 60, 60, # 12 | |
| 281 | + 60, 60, 60, 60, 60, 60, 60, 60, # 12 | |
| 282 | + 60, 60, 60, 60, 60, 60, 60, 60, # 12 | |
| 283 | + 60, 60, 60, 60, 60, 60, 60, 60, # 12 | |
| 284 | + 60, 60, 60, 60, 60, 60, 46, 46, # 13 | |
| 285 | + 46, 46, 46, 46, 46, 46, 46, 46, # 13 | |
| 286 | + 46, 46, 46, 46, 46, 46, 46, 46, # 13 | |
| 287 | + 46, 46, 46, 46, 46, 46, 46, 46, # 13 | |
| 288 | + 60, 60, 46, 46, 46, 46, 46, 46, # 13 | |
| 289 | + 46, 46, 46, 46, 46, 46, 46, 46, # 13 | |
| 290 | + 46, 46, 46, 46, 3, 3, 46, 46, # 13 | |
| 291 | + 46, 46, 59, 46, 46, 46, 3, 46, # 13 | |
| 292 | + 46, 46, 46, 46, 11, 11, 61, 3, # 14 | |
| 293 | + 62, 62, 62, 46, 63, 46, 64, 64, # 14 | |
| 294 | + 16, 20, 20, 20, 20, 20, 20, 20, # 14 | |
| 295 | + 20, 20, 20, 20, 20, 20, 20, 20, # 14 | |
| 296 | + 20, 20, 46, 20, 20, 20, 20, 20, # 14 | |
| 297 | + 20, 20, 20, 20, 65, 66, 66, 66, # 14 | |
| 298 | + 16, 21, 21, 21, 21, 21, 21, 21, # 14 | |
| 299 | + 21, 21, 21, 21, 21, 21, 21, 21, # 14 | |
| 300 | + 21, 21, 16, 21, 21, 21, 21, 21, # 15 | |
| 301 | + 21, 21, 21, 21, 67, 68, 68, 46, # 15 | |
| 302 | + 69, 70, 38, 38, 38, 71, 72, 46, # 15 | |
| 303 | + 46, 46, 38, 46, 38, 46, 38, 46, # 15 | |
| 304 | + 38, 46, 23, 24, 23, 24, 23, 24, # 15 | |
| 305 | + 23, 24, 23, 24, 23, 24, 23, 24, # 15 | |
| 306 | + 73, 74, 16, 40, 46, 46, 46, 46, # 15 | |
| 307 | + 46, 46, 46, 46, 46, 46, 46, 46, # 15 | |
| 308 | + 46, 75, 75, 75, 75, 75, 75, 75, # 16 | |
| 309 | + 75, 75, 75, 75, 75, 46, 75, 75, # 16 | |
| 310 | + 20, 20, 20, 20, 20, 20, 20, 20, # 16 | |
| 311 | + 20, 20, 20, 20, 20, 20, 20, 20, # 16 | |
| 312 | + 20, 20, 20, 20, 20, 20, 20, 20, # 16 | |
| 313 | + 20, 20, 20, 20, 20, 20, 20, 20, # 16 | |
| 314 | + 21, 21, 21, 21, 21, 21, 21, 21, # 16 | |
| 315 | + 21, 21, 21, 21, 21, 21, 21, 21, # 16 | |
| 316 | + 21, 21, 21, 21, 21, 21, 21, 21, # 17 | |
| 317 | + 21, 21, 21, 21, 21, 21, 21, 21, # 17 | |
| 318 | + 46, 74, 74, 74, 74, 74, 74, 74, # 17 | |
| 319 | + 74, 74, 74, 74, 74, 46, 74, 74, # 17 | |
| 320 | + 23, 24, 23, 24, 23, 24, 23, 24, # 17 | |
| 321 | + 23, 24, 23, 24, 23, 24, 23, 24, # 17 | |
| 322 | + 23, 24, 23, 24, 23, 24, 23, 24, # 17 | |
| 323 | + 23, 24, 23, 24, 23, 24, 23, 24, # 17 | |
| 324 | + 23, 24, 15, 60, 60, 60, 60, 46, # 18 | |
| 325 | + 46, 46, 46, 46, 46, 46, 46, 46, # 18 | |
| 326 | + 23, 24, 23, 24, 23, 24, 23, 24, # 18 | |
| 327 | + 23, 24, 23, 24, 23, 24, 23, 24, # 18 | |
| 328 | + 23, 24, 23, 24, 23, 24, 23, 24, # 18 | |
| 329 | + 23, 24, 23, 24, 23, 24, 23, 24, # 18 | |
| 330 | + 23, 24, 23, 24, 23, 24, 23, 24, # 18 | |
| 331 | + 23, 24, 23, 24, 23, 24, 23, 24, # 18 | |
| 332 | + 40, 23, 24, 23, 24, 46, 46, 23, # 19 | |
| 333 | + 24, 46, 46, 23, 24, 46, 46, 46, # 19 | |
| 334 | + 23, 24, 23, 24, 23, 24, 23, 24, # 19 | |
| 335 | + 23, 24, 23, 24, 23, 24, 23, 24, # 19 | |
| 336 | + 23, 24, 23, 24, 23, 24, 23, 24, # 19 | |
| 337 | + 23, 24, 23, 24, 46, 46, 23, 24, # 19 | |
| 338 | + 23, 24, 23, 24, 23, 24, 46, 46, # 19 | |
| 339 | + 23, 24, 46, 46, 46, 46, 46, 46, # 19 | |
| 340 | + 46, 46, 46, 46, 46, 46, 46, 46, # 20 | |
| 341 | + 46, 46, 46, 46, 46, 46, 46, 46, # 20 | |
| 342 | + 46, 46, 46, 46, 46, 46, 46, 46, # 20 | |
| 343 | + 46, 46, 46, 46, 46, 46, 46, 46, # 20 | |
| 344 | + 46, 46, 46, 46, 46, 46, 46, 46, # 20 | |
| 345 | + 46, 46, 46, 46, 46, 46, 46, 46, # 20 | |
| 346 | + 46, 76, 76, 76, 76, 76, 76, 76, # 20 | |
| 347 | + 76, 76, 76, 76, 76, 76, 76, 76, # 20 | |
| 348 | + 76, 76, 76, 76, 76, 76, 76, 76, # 21 | |
| 349 | + 76, 76, 76, 76, 76, 76, 76, 76, # 21 | |
| 350 | + 76, 76, 76, 76, 76, 76, 76, 46, # 21 | |
| 351 | + 46, 59, 3, 3, 3, 3, 3, 3, # 21 | |
| 352 | + 46, 77, 77, 77, 77, 77, 77, 77, # 21 | |
| 353 | + 77, 77, 77, 77, 77, 77, 77, 77, # 21 | |
| 354 | + 77, 77, 77, 77, 77, 77, 77, 77, # 21 | |
| 355 | + 77, 77, 77, 77, 77, 77, 77, 77, # 21 | |
| 356 | + 77, 77, 77, 77, 77, 77, 77, 16, # 22 | |
| 357 | + 46, 3, 46, 46, 46, 46, 46, 46, # 22 | |
| 358 | + 46, 60, 60, 60, 60, 60, 60, 60, # 22 | |
| 359 | + 60, 60, 60, 60, 60, 60, 60, 60, # 22 | |
| 360 | + 60, 60, 46, 60, 60, 60, 60, 60, # 22 | |
| 361 | + 60, 60, 60, 60, 60, 60, 60, 60, # 22 | |
| 362 | + 60, 60, 60, 60, 60, 60, 60, 60, # 22 | |
| 363 | + 60, 60, 46, 60, 60, 60, 3, 60, # 22 | |
| 364 | + 3, 60, 60, 3, 60, 46, 46, 46, # 23 | |
| 365 | + 46, 46, 46, 46, 46, 46, 46, 46, # 23 | |
| 366 | + 40, 40, 40, 40, 40, 40, 40, 40, # 23 | |
| 367 | + 40, 40, 40, 40, 40, 40, 40, 40, # 23 | |
| 368 | + 40, 40, 40, 40, 40, 40, 40, 40, # 23 | |
| 369 | + 40, 40, 40, 46, 46, 46, 46, 46, # 23 | |
| 370 | + 40, 40, 40, 3, 3, 46, 46, 46, # 23 | |
| 371 | + 46, 46, 46, 46, 46, 46, 46, 46, # 23 | |
| 372 | + 46, 46, 46, 46, 46, 46, 46, 46, # 24 | |
| 373 | + 46, 46, 46, 46, 3, 46, 46, 46, # 24 | |
| 374 | + 46, 46, 46, 46, 46, 46, 46, 46, # 24 | |
| 375 | + 46, 46, 46, 3, 46, 46, 46, 3, # 24 | |
| 376 | + 46, 40, 40, 40, 40, 40, 40, 40, # 24 | |
| 377 | + 40, 40, 40, 40, 40, 40, 40, 40, # 24 | |
| 378 | + 40, 40, 40, 40, 40, 40, 40, 40, # 24 | |
| 379 | + 40, 40, 40, 46, 46, 46, 46, 46, # 24 | |
| 380 | + 59, 40, 40, 40, 40, 40, 40, 40, # 25 | |
| 381 | + 40, 40, 40, 60, 60, 60, 60, 60, # 25 | |
| 382 | + 60, 60, 60, 46, 46, 46, 46, 46, # 25 | |
| 383 | + 46, 46, 46, 46, 46, 46, 46, 46, # 25 | |
| 384 | + 78, 78, 78, 78, 78, 78, 78, 78, # 25 | |
| 385 | + 78, 78, 3, 3, 3, 3, 46, 46, # 25 | |
| 386 | + 60, 40, 40, 40, 40, 40, 40, 40, # 25 | |
| 387 | + 40, 40, 40, 40, 40, 40, 40, 40, # 25 | |
| 388 | + 40, 40, 40, 40, 40, 40, 40, 40, # 26 | |
| 389 | + 40, 40, 40, 40, 40, 40, 40, 40, # 26 | |
| 390 | + 40, 40, 40, 40, 40, 40, 40, 40, # 26 | |
| 391 | + 40, 40, 40, 40, 40, 40, 40, 40, # 26 | |
| 392 | + 40, 40, 40, 40, 40, 40, 40, 40, # 26 | |
| 393 | + 40, 40, 40, 40, 40, 40, 40, 40, # 26 | |
| 394 | + 40, 40, 40, 40, 40, 40, 40, 40, # 26 | |
| 395 | + 46, 46, 40, 40, 40, 40, 40, 46, # 26 | |
| 396 | + 40, 40, 40, 40, 40, 40, 40, 40, # 27 | |
| 397 | + 40, 40, 40, 40, 40, 40, 40, 46, # 27 | |
| 398 | + 40, 40, 40, 40, 3, 40, 60, 60, # 27 | |
| 399 | + 60, 60, 60, 60, 60, 79, 79, 60, # 27 | |
| 400 | + 60, 60, 60, 60, 60, 59, 59, 60, # 27 | |
| 401 | + 60, 15, 60, 60, 60, 60, 46, 46, # 27 | |
| 402 | + 9, 9, 9, 9, 9, 9, 9, 9, # 27 | |
| 403 | + 9, 9, 46, 46, 46, 46, 46, 46, # 27 | |
| 404 | + 46, 46, 46, 46, 46, 46, 46, 46, # 28 | |
| 405 | + 46, 46, 46, 46, 46, 46, 46, 46, # 28 | |
| 406 | + 46, 46, 46, 46, 46, 46, 46, 46, # 28 | |
| 407 | + 46, 46, 46, 46, 46, 46, 46, 46, # 28 | |
| 408 | + 46, 46, 46, 46, 46, 46, 46, 46, # 28 | |
| 409 | + 46, 46, 46, 46, 46, 46, 46, 46, # 28 | |
| 410 | + 46, 46, 46, 46, 46, 46, 46, 46, # 28 | |
| 411 | + 46, 46, 46, 46, 46, 46, 46, 46, # 28 | |
| 412 | + 46, 60, 60, 80, 46, 40, 40, 40, # 29 | |
| 413 | + 40, 40, 40, 40, 40, 40, 40, 40, # 29 | |
| 414 | + 40, 40, 40, 40, 40, 40, 40, 40, # 29 | |
| 415 | + 40, 40, 40, 40, 40, 40, 40, 40, # 29 | |
| 416 | + 40, 40, 40, 40, 40, 40, 40, 40, # 29 | |
| 417 | + 40, 40, 40, 40, 40, 40, 40, 40, # 29 | |
| 418 | + 40, 40, 40, 40, 40, 40, 40, 40, # 29 | |
| 419 | + 40, 40, 46, 46, 60, 40, 80, 80, # 29 | |
| 420 | + 80, 60, 60, 60, 60, 60, 60, 60, # 30 | |
| 421 | + 60, 80, 80, 80, 80, 60, 46, 46, # 30 | |
| 422 | + 15, 60, 60, 60, 60, 46, 46, 46, # 30 | |
| 423 | + 40, 40, 40, 40, 40, 40, 40, 40, # 30 | |
| 424 | + 40, 40, 60, 60, 3, 3, 81, 81, # 30 | |
| 425 | + 81, 81, 81, 81, 81, 81, 81, 81, # 30 | |
| 426 | + 3, 46, 46, 46, 46, 46, 46, 46, # 30 | |
| 427 | + 46, 46, 46, 46, 46, 46, 46, 46, # 30 | |
| 428 | + 46, 60, 80, 80, 46, 40, 40, 40, # 31 | |
| 429 | + 40, 40, 40, 40, 40, 46, 46, 40, # 31 | |
| 430 | + 40, 46, 46, 40, 40, 40, 40, 40, # 31 | |
| 431 | + 40, 40, 40, 40, 40, 40, 40, 40, # 31 | |
| 432 | + 40, 40, 40, 40, 40, 40, 40, 40, # 31 | |
| 433 | + 40, 46, 40, 40, 40, 40, 40, 40, # 31 | |
| 434 | + 40, 46, 40, 46, 46, 46, 40, 40, # 31 | |
| 435 | + 40, 40, 46, 46, 60, 46, 80, 80, # 31 | |
| 436 | + 80, 60, 60, 60, 60, 46, 46, 80, # 32 | |
| 437 | + 80, 46, 46, 80, 80, 60, 46, 46, # 32 | |
| 438 | + 46, 46, 46, 46, 46, 46, 46, 80, # 32 | |
| 439 | + 46, 46, 46, 46, 40, 40, 46, 40, # 32 | |
| 440 | + 40, 40, 60, 60, 46, 46, 81, 81, # 32 | |
| 441 | + 81, 81, 81, 81, 81, 81, 81, 81, # 32 | |
| 442 | + 40, 40, 4, 4, 82, 82, 82, 82, # 32 | |
| 443 | + 19, 83, 15, 46, 46, 46, 46, 46, # 32 | |
| 444 | + 46, 46, 60, 46, 46, 40, 40, 40, # 33 | |
| 445 | + 40, 40, 40, 46, 46, 46, 46, 40, # 33 | |
| 446 | + 40, 46, 46, 40, 40, 40, 40, 40, # 33 | |
| 447 | + 40, 40, 40, 40, 40, 40, 40, 40, # 33 | |
| 448 | + 40, 40, 40, 40, 40, 40, 40, 40, # 33 | |
| 449 | + 40, 46, 40, 40, 40, 40, 40, 40, # 33 | |
| 450 | + 40, 46, 40, 40, 46, 40, 40, 46, # 33 | |
| 451 | + 40, 40, 46, 46, 60, 46, 80, 80, # 33 | |
| 452 | + 80, 60, 60, 46, 46, 46, 46, 60, # 34 | |
| 453 | + 60, 46, 46, 60, 60, 60, 46, 46, # 34 | |
| 454 | + 46, 46, 46, 46, 46, 46, 46, 46, # 34 | |
| 455 | + 46, 40, 40, 40, 40, 46, 40, 46, # 34 | |
| 456 | + 46, 46, 46, 46, 46, 46, 81, 81, # 34 | |
| 457 | + 81, 81, 81, 81, 81, 81, 81, 81, # 34 | |
| 458 | + 60, 60, 40, 40, 40, 46, 46, 46, # 34 | |
| 459 | + 46, 46, 46, 46, 46, 46, 46, 46, # 34 | |
| 460 | + 46, 60, 60, 80, 46, 40, 40, 40, # 35 | |
| 461 | + 40, 40, 40, 40, 46, 40, 46, 40, # 35 | |
| 462 | + 40, 40, 46, 40, 40, 40, 40, 40, # 35 | |
| 463 | + 40, 40, 40, 40, 40, 40, 40, 40, # 35 | |
| 464 | + 40, 40, 40, 40, 40, 40, 40, 40, # 35 | |
| 465 | + 40, 46, 40, 40, 40, 40, 40, 40, # 35 | |
| 466 | + 40, 46, 40, 40, 46, 40, 40, 40, # 35 | |
| 467 | + 40, 40, 46, 46, 60, 40, 80, 80, # 35 | |
| 468 | + 80, 60, 60, 60, 60, 60, 46, 60, # 36 | |
| 469 | + 60, 80, 46, 80, 80, 60, 46, 46, # 36 | |
| 470 | + 15, 46, 46, 46, 46, 46, 46, 46, # 36 | |
| 471 | + 46, 46, 46, 46, 46, 46, 46, 46, # 36 | |
| 472 | + 40, 46, 46, 46, 46, 46, 81, 81, # 36 | |
| 473 | + 81, 81, 81, 81, 81, 81, 81, 81, # 36 | |
| 474 | + 46, 46, 46, 46, 46, 46, 46, 46, # 36 | |
| 475 | + 46, 46, 46, 46, 46, 46, 46, 46, # 36 | |
| 476 | + 46, 60, 80, 80, 46, 40, 40, 40, # 37 | |
| 477 | + 40, 40, 40, 40, 40, 46, 46, 40, # 37 | |
| 478 | + 40, 46, 46, 40, 40, 40, 40, 40, # 37 | |
| 479 | + 40, 40, 40, 40, 40, 40, 40, 40, # 37 | |
| 480 | + 40, 40, 40, 40, 40, 40, 40, 40, # 37 | |
| 481 | + 40, 46, 40, 40, 40, 40, 40, 40, # 37 | |
| 482 | + 40, 46, 40, 40, 46, 46, 40, 40, # 37 | |
| 483 | + 40, 40, 46, 46, 60, 40, 80, 60, # 37 | |
| 484 | + 80, 60, 60, 60, 46, 46, 46, 80, # 38 | |
| 485 | + 80, 46, 46, 80, 80, 60, 46, 46, # 38 | |
| 486 | + 46, 46, 46, 46, 46, 46, 60, 80, # 38 | |
| 487 | + 46, 46, 46, 46, 40, 40, 46, 40, # 38 | |
| 488 | + 40, 40, 46, 46, 46, 46, 81, 81, # 38 | |
| 489 | + 81, 81, 81, 81, 81, 81, 81, 81, # 38 | |
| 490 | + 15, 46, 46, 46, 46, 46, 46, 46, # 38 | |
| 491 | + 46, 46, 46, 46, 46, 46, 46, 46, # 38 | |
| 492 | + 46, 46, 60, 80, 46, 40, 40, 40, # 39 | |
| 493 | + 40, 40, 40, 46, 46, 46, 40, 40, # 39 | |
| 494 | + 40, 46, 40, 40, 40, 40, 46, 46, # 39 | |
| 495 | + 46, 40, 40, 46, 40, 46, 40, 40, # 39 | |
| 496 | + 46, 46, 46, 40, 40, 46, 46, 46, # 39 | |
| 497 | + 40, 40, 40, 46, 46, 46, 40, 40, # 39 | |
| 498 | + 40, 40, 40, 40, 40, 40, 46, 40, # 39 | |
| 499 | + 40, 40, 46, 46, 46, 46, 80, 80, # 39 | |
| 500 | + 60, 80, 80, 46, 46, 46, 80, 80, # 40 | |
| 501 | + 80, 46, 80, 80, 80, 60, 46, 46, # 40 | |
| 502 | + 46, 46, 46, 46, 46, 46, 46, 80, # 40 | |
| 503 | + 46, 46, 46, 46, 46, 46, 46, 46, # 40 | |
| 504 | + 46, 46, 46, 46, 46, 46, 46, 81, # 40 | |
| 505 | + 81, 81, 81, 81, 81, 81, 81, 81, # 40 | |
| 506 | + 84, 19, 19, 46, 46, 46, 46, 46, # 40 | |
| 507 | + 46, 46, 46, 46, 46, 46, 46, 46, # 40 | |
| 508 | + 46, 80, 80, 80, 46, 40, 40, 40, # 41 | |
| 509 | + 40, 40, 40, 40, 40, 46, 40, 40, # 41 | |
| 510 | + 40, 46, 40, 40, 40, 40, 40, 40, # 41 | |
| 511 | + 40, 40, 40, 40, 40, 40, 40, 40, # 41 | |
| 512 | + 40, 40, 40, 40, 40, 40, 40, 40, # 41 | |
| 513 | + 40, 46, 40, 40, 40, 40, 40, 40, # 41 | |
| 514 | + 40, 40, 40, 40, 46, 40, 40, 40, # 41 | |
| 515 | + 40, 40, 46, 46, 46, 46, 60, 60, # 41 | |
| 516 | + 60, 80, 80, 80, 80, 46, 60, 60, # 42 | |
| 517 | + 60, 46, 60, 60, 60, 60, 46, 46, # 42 | |
| 518 | + 46, 46, 46, 46, 46, 60, 60, 46, # 42 | |
| 519 | + 46, 46, 46, 46, 46, 46, 46, 46, # 42 | |
| 520 | + 40, 40, 46, 46, 46, 46, 81, 81, # 42 | |
| 521 | + 81, 81, 81, 81, 81, 81, 81, 81, # 42 | |
| 522 | + 46, 46, 46, 46, 46, 46, 46, 46, # 42 | |
| 523 | + 46, 46, 46, 46, 46, 46, 46, 46, # 42 | |
| 524 | + 46, 46, 80, 80, 46, 40, 40, 40, # 43 | |
| 525 | + 40, 40, 40, 40, 40, 46, 40, 40, # 43 | |
| 526 | + 40, 46, 40, 40, 40, 40, 40, 40, # 43 | |
| 527 | + 40, 40, 40, 40, 40, 40, 40, 40, # 43 | |
| 528 | + 40, 40, 40, 40, 40, 40, 40, 40, # 43 | |
| 529 | + 40, 46, 40, 40, 40, 40, 40, 40, # 43 | |
| 530 | + 40, 40, 40, 40, 46, 40, 40, 40, # 43 | |
| 531 | + 40, 40, 46, 46, 46, 46, 80, 60, # 43 | |
| 532 | + 80, 80, 80, 80, 80, 46, 60, 80, # 44 | |
| 533 | + 80, 46, 80, 80, 60, 60, 46, 46, # 44 | |
| 534 | + 46, 46, 46, 46, 46, 80, 80, 46, # 44 | |
| 535 | + 46, 46, 46, 46, 46, 46, 40, 46, # 44 | |
| 536 | + 40, 40, 46, 46, 46, 46, 81, 81, # 44 | |
| 537 | + 81, 81, 81, 81, 81, 81, 81, 81, # 44 | |
| 538 | + 46, 46, 46, 46, 46, 46, 46, 46, # 44 | |
| 539 | + 46, 46, 46, 46, 46, 46, 46, 46, # 44 | |
| 540 | + 46, 46, 80, 80, 46, 40, 40, 40, # 45 | |
| 541 | + 40, 40, 40, 40, 40, 46, 40, 40, # 45 | |
| 542 | + 40, 46, 40, 40, 40, 40, 40, 40, # 45 | |
| 543 | + 40, 40, 40, 40, 40, 40, 40, 40, # 45 | |
| 544 | + 40, 40, 40, 40, 40, 40, 40, 40, # 45 | |
| 545 | + 40, 46, 40, 40, 40, 40, 40, 40, # 45 | |
| 546 | + 40, 40, 40, 40, 40, 40, 40, 40, # 45 | |
| 547 | + 40, 40, 46, 46, 46, 46, 80, 80, # 45 | |
| 548 | + 80, 60, 60, 60, 46, 46, 80, 80, # 46 | |
| 549 | + 80, 46, 80, 80, 80, 60, 46, 46, # 46 | |
| 550 | + 46, 46, 46, 46, 46, 46, 46, 80, # 46 | |
| 551 | + 46, 46, 46, 46, 46, 46, 46, 46, # 46 | |
| 552 | + 40, 40, 46, 46, 46, 46, 81, 81, # 46 | |
| 553 | + 81, 81, 81, 81, 81, 81, 81, 81, # 46 | |
| 554 | + 46, 46, 46, 46, 46, 46, 46, 46, # 46 | |
| 555 | + 46, 46, 46, 46, 46, 46, 46, 46, # 46 | |
| 556 | + 46, 40, 40, 40, 40, 40, 40, 40, # 47 | |
| 557 | + 40, 40, 40, 40, 40, 40, 40, 40, # 47 | |
| 558 | + 40, 40, 40, 40, 40, 40, 40, 40, # 47 | |
| 559 | + 40, 40, 40, 40, 40, 40, 40, 40, # 47 | |
| 560 | + 40, 40, 40, 40, 40, 40, 40, 40, # 47 | |
| 561 | + 40, 40, 40, 40, 40, 40, 40, 3, # 47 | |
| 562 | + 40, 60, 40, 40, 60, 60, 60, 60, # 47 | |
| 563 | + 60, 60, 60, 46, 46, 46, 46, 4, # 47 | |
| 564 | + 40, 40, 40, 40, 40, 40, 59, 60, # 48 | |
| 565 | + 60, 60, 60, 60, 60, 60, 60, 15, # 48 | |
| 566 | + 9, 9, 9, 9, 9, 9, 9, 9, # 48 | |
| 567 | + 9, 9, 3, 3, 46, 46, 46, 46, # 48 | |
| 568 | + 46, 46, 46, 46, 46, 46, 46, 46, # 48 | |
| 569 | + 46, 46, 46, 46, 46, 46, 46, 46, # 48 | |
| 570 | + 46, 46, 46, 46, 46, 46, 46, 46, # 48 | |
| 571 | + 46, 46, 46, 46, 46, 46, 46, 46, # 48 | |
| 572 | + 46, 40, 40, 46, 40, 46, 46, 40, # 49 | |
| 573 | + 40, 46, 40, 46, 46, 40, 46, 46, # 49 | |
| 574 | + 46, 46, 46, 46, 40, 40, 40, 40, # 49 | |
| 575 | + 46, 40, 40, 40, 40, 40, 40, 40, # 49 | |
| 576 | + 46, 40, 40, 40, 46, 40, 46, 40, # 49 | |
| 577 | + 46, 46, 40, 40, 46, 40, 40, 3, # 49 | |
| 578 | + 40, 60, 40, 40, 60, 60, 60, 60, # 49 | |
| 579 | + 60, 60, 46, 60, 60, 40, 46, 46, # 49 | |
| 580 | + 40, 40, 40, 40, 40, 46, 59, 46, # 50 | |
| 581 | + 60, 60, 60, 60, 60, 60, 46, 46, # 50 | |
| 582 | + 9, 9, 9, 9, 9, 9, 9, 9, # 50 | |
| 583 | + 9, 9, 46, 46, 40, 40, 46, 46, # 50 | |
| 584 | + 46, 46, 46, 46, 46, 46, 46, 46, # 50 | |
| 585 | + 46, 46, 46, 46, 46, 46, 46, 46, # 50 | |
| 586 | + 46, 46, 46, 46, 46, 46, 46, 46, # 50 | |
| 587 | + 46, 46, 46, 46, 46, 46, 46, 46, # 50 | |
| 588 | + 15, 15, 15, 15, 3, 3, 3, 3, # 51 | |
| 589 | + 3, 3, 3, 3, 3, 3, 3, 3, # 51 | |
| 590 | + 3, 3, 3, 15, 15, 15, 15, 15, # 51 | |
| 591 | + 60, 60, 15, 15, 15, 15, 15, 15, # 51 | |
| 592 | + 78, 78, 78, 78, 78, 78, 78, 78, # 51 | |
| 593 | + 78, 78, 85, 85, 85, 85, 85, 85, # 51 | |
| 594 | + 85, 85, 85, 85, 15, 60, 15, 60, # 51 | |
| 595 | + 15, 60, 5, 6, 5, 6, 80, 80, # 51 | |
| 596 | + 40, 40, 40, 40, 40, 40, 40, 40, # 52 | |
| 597 | + 46, 40, 40, 40, 40, 40, 40, 40, # 52 | |
| 598 | + 40, 40, 40, 40, 40, 40, 40, 40, # 52 | |
| 599 | + 40, 40, 40, 40, 40, 40, 40, 40, # 52 | |
| 600 | + 40, 40, 40, 40, 40, 40, 40, 40, # 52 | |
| 601 | + 40, 40, 46, 46, 46, 46, 46, 46, # 52 | |
| 602 | + 46, 60, 60, 60, 60, 60, 60, 60, # 52 | |
| 603 | + 60, 60, 60, 60, 60, 60, 60, 80, # 52 | |
| 604 | + 60, 60, 60, 60, 60, 3, 60, 60, # 53 | |
| 605 | + 60, 60, 60, 60, 46, 46, 46, 46, # 53 | |
| 606 | + 60, 60, 60, 60, 60, 60, 46, 60, # 53 | |
| 607 | + 46, 60, 60, 60, 60, 60, 60, 60, # 53 | |
| 608 | + 60, 60, 60, 60, 60, 60, 60, 60, # 53 | |
| 609 | + 60, 60, 60, 60, 60, 60, 46, 46, # 53 | |
| 610 | + 46, 60, 60, 60, 60, 60, 60, 60, # 53 | |
| 611 | + 46, 60, 46, 46, 46, 46, 46, 46, # 53 | |
| 612 | + 46, 46, 46, 46, 46, 46, 46, 46, # 54 | |
| 613 | + 46, 46, 46, 46, 46, 46, 46, 46, # 54 | |
| 614 | + 46, 46, 46, 46, 46, 46, 46, 46, # 54 | |
| 615 | + 46, 46, 46, 46, 46, 46, 46, 46, # 54 | |
| 616 | + 76, 76, 76, 76, 76, 76, 76, 76, # 54 | |
| 617 | + 76, 76, 76, 76, 76, 76, 76, 76, # 54 | |
| 618 | + 76, 76, 76, 76, 76, 76, 76, 76, # 54 | |
| 619 | + 76, 76, 76, 76, 76, 76, 76, 76, # 54 | |
| 620 | + 76, 76, 76, 76, 76, 76, 46, 46, # 55 | |
| 621 | + 46, 46, 46, 46, 46, 46, 46, 46, # 55 | |
| 622 | + 16, 16, 16, 16, 16, 16, 16, 16, # 55 | |
| 623 | + 16, 16, 16, 16, 16, 16, 16, 16, # 55 | |
| 624 | + 16, 16, 16, 16, 16, 16, 16, 16, # 55 | |
| 625 | + 16, 16, 16, 16, 16, 16, 16, 16, # 55 | |
| 626 | + 16, 16, 16, 16, 16, 16, 16, 46, # 55 | |
| 627 | + 46, 46, 46, 3, 46, 46, 46, 46, # 55 | |
| 628 | + 40, 40, 40, 40, 40, 40, 40, 40, # 56 | |
| 629 | + 40, 40, 40, 40, 40, 40, 40, 40, # 56 | |
| 630 | + 40, 40, 40, 40, 40, 40, 40, 40, # 56 | |
| 631 | + 40, 40, 40, 40, 40, 40, 40, 40, # 56 | |
| 632 | + 40, 40, 40, 40, 40, 40, 40, 40, # 56 | |
| 633 | + 40, 40, 40, 40, 40, 40, 40, 40, # 56 | |
| 634 | + 40, 40, 40, 40, 40, 40, 40, 40, # 56 | |
| 635 | + 40, 40, 40, 40, 40, 40, 40, 40, # 56 | |
| 636 | + 40, 40, 40, 40, 40, 40, 40, 40, # 57 | |
| 637 | + 40, 40, 40, 40, 40, 40, 40, 40, # 57 | |
| 638 | + 40, 40, 40, 40, 40, 40, 40, 40, # 57 | |
| 639 | + 40, 40, 46, 46, 46, 46, 46, 40, # 57 | |
| 640 | + 40, 40, 40, 40, 40, 40, 40, 40, # 57 | |
| 641 | + 40, 40, 40, 40, 40, 40, 40, 40, # 57 | |
| 642 | + 40, 40, 40, 40, 40, 40, 40, 40, # 57 | |
| 643 | + 40, 40, 40, 40, 40, 40, 40, 40, # 57 | |
| 644 | + 40, 40, 40, 40, 40, 40, 40, 40, # 58 | |
| 645 | + 40, 40, 40, 40, 40, 40, 40, 40, # 58 | |
| 646 | + 40, 40, 40, 40, 40, 40, 40, 40, # 58 | |
| 647 | + 40, 40, 40, 40, 40, 40, 40, 40, # 58 | |
| 648 | + 40, 40, 40, 46, 46, 46, 46, 46, # 58 | |
| 649 | + 40, 40, 40, 40, 40, 40, 40, 40, # 58 | |
| 650 | + 40, 40, 40, 40, 40, 40, 40, 40, # 58 | |
| 651 | + 40, 40, 40, 40, 40, 40, 40, 40, # 58 | |
| 652 | + 40, 40, 40, 40, 40, 40, 40, 40, # 59 | |
| 653 | + 40, 40, 40, 40, 40, 40, 40, 40, # 59 | |
| 654 | + 40, 40, 40, 40, 40, 40, 40, 40, # 59 | |
| 655 | + 40, 40, 40, 40, 40, 40, 40, 40, # 59 | |
| 656 | + 40, 40, 40, 40, 40, 40, 40, 40, # 59 | |
| 657 | + 40, 40, 40, 40, 40, 40, 40, 40, # 59 | |
| 658 | + 40, 40, 40, 40, 40, 40, 40, 40, # 59 | |
| 659 | + 40, 40, 46, 46, 46, 46, 46, 46, # 59 | |
| 660 | + 23, 24, 23, 24, 23, 24, 23, 24, # 60 | |
| 661 | + 23, 24, 23, 24, 23, 24, 23, 24, # 60 | |
| 662 | + 23, 24, 23, 24, 23, 24, 23, 24, # 60 | |
| 663 | + 23, 24, 23, 24, 23, 24, 23, 24, # 60 | |
| 664 | + 23, 24, 23, 24, 23, 24, 23, 24, # 60 | |
| 665 | + 23, 24, 23, 24, 23, 24, 23, 24, # 60 | |
| 666 | + 23, 24, 23, 24, 23, 24, 23, 24, # 60 | |
| 667 | + 23, 24, 23, 24, 23, 24, 23, 24, # 60 | |
| 668 | + 23, 24, 23, 24, 23, 24, 23, 24, # 61 | |
| 669 | + 23, 24, 23, 24, 23, 24, 23, 24, # 61 | |
| 670 | + 23, 24, 23, 24, 23, 24, 16, 16, # 61 | |
| 671 | + 16, 16, 16, 16, 46, 46, 46, 46, # 61 | |
| 672 | + 23, 24, 23, 24, 23, 24, 23, 24, # 61 | |
| 673 | + 23, 24, 23, 24, 23, 24, 23, 24, # 61 | |
| 674 | + 23, 24, 23, 24, 23, 24, 23, 24, # 61 | |
| 675 | + 23, 24, 23, 24, 23, 24, 23, 24, # 61 | |
| 676 | + 23, 24, 23, 24, 23, 24, 23, 24, # 62 | |
| 677 | + 23, 24, 23, 24, 23, 24, 23, 24, # 62 | |
| 678 | + 23, 24, 23, 24, 23, 24, 23, 24, # 62 | |
| 679 | + 23, 24, 23, 24, 23, 24, 23, 24, # 62 | |
| 680 | + 23, 24, 23, 24, 23, 24, 23, 24, # 62 | |
| 681 | + 23, 24, 23, 24, 23, 24, 23, 24, # 62 | |
| 682 | + 23, 24, 23, 24, 23, 24, 23, 24, # 62 | |
| 683 | + 23, 24, 46, 46, 46, 46, 46, 46, # 62 | |
| 684 | + 86, 86, 86, 86, 86, 86, 86, 86, # 63 | |
| 685 | + 87, 87, 87, 87, 87, 87, 87, 87, # 63 | |
| 686 | + 86, 86, 86, 86, 86, 86, 46, 46, # 63 | |
| 687 | + 87, 87, 87, 87, 87, 87, 46, 46, # 63 | |
| 688 | + 86, 86, 86, 86, 86, 86, 86, 86, # 63 | |
| 689 | + 87, 87, 87, 87, 87, 87, 87, 87, # 63 | |
| 690 | + 86, 86, 86, 86, 86, 86, 86, 86, # 63 | |
| 691 | + 87, 87, 87, 87, 87, 87, 87, 87, # 63 | |
| 692 | + 86, 86, 86, 86, 86, 86, 46, 46, # 64 | |
| 693 | + 87, 87, 87, 87, 87, 87, 46, 46, # 64 | |
| 694 | + 16, 86, 16, 86, 16, 86, 16, 86, # 64 | |
| 695 | + 46, 87, 46, 87, 46, 87, 46, 87, # 64 | |
| 696 | + 86, 86, 86, 86, 86, 86, 86, 86, # 64 | |
| 697 | + 87, 87, 87, 87, 87, 87, 87, 87, # 64 | |
| 698 | + 88, 88, 89, 89, 89, 89, 90, 90, # 64 | |
| 699 | + 91, 91, 92, 92, 93, 93, 46, 46, # 64 | |
| 700 | + 86, 86, 86, 86, 86, 86, 86, 86, # 65 | |
| 701 | + 87, 87, 87, 87, 87, 87, 87, 87, # 65 | |
| 702 | + 86, 86, 86, 86, 86, 86, 86, 86, # 65 | |
| 703 | + 87, 87, 87, 87, 87, 87, 87, 87, # 65 | |
| 704 | + 86, 86, 86, 86, 86, 86, 86, 86, # 65 | |
| 705 | + 87, 87, 87, 87, 87, 87, 87, 87, # 65 | |
| 706 | + 86, 86, 16, 94, 16, 46, 16, 16, # 65 | |
| 707 | + 87, 87, 95, 95, 96, 11, 38, 11, # 65 | |
| 708 | + 11, 11, 16, 94, 16, 46, 16, 16, # 66 | |
| 709 | + 97, 97, 97, 97, 96, 11, 11, 11, # 66 | |
| 710 | + 86, 86, 16, 16, 46, 46, 16, 16, # 66 | |
| 711 | + 87, 87, 98, 98, 46, 11, 11, 11, # 66 | |
| 712 | + 86, 86, 16, 16, 16, 99, 16, 16, # 66 | |
| 713 | + 87, 87, 100, 100, 101, 11, 11, 11, # 66 | |
| 714 | + 46, 46, 16, 94, 16, 46, 16, 16, # 66 | |
| 715 | + 102, 102, 103, 103, 96, 11, 11, 46, # 66 | |
| 716 | + 2, 2, 2, 2, 2, 2, 2, 2, # 67 | |
| 717 | + 2, 2, 2, 2, 104, 104, 104, 104, # 67 | |
| 718 | + 8, 8, 8, 8, 8, 8, 3, 3, # 67 | |
| 719 | + 5, 6, 5, 5, 5, 6, 5, 5, # 67 | |
| 720 | + 3, 3, 3, 3, 3, 3, 3, 3, # 67 | |
| 721 | + 105, 106, 104, 104, 104, 104, 104, 46, # 67 | |
| 722 | + 3, 3, 3, 3, 3, 3, 3, 3, # 67 | |
| 723 | + 3, 5, 6, 3, 3, 3, 3, 12, # 67 | |
| 724 | + 12, 3, 3, 3, 7, 5, 6, 46, # 68 | |
| 725 | + 46, 46, 46, 46, 46, 46, 46, 46, # 68 | |
| 726 | + 46, 46, 46, 46, 46, 46, 46, 46, # 68 | |
| 727 | + 46, 46, 46, 46, 46, 46, 46, 46, # 68 | |
| 728 | + 46, 46, 46, 46, 46, 46, 46, 46, # 68 | |
| 729 | + 46, 46, 104, 104, 104, 104, 104, 104, # 68 | |
| 730 | + 17, 46, 46, 46, 17, 17, 17, 17, # 68 | |
| 731 | + 17, 17, 7, 7, 7, 5, 6, 16, # 68 | |
| 732 | + 107, 107, 107, 107, 107, 107, 107, 107, # 69 | |
| 733 | + 107, 107, 7, 7, 7, 5, 6, 46, # 69 | |
| 734 | + 46, 46, 46, 46, 46, 46, 46, 46, # 69 | |
| 735 | + 46, 46, 46, 46, 46, 46, 46, 46, # 69 | |
| 736 | + 4, 4, 4, 4, 4, 4, 4, 4, # 69 | |
| 737 | + 4, 4, 4, 4, 46, 46, 46, 46, # 69 | |
| 738 | + 46, 46, 46, 46, 46, 46, 46, 46, # 69 | |
| 739 | + 46, 46, 46, 46, 46, 46, 46, 46, # 69 | |
| 740 | + 46, 46, 46, 46, 46, 46, 46, 46, # 70 | |
| 741 | + 46, 46, 46, 46, 46, 46, 46, 46, # 70 | |
| 742 | + 60, 60, 60, 60, 60, 60, 60, 60, # 70 | |
| 743 | + 60, 60, 60, 60, 60, 79, 79, 79, # 70 | |
| 744 | + 79, 60, 46, 46, 46, 46, 46, 46, # 70 | |
| 745 | + 46, 46, 46, 46, 46, 46, 46, 46, # 70 | |
| 746 | + 46, 46, 46, 46, 46, 46, 46, 46, # 70 | |
| 747 | + 46, 46, 46, 46, 46, 46, 46, 46, # 70 | |
| 748 | + 15, 15, 38, 15, 15, 15, 15, 38, # 71 | |
| 749 | + 15, 15, 16, 38, 38, 38, 16, 16, # 71 | |
| 750 | + 38, 38, 38, 16, 15, 38, 15, 15, # 71 | |
| 751 | + 38, 38, 38, 38, 38, 38, 15, 15, # 71 | |
| 752 | + 15, 15, 15, 15, 38, 15, 38, 15, # 71 | |
| 753 | + 38, 15, 38, 38, 38, 38, 16, 16, # 71 | |
| 754 | + 38, 38, 15, 38, 16, 40, 40, 40, # 71 | |
| 755 | + 40, 46, 46, 46, 46, 46, 46, 46, # 71 | |
| 756 | + 46, 46, 46, 46, 46, 46, 46, 46, # 72 | |
| 757 | + 46, 46, 46, 46, 46, 46, 46, 46, # 72 | |
| 758 | + 46, 46, 46, 19, 19, 19, 19, 19, # 72 | |
| 759 | + 19, 19, 19, 19, 19, 19, 19, 108, # 72 | |
| 760 | + 109, 109, 109, 109, 109, 109, 109, 109, # 72 | |
| 761 | + 109, 109, 109, 109, 110, 110, 110, 110, # 72 | |
| 762 | + 111, 111, 111, 111, 111, 111, 111, 111, # 72 | |
| 763 | + 111, 111, 111, 111, 112, 112, 112, 112, # 72 | |
| 764 | + 113, 113, 113, 46, 46, 46, 46, 46, # 73 | |
| 765 | + 46, 46, 46, 46, 46, 46, 46, 46, # 73 | |
| 766 | + 7, 7, 7, 7, 7, 15, 15, 15, # 73 | |
| 767 | + 15, 15, 15, 15, 15, 15, 15, 15, # 73 | |
| 768 | + 15, 15, 15, 15, 15, 15, 15, 15, # 73 | |
| 769 | + 15, 15, 15, 15, 15, 15, 15, 15, # 73 | |
| 770 | + 15, 15, 15, 15, 15, 15, 15, 15, # 73 | |
| 771 | + 15, 15, 15, 15, 15, 15, 15, 15, # 73 | |
| 772 | + 15, 15, 15, 15, 15, 15, 15, 15, # 74 | |
| 773 | + 15, 15, 15, 15, 15, 15, 15, 15, # 74 | |
| 774 | + 15, 15, 7, 15, 7, 15, 15, 15, # 74 | |
| 775 | + 15, 15, 15, 15, 15, 15, 15, 15, # 74 | |
| 776 | + 15, 15, 15, 15, 15, 15, 15, 15, # 74 | |
| 777 | + 15, 15, 15, 46, 46, 46, 46, 46, # 74 | |
| 778 | + 46, 46, 46, 46, 46, 46, 46, 46, # 74 | |
| 779 | + 46, 46, 46, 46, 46, 46, 46, 46, # 74 | |
| 780 | + 7, 7, 7, 7, 7, 7, 7, 7, # 75 | |
| 781 | + 7, 7, 7, 7, 7, 7, 7, 7, # 75 | |
| 782 | + 7, 7, 7, 7, 7, 7, 7, 7, # 75 | |
| 783 | + 7, 7, 7, 7, 7, 7, 7, 7, # 75 | |
| 784 | + 7, 7, 7, 7, 7, 7, 7, 7, # 75 | |
| 785 | + 7, 7, 7, 7, 7, 7, 7, 7, # 75 | |
| 786 | + 7, 7, 7, 7, 7, 7, 7, 7, # 75 | |
| 787 | + 7, 7, 7, 7, 7, 7, 7, 7, # 75 | |
| 788 | + 7, 7, 7, 7, 7, 7, 7, 7, # 76 | |
| 789 | + 7, 7, 7, 7, 7, 7, 7, 7, # 76 | |
| 790 | + 7, 7, 7, 7, 7, 7, 7, 7, # 76 | |
| 791 | + 7, 7, 7, 7, 7, 7, 7, 7, # 76 | |
| 792 | + 7, 7, 7, 7, 7, 7, 7, 7, # 76 | |
| 793 | + 7, 7, 7, 7, 7, 7, 7, 7, # 76 | |
| 794 | + 7, 7, 46, 46, 46, 46, 46, 46, # 76 | |
| 795 | + 46, 46, 46, 46, 46, 46, 46, 46, # 76 | |
| 796 | + 15, 46, 15, 15, 15, 15, 15, 15, # 77 | |
| 797 | + 7, 7, 7, 7, 15, 15, 15, 15, # 77 | |
| 798 | + 15, 15, 15, 15, 15, 15, 15, 15, # 77 | |
| 799 | + 15, 15, 15, 15, 15, 15, 15, 15, # 77 | |
| 800 | + 7, 7, 15, 15, 15, 15, 15, 15, # 77 | |
| 801 | + 15, 5, 6, 15, 15, 15, 15, 15, # 77 | |
| 802 | + 15, 15, 15, 15, 15, 15, 15, 15, # 77 | |
| 803 | + 15, 15, 15, 15, 15, 15, 15, 15, # 77 | |
| 804 | + 15, 15, 15, 15, 15, 15, 15, 15, # 78 | |
| 805 | + 15, 15, 15, 15, 15, 15, 15, 15, # 78 | |
| 806 | + 15, 15, 15, 15, 15, 15, 15, 15, # 78 | |
| 807 | + 15, 15, 15, 15, 15, 15, 15, 15, # 78 | |
| 808 | + 15, 15, 15, 15, 15, 15, 15, 15, # 78 | |
| 809 | + 15, 15, 15, 15, 15, 15, 15, 15, # 78 | |
| 810 | + 15, 15, 15, 15, 15, 15, 15, 15, # 78 | |
| 811 | + 15, 15, 15, 46, 46, 46, 46, 46, # 78 | |
| 812 | + 15, 15, 15, 15, 15, 15, 15, 15, # 79 | |
| 813 | + 15, 15, 15, 15, 15, 15, 15, 15, # 79 | |
| 814 | + 15, 15, 15, 15, 15, 15, 15, 15, # 79 | |
| 815 | + 15, 15, 15, 15, 15, 15, 15, 15, # 79 | |
| 816 | + 15, 15, 15, 15, 15, 46, 46, 46, # 79 | |
| 817 | + 46, 46, 46, 46, 46, 46, 46, 46, # 79 | |
| 818 | + 46, 46, 46, 46, 46, 46, 46, 46, # 79 | |
| 819 | + 46, 46, 46, 46, 46, 46, 46, 46, # 79 | |
| 820 | + 15, 15, 15, 15, 15, 15, 15, 15, # 80 | |
| 821 | + 15, 15, 15, 46, 46, 46, 46, 46, # 80 | |
| 822 | + 46, 46, 46, 46, 46, 46, 46, 46, # 80 | |
| 823 | + 46, 46, 46, 46, 46, 46, 46, 46, # 80 | |
| 824 | + 114, 114, 114, 114, 114, 114, 114, 114, # 80 | |
| 825 | + 114, 114, 114, 114, 114, 114, 114, 114, # 80 | |
| 826 | + 114, 114, 114, 114, 82, 82, 82, 82, # 80 | |
| 827 | + 82, 82, 82, 82, 82, 82, 82, 82, # 80 | |
| 828 | + 82, 82, 82, 82, 82, 82, 82, 82, # 81 | |
| 829 | + 115, 115, 115, 115, 115, 115, 115, 115, # 81 | |
| 830 | + 115, 115, 115, 115, 115, 115, 115, 115, # 81 | |
| 831 | + 115, 115, 115, 115, 15, 15, 15, 15, # 81 | |
| 832 | + 15, 15, 15, 15, 15, 15, 15, 15, # 81 | |
| 833 | + 15, 15, 15, 15, 15, 15, 15, 15, # 81 | |
| 834 | + 15, 15, 15, 15, 15, 15, 116, 116, # 81 | |
| 835 | + 116, 116, 116, 116, 116, 116, 116, 116, # 81 | |
| 836 | + 116, 116, 116, 116, 116, 116, 116, 116, # 82 | |
| 837 | + 116, 116, 116, 116, 116, 116, 116, 116, # 82 | |
| 838 | + 117, 117, 117, 117, 117, 117, 117, 117, # 82 | |
| 839 | + 117, 117, 117, 117, 117, 117, 117, 117, # 82 | |
| 840 | + 117, 117, 117, 117, 117, 117, 117, 117, # 82 | |
| 841 | + 117, 117, 118, 46, 46, 46, 46, 46, # 82 | |
| 842 | + 46, 46, 46, 46, 46, 46, 46, 46, # 82 | |
| 843 | + 46, 46, 46, 46, 46, 46, 46, 46, # 82 | |
| 844 | + 15, 15, 15, 15, 15, 15, 15, 15, # 83 | |
| 845 | + 15, 15, 15, 15, 15, 15, 15, 15, # 83 | |
| 846 | + 15, 15, 15, 15, 15, 15, 15, 15, # 83 | |
| 847 | + 15, 15, 15, 15, 15, 15, 15, 15, # 83 | |
| 848 | + 15, 15, 15, 15, 15, 15, 15, 15, # 83 | |
| 849 | + 15, 15, 15, 15, 15, 15, 15, 15, # 83 | |
| 850 | + 15, 15, 15, 15, 15, 15, 15, 15, # 83 | |
| 851 | + 15, 15, 15, 15, 15, 15, 15, 15, # 83 | |
| 852 | + 15, 15, 15, 15, 15, 15, 15, 15, # 84 | |
| 853 | + 15, 15, 15, 15, 15, 15, 15, 15, # 84 | |
| 854 | + 15, 15, 15, 15, 15, 15, 46, 46, # 84 | |
| 855 | + 46, 46, 46, 46, 46, 46, 46, 46, # 84 | |
| 856 | + 15, 15, 15, 15, 15, 15, 15, 15, # 84 | |
| 857 | + 15, 15, 15, 15, 15, 15, 15, 15, # 84 | |
| 858 | + 15, 15, 15, 15, 15, 15, 15, 15, # 84 | |
| 859 | + 15, 15, 15, 15, 15, 15, 15, 15, # 84 | |
| 860 | + 15, 15, 15, 15, 15, 15, 15, 15, # 85 | |
| 861 | + 15, 15, 15, 15, 15, 15, 15, 15, # 85 | |
| 862 | + 15, 15, 15, 15, 15, 15, 15, 15, # 85 | |
| 863 | + 15, 15, 15, 15, 15, 15, 15, 15, # 85 | |
| 864 | + 15, 15, 15, 15, 15, 15, 15, 15, # 85 | |
| 865 | + 15, 15, 15, 15, 15, 15, 15, 15, # 85 | |
| 866 | + 46, 46, 46, 46, 46, 46, 46, 46, # 85 | |
| 867 | + 46, 46, 46, 46, 46, 46, 46, 46, # 85 | |
| 868 | + 15, 15, 15, 15, 15, 15, 15, 15, # 86 | |
| 869 | + 15, 15, 15, 15, 15, 15, 15, 15, # 86 | |
| 870 | + 15, 15, 15, 15, 46, 46, 46, 46, # 86 | |
| 871 | + 46, 46, 15, 15, 15, 15, 15, 15, # 86 | |
| 872 | + 15, 15, 15, 15, 15, 15, 15, 15, # 86 | |
| 873 | + 15, 15, 15, 15, 15, 15, 15, 15, # 86 | |
| 874 | + 15, 15, 15, 15, 15, 15, 15, 15, # 86 | |
| 875 | + 15, 15, 15, 15, 15, 15, 15, 15, # 86 | |
| 876 | + 46, 15, 15, 15, 15, 46, 15, 15, # 87 | |
| 877 | + 15, 15, 46, 46, 15, 15, 15, 15, # 87 | |
| 878 | + 15, 15, 15, 15, 15, 15, 15, 15, # 87 | |
| 879 | + 15, 15, 15, 15, 15, 15, 15, 15, # 87 | |
| 880 | + 15, 15, 15, 15, 15, 15, 15, 15, # 87 | |
| 881 | + 46, 15, 15, 15, 15, 15, 15, 15, # 87 | |
| 882 | + 15, 15, 15, 15, 15, 15, 15, 15, # 87 | |
| 883 | + 15, 15, 15, 15, 15, 15, 15, 15, # 87 | |
| 884 | + 15, 15, 15, 15, 15, 15, 15, 15, # 88 | |
| 885 | + 15, 15, 15, 15, 46, 15, 46, 15, # 88 | |
| 886 | + 15, 15, 15, 46, 46, 46, 15, 46, # 88 | |
| 887 | + 15, 15, 15, 15, 15, 15, 15, 46, # 88 | |
| 888 | + 46, 15, 15, 15, 15, 15, 15, 15, # 88 | |
| 889 | + 46, 46, 46, 46, 46, 46, 46, 46, # 88 | |
| 890 | + 46, 46, 46, 46, 46, 46, 119, 119, # 88 | |
| 891 | + 119, 119, 119, 119, 119, 119, 119, 119, # 88 | |
| 892 | + 114, 114, 114, 114, 114, 114, 114, 114, # 89 | |
| 893 | + 114, 114, 83, 83, 83, 83, 83, 83, # 89 | |
| 894 | + 83, 83, 83, 83, 15, 46, 46, 46, # 89 | |
| 895 | + 15, 15, 15, 15, 15, 15, 15, 15, # 89 | |
| 896 | + 15, 15, 15, 15, 15, 15, 15, 15, # 89 | |
| 897 | + 15, 15, 15, 15, 15, 15, 15, 15, # 89 | |
| 898 | + 46, 15, 15, 15, 15, 15, 15, 15, # 89 | |
| 899 | + 15, 15, 15, 15, 15, 15, 15, 46, # 89 | |
| 900 | + 2, 3, 3, 3, 15, 59, 3, 120, # 90 | |
| 901 | + 5, 6, 5, 6, 5, 6, 5, 6, # 90 | |
| 902 | + 5, 6, 15, 15, 5, 6, 5, 6, # 90 | |
| 903 | + 5, 6, 5, 6, 8, 5, 6, 5, # 90 | |
| 904 | + 15, 121, 121, 121, 121, 121, 121, 121, # 90 | |
| 905 | + 121, 121, 60, 60, 60, 60, 60, 60, # 90 | |
| 906 | + 8, 59, 59, 59, 59, 59, 15, 15, # 90 | |
| 907 | + 46, 46, 46, 46, 46, 46, 46, 15, # 90 | |
| 908 | + 46, 40, 40, 40, 40, 40, 40, 40, # 91 | |
| 909 | + 40, 40, 40, 40, 40, 40, 40, 40, # 91 | |
| 910 | + 40, 40, 40, 40, 40, 40, 40, 40, # 91 | |
| 911 | + 40, 40, 40, 40, 40, 40, 40, 40, # 91 | |
| 912 | + 40, 40, 40, 40, 40, 40, 40, 40, # 91 | |
| 913 | + 40, 40, 40, 40, 40, 40, 40, 40, # 91 | |
| 914 | + 40, 40, 40, 40, 40, 40, 40, 40, # 91 | |
| 915 | + 40, 40, 40, 40, 40, 40, 40, 40, # 91 | |
| 916 | + 40, 40, 40, 40, 40, 40, 40, 40, # 92 | |
| 917 | + 40, 40, 40, 40, 40, 40, 40, 40, # 92 | |
| 918 | + 40, 40, 40, 40, 40, 46, 46, 46, # 92 | |
| 919 | + 46, 60, 60, 59, 59, 59, 59, 46, # 92 | |
| 920 | + 46, 40, 40, 40, 40, 40, 40, 40, # 92 | |
| 921 | + 40, 40, 40, 40, 40, 40, 40, 40, # 92 | |
| 922 | + 40, 40, 40, 40, 40, 40, 40, 40, # 92 | |
| 923 | + 40, 40, 40, 40, 40, 40, 40, 40, # 92 | |
| 924 | + 40, 40, 40, 40, 40, 40, 40, 40, # 93 | |
| 925 | + 40, 40, 40, 40, 40, 40, 40, 40, # 93 | |
| 926 | + 40, 40, 40, 40, 40, 40, 40, 40, # 93 | |
| 927 | + 40, 40, 40, 40, 40, 40, 40, 40, # 93 | |
| 928 | + 40, 40, 40, 40, 40, 40, 40, 40, # 93 | |
| 929 | + 40, 40, 40, 40, 40, 40, 40, 40, # 93 | |
| 930 | + 40, 40, 40, 40, 40, 40, 40, 40, # 93 | |
| 931 | + 40, 40, 40, 3, 59, 59, 59, 46, # 93 | |
| 932 | + 46, 46, 46, 46, 46, 40, 40, 40, # 94 | |
| 933 | + 40, 40, 40, 40, 40, 40, 40, 40, # 94 | |
| 934 | + 40, 40, 40, 40, 40, 40, 40, 40, # 94 | |
| 935 | + 40, 40, 40, 40, 40, 40, 40, 40, # 94 | |
| 936 | + 40, 40, 40, 40, 40, 40, 40, 40, # 94 | |
| 937 | + 40, 40, 40, 40, 40, 46, 46, 46, # 94 | |
| 938 | + 46, 40, 40, 40, 40, 40, 40, 40, # 94 | |
| 939 | + 40, 40, 40, 40, 40, 40, 40, 40, # 94 | |
| 940 | + 40, 40, 40, 40, 40, 40, 40, 40, # 95 | |
| 941 | + 40, 40, 40, 40, 40, 40, 40, 46, # 95 | |
| 942 | + 15, 15, 85, 85, 85, 85, 15, 15, # 95 | |
| 943 | + 15, 15, 15, 15, 15, 15, 15, 15, # 95 | |
| 944 | + 46, 46, 46, 46, 46, 46, 46, 46, # 95 | |
| 945 | + 46, 46, 46, 46, 46, 46, 46, 46, # 95 | |
| 946 | + 46, 46, 46, 46, 46, 46, 46, 46, # 95 | |
| 947 | + 46, 46, 46, 46, 46, 46, 46, 46, # 95 | |
| 948 | + 15, 15, 15, 15, 15, 15, 15, 15, # 96 | |
| 949 | + 15, 15, 15, 15, 15, 15, 15, 15, # 96 | |
| 950 | + 15, 15, 15, 15, 15, 15, 15, 15, # 96 | |
| 951 | + 15, 15, 15, 15, 15, 46, 46, 46, # 96 | |
| 952 | + 85, 85, 85, 85, 85, 85, 85, 85, # 96 | |
| 953 | + 85, 85, 15, 15, 15, 15, 15, 15, # 96 | |
| 954 | + 15, 15, 15, 15, 15, 15, 15, 15, # 96 | |
| 955 | + 15, 15, 15, 15, 15, 15, 15, 15, # 96 | |
| 956 | + 15, 15, 15, 15, 46, 46, 46, 46, # 97 | |
| 957 | + 46, 46, 46, 46, 46, 46, 46, 46, # 97 | |
| 958 | + 46, 46, 46, 46, 46, 46, 46, 46, # 97 | |
| 959 | + 46, 46, 46, 46, 46, 46, 46, 46, # 97 | |
| 960 | + 15, 15, 15, 15, 15, 15, 15, 15, # 97 | |
| 961 | + 15, 15, 15, 15, 15, 15, 15, 15, # 97 | |
| 962 | + 15, 15, 15, 15, 15, 15, 15, 15, # 97 | |
| 963 | + 15, 15, 15, 15, 46, 46, 46, 15, # 97 | |
| 964 | + 114, 114, 114, 114, 114, 114, 114, 114, # 98 | |
| 965 | + 114, 114, 15, 15, 15, 15, 15, 15, # 98 | |
| 966 | + 15, 15, 15, 15, 15, 15, 15, 15, # 98 | |
| 967 | + 15, 15, 15, 15, 15, 15, 15, 15, # 98 | |
| 968 | + 15, 15, 15, 15, 15, 15, 15, 15, # 98 | |
| 969 | + 15, 15, 15, 15, 15, 15, 15, 15, # 98 | |
| 970 | + 15, 46, 46, 46, 46, 46, 46, 46, # 98 | |
| 971 | + 46, 46, 46, 46, 46, 46, 46, 46, # 98 | |
| 972 | + 15, 15, 15, 15, 15, 15, 15, 15, # 99 | |
| 973 | + 15, 15, 15, 15, 46, 46, 46, 46, # 99 | |
| 974 | + 15, 15, 15, 15, 15, 15, 15, 15, # 99 | |
| 975 | + 15, 15, 15, 15, 15, 15, 15, 15, # 99 | |
| 976 | + 15, 15, 15, 15, 15, 15, 15, 15, # 99 | |
| 977 | + 15, 15, 15, 15, 15, 15, 15, 15, # 99 | |
| 978 | + 15, 15, 15, 15, 15, 15, 15, 15, # 99 | |
| 979 | + 15, 15, 15, 15, 15, 15, 15, 46, # 99 | |
| 980 | + 15, 15, 15, 15, 15, 15, 15, 15, # 100 | |
| 981 | + 15, 15, 15, 15, 15, 15, 15, 15, # 100 | |
| 982 | + 15, 15, 15, 15, 15, 15, 15, 15, # 100 | |
| 983 | + 15, 15, 15, 15, 15, 15, 15, 15, # 100 | |
| 984 | + 15, 15, 15, 15, 15, 15, 15, 15, # 100 | |
| 985 | + 15, 15, 15, 15, 15, 15, 15, 15, # 100 | |
| 986 | + 15, 15, 15, 15, 15, 15, 15, 46, # 100 | |
| 987 | + 46, 46, 46, 15, 15, 15, 15, 15, # 100 | |
| 988 | + 15, 15, 15, 15, 15, 15, 15, 15, # 101 | |
| 989 | + 15, 15, 15, 15, 15, 15, 15, 15, # 101 | |
| 990 | + 15, 15, 15, 15, 15, 15, 15, 15, # 101 | |
| 991 | + 15, 15, 15, 15, 15, 15, 46, 46, # 101 | |
| 992 | + 15, 15, 15, 15, 15, 15, 15, 15, # 101 | |
| 993 | + 15, 15, 15, 15, 15, 15, 15, 15, # 101 | |
| 994 | + 15, 15, 15, 15, 15, 15, 15, 15, # 101 | |
| 995 | + 15, 15, 15, 15, 15, 15, 15, 46, # 101 | |
| 996 | + 40, 40, 40, 40, 40, 40, 40, 40, # 102 | |
| 997 | + 40, 40, 40, 40, 40, 40, 40, 40, # 102 | |
| 998 | + 40, 40, 40, 40, 40, 40, 40, 40, # 102 | |
| 999 | + 40, 40, 40, 40, 40, 40, 40, 40, # 102 | |
| 1000 | + 40, 40, 40, 40, 40, 40, 46, 46, # 102 | |
| 1001 | + 46, 46, 46, 46, 46, 46, 46, 46, # 102 | |
| 1002 | + 46, 46, 46, 46, 46, 46, 46, 46, # 102 | |
| 1003 | + 46, 46, 46, 46, 46, 46, 46, 46, # 102 | |
| 1004 | + 40, 40, 40, 40, 40, 40, 40, 40, # 103 | |
| 1005 | + 40, 40, 40, 40, 40, 40, 40, 40, # 103 | |
| 1006 | + 40, 40, 40, 40, 40, 40, 40, 40, # 103 | |
| 1007 | + 40, 40, 40, 40, 40, 40, 40, 40, # 103 | |
| 1008 | + 40, 40, 40, 40, 46, 46, 46, 46, # 103 | |
| 1009 | + 46, 46, 46, 46, 46, 46, 46, 46, # 103 | |
| 1010 | + 46, 46, 46, 46, 46, 46, 46, 46, # 103 | |
| 1011 | + 46, 46, 46, 46, 46, 46, 46, 46, # 103 | |
| 1012 | + 122, 122, 122, 122, 122, 122, 122, 122, # 104 | |
| 1013 | + 122, 122, 122, 122, 122, 122, 122, 122, # 104 | |
| 1014 | + 122, 122, 122, 122, 122, 122, 122, 122, # 104 | |
| 1015 | + 122, 122, 122, 122, 122, 122, 122, 122, # 104 | |
| 1016 | + 122, 122, 122, 122, 122, 122, 122, 122, # 104 | |
| 1017 | + 122, 122, 122, 122, 122, 122, 122, 122, # 104 | |
| 1018 | + 122, 122, 122, 122, 122, 122, 122, 122, # 104 | |
| 1019 | + 122, 122, 122, 122, 122, 122, 122, 122, # 104 | |
| 1020 | + 123, 123, 123, 123, 123, 123, 123, 123, # 105 | |
| 1021 | + 123, 123, 123, 123, 123, 123, 123, 123, # 105 | |
| 1022 | + 123, 123, 123, 123, 123, 123, 123, 123, # 105 | |
| 1023 | + 123, 123, 123, 123, 123, 123, 123, 123, # 105 | |
| 1024 | + 123, 123, 123, 123, 123, 123, 123, 123, # 105 | |
| 1025 | + 123, 123, 123, 123, 123, 123, 123, 123, # 105 | |
| 1026 | + 123, 123, 123, 123, 123, 123, 123, 123, # 105 | |
| 1027 | + 123, 123, 123, 123, 123, 123, 123, 123, # 105 | |
| 1028 | + 40, 40, 40, 40, 40, 40, 40, 40, # 106 | |
| 1029 | + 40, 40, 40, 40, 40, 40, 40, 40, # 106 | |
| 1030 | + 40, 40, 40, 40, 40, 40, 40, 40, # 106 | |
| 1031 | + 40, 40, 40, 40, 40, 40, 40, 40, # 106 | |
| 1032 | + 40, 40, 40, 40, 40, 40, 40, 40, # 106 | |
| 1033 | + 40, 40, 40, 40, 40, 40, 46, 46, # 106 | |
| 1034 | + 46, 46, 46, 46, 46, 46, 46, 46, # 106 | |
| 1035 | + 46, 46, 46, 46, 46, 46, 46, 46, # 106 | |
| 1036 | + 16, 16, 16, 16, 16, 16, 16, 46, # 107 | |
| 1037 | + 46, 46, 46, 46, 46, 46, 46, 46, # 107 | |
| 1038 | + 46, 46, 46, 16, 16, 16, 16, 16, # 107 | |
| 1039 | + 46, 46, 46, 46, 46, 46, 60, 40, # 107 | |
| 1040 | + 40, 40, 40, 40, 40, 40, 40, 40, # 107 | |
| 1041 | + 40, 7, 40, 40, 40, 40, 40, 40, # 107 | |
| 1042 | + 40, 40, 40, 40, 40, 40, 40, 46, # 107 | |
| 1043 | + 40, 40, 40, 40, 40, 46, 40, 46, # 107 | |
| 1044 | + 40, 40, 46, 40, 40, 46, 40, 40, # 108 | |
| 1045 | + 40, 40, 40, 40, 40, 40, 40, 40, # 108 | |
| 1046 | + 40, 40, 40, 40, 40, 40, 40, 40, # 108 | |
| 1047 | + 40, 40, 40, 40, 40, 40, 40, 40, # 108 | |
| 1048 | + 40, 40, 40, 40, 40, 40, 40, 40, # 108 | |
| 1049 | + 40, 40, 40, 40, 40, 40, 40, 40, # 108 | |
| 1050 | + 40, 40, 40, 40, 40, 40, 40, 40, # 108 | |
| 1051 | + 40, 40, 40, 40, 40, 40, 40, 40, # 108 | |
| 1052 | + 40, 40, 40, 40, 40, 40, 40, 40, # 109 | |
| 1053 | + 40, 40, 40, 40, 40, 40, 40, 40, # 109 | |
| 1054 | + 40, 40, 40, 40, 40, 40, 40, 40, # 109 | |
| 1055 | + 40, 40, 40, 40, 40, 40, 40, 40, # 109 | |
| 1056 | + 40, 40, 40, 40, 40, 40, 40, 40, # 109 | |
| 1057 | + 40, 40, 40, 40, 40, 40, 40, 40, # 109 | |
| 1058 | + 40, 40, 46, 46, 46, 46, 46, 46, # 109 | |
| 1059 | + 46, 46, 46, 46, 46, 46, 46, 46, # 109 | |
| 1060 | + 46, 46, 46, 46, 46, 46, 46, 46, # 110 | |
| 1061 | + 46, 46, 46, 46, 46, 46, 46, 46, # 110 | |
| 1062 | + 46, 46, 46, 40, 40, 40, 40, 40, # 110 | |
| 1063 | + 40, 40, 40, 40, 40, 40, 40, 40, # 110 | |
| 1064 | + 40, 40, 40, 40, 40, 40, 40, 40, # 110 | |
| 1065 | + 40, 40, 40, 40, 40, 40, 40, 40, # 110 | |
| 1066 | + 40, 40, 40, 40, 40, 40, 40, 40, # 110 | |
| 1067 | + 40, 40, 40, 40, 40, 40, 40, 40, # 110 | |
| 1068 | + 40, 40, 40, 40, 40, 40, 40, 40, # 111 | |
| 1069 | + 40, 40, 40, 40, 40, 40, 40, 40, # 111 | |
| 1070 | + 40, 40, 40, 40, 40, 40, 40, 40, # 111 | |
| 1071 | + 40, 40, 40, 40, 40, 40, 40, 40, # 111 | |
| 1072 | + 40, 40, 40, 40, 40, 40, 40, 40, # 111 | |
| 1073 | + 40, 40, 40, 40, 40, 40, 40, 40, # 111 | |
| 1074 | + 40, 40, 40, 40, 40, 40, 40, 40, # 111 | |
| 1075 | + 40, 40, 40, 40, 40, 40, 5, 6, # 111 | |
| 1076 | + 46, 46, 46, 46, 46, 46, 46, 46, # 112 | |
| 1077 | + 46, 46, 46, 46, 46, 46, 46, 46, # 112 | |
| 1078 | + 40, 40, 40, 40, 40, 40, 40, 40, # 112 | |
| 1079 | + 40, 40, 40, 40, 40, 40, 40, 40, # 112 | |
| 1080 | + 40, 40, 40, 40, 40, 40, 40, 40, # 112 | |
| 1081 | + 40, 40, 40, 40, 40, 40, 40, 40, # 112 | |
| 1082 | + 40, 40, 40, 40, 40, 40, 40, 40, # 112 | |
| 1083 | + 40, 40, 40, 40, 40, 40, 40, 40, # 112 | |
| 1084 | + 40, 40, 40, 40, 40, 40, 40, 40, # 113 | |
| 1085 | + 40, 40, 40, 40, 40, 40, 40, 40, # 113 | |
| 1086 | + 46, 46, 40, 40, 40, 40, 40, 40, # 113 | |
| 1087 | + 40, 40, 40, 40, 40, 40, 40, 40, # 113 | |
| 1088 | + 40, 40, 40, 40, 40, 40, 40, 40, # 113 | |
| 1089 | + 40, 40, 40, 40, 40, 40, 40, 40, # 113 | |
| 1090 | + 40, 40, 40, 40, 40, 40, 40, 40, # 113 | |
| 1091 | + 40, 40, 40, 40, 40, 40, 40, 40, # 113 | |
| 1092 | + 40, 40, 40, 40, 40, 40, 40, 40, # 114 | |
| 1093 | + 46, 46, 46, 46, 46, 46, 46, 46, # 114 | |
| 1094 | + 46, 46, 46, 46, 46, 46, 46, 46, # 114 | |
| 1095 | + 46, 46, 46, 46, 46, 46, 46, 46, # 114 | |
| 1096 | + 46, 46, 46, 46, 46, 46, 46, 46, # 114 | |
| 1097 | + 46, 46, 46, 46, 46, 46, 46, 46, # 114 | |
| 1098 | + 40, 40, 40, 40, 40, 40, 40, 40, # 114 | |
| 1099 | + 40, 40, 40, 40, 46, 46, 46, 46, # 114 | |
| 1100 | + 46, 46, 46, 46, 46, 46, 46, 46, # 115 | |
| 1101 | + 46, 46, 46, 46, 46, 46, 46, 46, # 115 | |
| 1102 | + 46, 46, 46, 46, 46, 46, 46, 46, # 115 | |
| 1103 | + 46, 46, 46, 46, 46, 46, 46, 46, # 115 | |
| 1104 | + 60, 60, 60, 60, 46, 46, 46, 46, # 115 | |
| 1105 | + 46, 46, 46, 46, 46, 46, 46, 46, # 115 | |
| 1106 | + 3, 8, 8, 12, 12, 5, 6, 5, # 115 | |
| 1107 | + 6, 5, 6, 5, 6, 5, 6, 5, # 115 | |
| 1108 | + 6, 5, 6, 5, 6, 46, 46, 46, # 116 | |
| 1109 | + 46, 3, 3, 3, 3, 12, 12, 12, # 116 | |
| 1110 | + 3, 3, 3, 46, 3, 3, 3, 3, # 116 | |
| 1111 | + 8, 5, 6, 5, 6, 5, 6, 3, # 116 | |
| 1112 | + 3, 3, 7, 8, 7, 7, 7, 46, # 116 | |
| 1113 | + 3, 4, 3, 3, 46, 46, 46, 46, # 116 | |
| 1114 | + 40, 40, 40, 46, 40, 46, 40, 40, # 116 | |
| 1115 | + 40, 40, 40, 40, 40, 40, 40, 40, # 116 | |
| 1116 | + 40, 40, 40, 40, 40, 40, 40, 40, # 117 | |
| 1117 | + 40, 40, 40, 40, 40, 40, 40, 40, # 117 | |
| 1118 | + 40, 40, 40, 40, 40, 40, 40, 40, # 117 | |
| 1119 | + 40, 40, 40, 40, 40, 40, 40, 40, # 117 | |
| 1120 | + 40, 40, 40, 40, 40, 40, 40, 40, # 117 | |
| 1121 | + 40, 40, 40, 40, 40, 40, 40, 40, # 117 | |
| 1122 | + 40, 40, 40, 40, 40, 40, 40, 40, # 117 | |
| 1123 | + 40, 40, 40, 40, 40, 46, 46, 104, # 117 | |
| 1124 | + 46, 3, 3, 3, 4, 3, 3, 3, # 118 | |
| 1125 | + 5, 6, 3, 7, 3, 8, 3, 3, # 118 | |
| 1126 | + 9, 9, 9, 9, 9, 9, 9, 9, # 118 | |
| 1127 | + 9, 9, 3, 3, 7, 7, 7, 3, # 118 | |
| 1128 | + 3, 10, 10, 10, 10, 10, 10, 10, # 118 | |
| 1129 | + 10, 10, 10, 10, 10, 10, 10, 10, # 118 | |
| 1130 | + 10, 10, 10, 10, 10, 10, 10, 10, # 118 | |
| 1131 | + 10, 10, 10, 5, 3, 6, 11, 12, # 118 | |
| 1132 | + 11, 13, 13, 13, 13, 13, 13, 13, # 119 | |
| 1133 | + 13, 13, 13, 13, 13, 13, 13, 13, # 119 | |
| 1134 | + 13, 13, 13, 13, 13, 13, 13, 13, # 119 | |
| 1135 | + 13, 13, 13, 5, 7, 6, 7, 46, # 119 | |
| 1136 | + 46, 3, 5, 6, 3, 3, 40, 40, # 119 | |
| 1137 | + 40, 40, 40, 40, 40, 40, 40, 40, # 119 | |
| 1138 | + 59, 40, 40, 40, 40, 40, 40, 40, # 119 | |
| 1139 | + 40, 40, 40, 40, 40, 40, 40, 40, # 119 | |
| 1140 | + 40, 40, 40, 40, 40, 40, 40, 40, # 120 | |
| 1141 | + 40, 40, 40, 40, 40, 40, 40, 40, # 120 | |
| 1142 | + 40, 40, 40, 40, 40, 40, 40, 40, # 120 | |
| 1143 | + 40, 40, 40, 40, 40, 40, 59, 59, # 120 | |
| 1144 | + 40, 40, 40, 40, 40, 40, 40, 40, # 120 | |
| 1145 | + 40, 40, 40, 40, 40, 40, 40, 40, # 120 | |
| 1146 | + 40, 40, 40, 40, 40, 40, 40, 40, # 120 | |
| 1147 | + 40, 40, 40, 40, 40, 40, 40, 46, # 120 | |
| 1148 | + 46, 46, 40, 40, 40, 40, 40, 40, # 121 | |
| 1149 | + 46, 46, 40, 40, 40, 40, 40, 40, # 121 | |
| 1150 | + 46, 46, 40, 40, 40, 40, 40, 40, # 121 | |
| 1151 | + 46, 46, 40, 40, 40, 46, 46, 46, # 121 | |
| 1152 | + 4, 4, 7, 11, 15, 4, 4, 46, # 121 | |
| 1153 | + 7, 7, 7, 7, 7, 15, 15, 46, # 121 | |
| 1154 | + 46, 46, 46, 46, 46, 46, 46, 46, # 121 | |
| 1155 | + 46, 46, 46, 46, 46, 15, 46, 46 # 121 | |
| 1156 | + }; | |
| 1157 | + | |
| 1158 | +# The A table has 124 entries for a total of 496 bytes. | |
| 1159 | + | |
| 1160 | +A = array[] of { | |
| 1161 | + 16r0001000F, # 0 Cc, ignorable | |
| 1162 | + 16r0004000F, # 1 Cc, whitespace | |
| 1163 | + 16r0004000C, # 2 Zs, whitespace | |
| 1164 | + 16r00000018, # 3 Po | |
| 1165 | + 16r0006001A, # 4 Sc, currency | |
| 1166 | + 16r00000015, # 5 Ps | |
| 1167 | + 16r00000016, # 6 Pe | |
| 1168 | + 16r00000019, # 7 Sm | |
| 1169 | + 16r00000014, # 8 Pd | |
| 1170 | + 16r00036009, # 9 Nd, identifier part, decimal 16 | |
| 1171 | + 16r0827FE01, # 10 Lu, hasLower (add 32), identifier start, supradecimal 31 | |
| 1172 | + 16r0000001B, # 11 Sk | |
| 1173 | + 16r00050017, # 12 Pc, underscore | |
| 1174 | + 16r0817FE02, # 13 Ll, hasUpper (subtract 32), identifier start, supradecimal 31 | |
| 1175 | + 16r0000000C, # 14 Zs | |
| 1176 | + 16r0000001C, # 15 So | |
| 1177 | + 16r00070002, # 16 Ll, identifier start | |
| 1178 | + 16r0000600B, # 17 No, decimal 16 | |
| 1179 | + 16r0000500B, # 18 No, decimal 8 | |
| 1180 | + 16r0000800B, # 19 No, strange | |
| 1181 | + 16r08270001, # 20 Lu, hasLower (add 32), identifier start | |
| 1182 | + 16r08170002, # 21 Ll, hasUpper (subtract 32), identifier start | |
| 1183 | + int 16rE1D70002, # 22 Ll, hasUpper (subtract -121), identifier start | |
| 1184 | + 16r00670001, # 23 Lu, hasLower (add 1), identifier start | |
| 1185 | + 16r00570002, # 24 Ll, hasUpper (subtract 1), identifier start | |
| 1186 | + int 16rCE670001, # 25 Lu, hasLower (add -199), identifier start | |
| 1187 | + 16r3A170002, # 26 Ll, hasUpper (subtract 232), identifier start | |
| 1188 | + int 16rE1E70001, # 27 Lu, hasLower (add -121), identifier start | |
| 1189 | + 16r4B170002, # 28 Ll, hasUpper (subtract 300), identifier start | |
| 1190 | + 16r34A70001, # 29 Lu, hasLower (add 210), identifier start | |
| 1191 | + 16r33A70001, # 30 Lu, hasLower (add 206), identifier start | |
| 1192 | + 16r33670001, # 31 Lu, hasLower (add 205), identifier start | |
| 1193 | + 16r32A70001, # 32 Lu, hasLower (add 202), identifier start | |
| 1194 | + 16r32E70001, # 33 Lu, hasLower (add 203), identifier start | |
| 1195 | + 16r33E70001, # 34 Lu, hasLower (add 207), identifier start | |
| 1196 | + 16r34E70001, # 35 Lu, hasLower (add 211), identifier start | |
| 1197 | + 16r34670001, # 36 Lu, hasLower (add 209), identifier start | |
| 1198 | + 16r35670001, # 37 Lu, hasLower (add 213), identifier start | |
| 1199 | + 16r00070001, # 38 Lu, identifier start | |
| 1200 | + 16r36A70001, # 39 Lu, hasLower (add 218), identifier start | |
| 1201 | + 16r00070005, # 40 Lo, identifier start | |
| 1202 | + 16r36670001, # 41 Lu, hasLower (add 217), identifier start | |
| 1203 | + 16r36E70001, # 42 Lu, hasLower (add 219), identifier start | |
| 1204 | + 16r00AF0001, # 43 Lu, hasLower (add 2), hasTitle, identifier start | |
| 1205 | + 16r007F0003, # 44 Lt, hasUpper (subtract 1), hasLower (add 1), hasTitle, identifier start | |
| 1206 | + 16r009F0002, # 45 Ll, hasUpper (subtract 2), hasTitle, identifier start | |
| 1207 | + 16r00000000, # 46 unassigned | |
| 1208 | + 16r34970002, # 47 Ll, hasUpper (subtract 210), identifier start | |
| 1209 | + 16r33970002, # 48 Ll, hasUpper (subtract 206), identifier start | |
| 1210 | + 16r33570002, # 49 Ll, hasUpper (subtract 205), identifier start | |
| 1211 | + 16r32970002, # 50 Ll, hasUpper (subtract 202), identifier start | |
| 1212 | + 16r32D70002, # 51 Ll, hasUpper (subtract 203), identifier start | |
| 1213 | + 16r33D70002, # 52 Ll, hasUpper (subtract 207), identifier start | |
| 1214 | + 16r34570002, # 53 Ll, hasUpper (subtract 209), identifier start | |
| 1215 | + 16r34D70002, # 54 Ll, hasUpper (subtract 211), identifier start | |
| 1216 | + 16r35570002, # 55 Ll, hasUpper (subtract 213), identifier start | |
| 1217 | + 16r36970002, # 56 Ll, hasUpper (subtract 218), identifier start | |
| 1218 | + 16r36570002, # 57 Ll, hasUpper (subtract 217), identifier start | |
| 1219 | + 16r36D70002, # 58 Ll, hasUpper (subtract 219), identifier start | |
| 1220 | + 16r00070004, # 59 Lm, identifier start | |
| 1221 | + 16r00030006, # 60 Mn, identifier part | |
| 1222 | + 16r09A70001, # 61 Lu, hasLower (add 38), identifier start | |
| 1223 | + 16r09670001, # 62 Lu, hasLower (add 37), identifier start | |
| 1224 | + 16r10270001, # 63 Lu, hasLower (add 64), identifier start | |
| 1225 | + 16r0FE70001, # 64 Lu, hasLower (add 63), identifier start | |
| 1226 | + 16r09970002, # 65 Ll, hasUpper (subtract 38), identifier start | |
| 1227 | + 16r09570002, # 66 Ll, hasUpper (subtract 37), identifier start | |
| 1228 | + 16r10170002, # 67 Ll, hasUpper (subtract 64), identifier start | |
| 1229 | + 16r0FD70002, # 68 Ll, hasUpper (subtract 63), identifier start | |
| 1230 | + 16r0F970002, # 69 Ll, hasUpper (subtract 62), identifier start | |
| 1231 | + 16r0E570002, # 70 Ll, hasUpper (subtract 57), identifier start | |
| 1232 | + 16r0BD70002, # 71 Ll, hasUpper (subtract 47), identifier start | |
| 1233 | + 16r0D970002, # 72 Ll, hasUpper (subtract 54), identifier start | |
| 1234 | + 16r15970002, # 73 Ll, hasUpper (subtract 86), identifier start | |
| 1235 | + 16r14170002, # 74 Ll, hasUpper (subtract 80), identifier start | |
| 1236 | + 16r14270001, # 75 Lu, hasLower (add 80), identifier start | |
| 1237 | + 16r0C270001, # 76 Lu, hasLower (add 48), identifier start | |
| 1238 | + 16r0C170002, # 77 Ll, hasUpper (subtract 48), identifier start | |
| 1239 | + 16r00034009, # 78 Nd, identifier part, decimal 0 | |
| 1240 | + 16r00000007, # 79 Me | |
| 1241 | + 16r00030008, # 80 Mc, identifier part | |
| 1242 | + 16r00037409, # 81 Nd, identifier part, decimal 26 | |
| 1243 | + 16r00005A0B, # 82 No, decimal 13 | |
| 1244 | + 16r00006E0B, # 83 No, decimal 23 | |
| 1245 | + 16r0000740B, # 84 No, decimal 26 | |
| 1246 | + 16r0000000B, # 85 No | |
| 1247 | + int 16rFE170002, # 86 Ll, hasUpper (subtract -8), identifier start | |
| 1248 | + int 16rFE270001, # 87 Lu, hasLower (add -8), identifier start | |
| 1249 | + int 16rED970002, # 88 Ll, hasUpper (subtract -74), identifier start | |
| 1250 | + int 16rEA970002, # 89 Ll, hasUpper (subtract -86), identifier start | |
| 1251 | + int 16rE7170002, # 90 Ll, hasUpper (subtract -100), identifier start | |
| 1252 | + int 16rE0170002, # 91 Ll, hasUpper (subtract -128), identifier start | |
| 1253 | + int 16rE4170002, # 92 Ll, hasUpper (subtract -112), identifier start | |
| 1254 | + int 16rE0970002, # 93 Ll, hasUpper (subtract -126), identifier start | |
| 1255 | + int 16rFDD70002, # 94 Ll, hasUpper (subtract -9), identifier start | |
| 1256 | + int 16rEDA70001, # 95 Lu, hasLower (add -74), identifier start | |
| 1257 | + int 16rFDE70001, # 96 Lu, hasLower (add -9), identifier start | |
| 1258 | + int 16rEAA70001, # 97 Lu, hasLower (add -86), identifier start | |
| 1259 | + int 16rE7270001, # 98 Lu, hasLower (add -100), identifier start | |
| 1260 | + int 16rFE570002, # 99 Ll, hasUpper (subtract -7), identifier start | |
| 1261 | + int 16rE4270001, # 100 Lu, hasLower (add -112), identifier start | |
| 1262 | + int 16rFE670001, # 101 Lu, hasLower (add -7), identifier start | |
| 1263 | + int 16rE0270001, # 102 Lu, hasLower (add -128), identifier start | |
| 1264 | + int 16rE0A70001, # 103 Lu, hasLower (add -126), identifier start | |
| 1265 | + 16r00010010, # 104 Cf, ignorable | |
| 1266 | + 16r0004000D, # 105 Zl, whitespace | |
| 1267 | + 16r0004000E, # 106 Zp, whitespace | |
| 1268 | + 16r0000400B, # 107 No, decimal 0 | |
| 1269 | + 16r0000440B, # 108 No, decimal 2 | |
| 1270 | + 16r0427420A, # 109 Nl, hasLower (add 16), identifier start, decimal 1 | |
| 1271 | + 16r0427800A, # 110 Nl, hasLower (add 16), identifier start, strange | |
| 1272 | + 16r0417620A, # 111 Nl, hasUpper (subtract 16), identifier start, decimal 17 | |
| 1273 | + 16r0417800A, # 112 Nl, hasUpper (subtract 16), identifier start, strange | |
| 1274 | + 16r0007800A, # 113 Nl, identifier start, strange | |
| 1275 | + 16r0000420B, # 114 No, decimal 1 | |
| 1276 | + 16r0000720B, # 115 No, decimal 25 | |
| 1277 | + 16r06A0001C, # 116 So, hasLower (add 26) | |
| 1278 | + 16r0690001C, # 117 So, hasUpper (subtract 26) | |
| 1279 | + 16r00006C0B, # 118 No, decimal 22 | |
| 1280 | + 16r0000560B, # 119 No, decimal 11 | |
| 1281 | + 16r0007720A, # 120 Nl, identifier start, decimal 25 | |
| 1282 | + 16r0007400A, # 121 Nl, identifier start, decimal 0 | |
| 1283 | + 16r00000013, # 122 Cs | |
| 1284 | + 16r00000012 # 123 Co | |
| 1285 | + }; | |
| @@ -0,0 +1,8 @@ | ||
| 1 | +UnicodeTable : module | |
| 2 | +{ | |
| 3 | + PATH : con "/dis/java/java/lang/unicode_table.dis"; | |
| 4 | + | |
| 5 | + A : array of int; | |
| 6 | + X : array of int; | |
| 7 | + Y : array of int; | |
| 8 | +}; | |
| @@ -0,0 +1,13 @@ | ||
| 1 | +<../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | +# applet\ | |
| 5 | +# awt\ | |
| 6 | +# beans\ | |
| 7 | +# io\ | |
| 8 | + lang\ | |
| 9 | +# net\ | |
| 10 | +# security\ | |
| 11 | +# util\ | |
| 12 | + | |
| 13 | +<$ROOT/mkfiles/mksubdirs | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,16 @@ | ||
| 1 | +# javal v1.5 generated file: edit with care | |
| 2 | + | |
| 3 | +DatagramPacket_L : module | |
| 4 | +{ | |
| 5 | + DatagramPacket_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + buf : JArrayB; | |
| 9 | + length : int; | |
| 10 | + address : JObject; | |
| 11 | + port : int; | |
| 12 | + }; | |
| 13 | + | |
| 14 | + init : fn( jni_p : JNI ); | |
| 15 | + | |
| 16 | +}; | |
Empty file added.
Empty file added.
| @@ -0,0 +1,14 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +DatagramSocketImpl_L : module | |
| 4 | +{ | |
| 5 | + DatagramSocketImpl_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + localPort : int; | |
| 9 | + fd : ref FileDescriptor_obj; | |
| 10 | + }; | |
| 11 | + | |
| 12 | + init : fn( jni_p : JNI ); | |
| 13 | + | |
| 14 | +}; | |
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,218 @@ | ||
| 1 | +implement InetAddressImpl_L; | |
| 2 | + | |
| 3 | +# javal v1.5 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | +#<< | |
| 27 | + | |
| 28 | +include "InetAddressImpl_L.m"; | |
| 29 | + | |
| 30 | +#>> extra post includes here | |
| 31 | + | |
| 32 | +include "InetAddress_L.m"; | |
| 33 | + inet: InetAddress_L; # declare pointer to module name | |
| 34 | + | |
| 35 | +include "srv.m"; | |
| 36 | + srv: Srv; | |
| 37 | + | |
| 38 | +sys: Sys; | |
| 39 | + | |
| 40 | +include "jnet.m"; | |
| 41 | + jnet: JNET; | |
| 42 | + | |
| 43 | +DEBUG, AF_INET: import jnet; | |
| 44 | +FD: import sys; | |
| 45 | +InetAddress_obj: import inet; # import adt object for p0 ref | |
| 46 | +Value: import jni; | |
| 47 | + | |
| 48 | +#<< | |
| 49 | + | |
| 50 | +init( jni_p : JNI ) | |
| 51 | +{ | |
| 52 | + # save java native inteface mod instance | |
| 53 | + jni = jni_p; | |
| 54 | + #>>extra initialization here | |
| 55 | + | |
| 56 | + sys = jni->sys; | |
| 57 | + if((srv = load Srv Srv->BUILTINPATH) == nil | |
| 58 | + && (srv = load Srv Srv->PATH) == nil) | |
| 59 | + jni->InitError( jni->sys->sprint( "java.net.InetAddressImpl: could not load Srv: %r" ) ); | |
| 60 | + | |
| 61 | + #<< | |
| 62 | +} | |
| 63 | + | |
| 64 | +getLocalHostName_rString( this : ref InetAddressImpl_obj) : JString | |
| 65 | +{#>> | |
| 66 | + | |
| 67 | + fd: ref FD; | |
| 68 | + buf:= array[256] of byte; | |
| 69 | + | |
| 70 | + if (DEBUG) | |
| 71 | + sys->print("Entering getLocalHostName\n"); | |
| 72 | + | |
| 73 | + fd = sys->open("/dev/sysname", sys->OREAD); | |
| 74 | + | |
| 75 | + if (fd != nil ) | |
| 76 | + n := sys->read(fd, buf, 256); | |
| 77 | + else | |
| 78 | + return jni->NewString("localhost"); | |
| 79 | + | |
| 80 | + if (n <= 0) { | |
| 81 | + return jni->NewString("localhost"); | |
| 82 | + if (DEBUG) | |
| 83 | + sys->print(" Bad return from /dev/sysname\n"); | |
| 84 | + } | |
| 85 | + if (DEBUG) | |
| 86 | + sys->print(" Name from dev/sysname: %s\n", string buf[0:n]); | |
| 87 | + return jni->NewString(string buf[0:n]); | |
| 88 | + | |
| 89 | +} | |
| 90 | +#<< | |
| 91 | + | |
| 92 | +makeAnyLocalAddress_rInetAddress_V( this : ref InetAddressImpl_obj, p0 : JObject) | |
| 93 | +{#>> | |
| 94 | + | |
| 95 | + # p0 must be changed to a type InetAddress_obj in arg list | |
| 96 | + # Must include InetAddress_L.m also in this file. | |
| 97 | + | |
| 98 | + if (DEBUG) | |
| 99 | + sys->print("Entering makeAnyLocalAddress\n"); | |
| 100 | + | |
| 101 | + | |
| 102 | + #p0.address = jnet->INADDR_ANY; | |
| 103 | + | |
| 104 | + val := ref Value.TInt( jnet->INADDR_ANY ); | |
| 105 | + n := jni->SetObjField( p0, "address", val ); | |
| 106 | + if (DEBUG ) | |
| 107 | + sys->print("makeAnyLocalAddr: Return from SetObjField %d\n",n); | |
| 108 | + | |
| 109 | + #p0.family = jnet->AF_INET; | |
| 110 | + val = ref Value.TInt( jnet->AF_INET ); | |
| 111 | + n = jni->SetObjField( p0, "family", val ); | |
| 112 | + if (DEBUG ) | |
| 113 | + sys->print("makeAnyLocalAddr: Return from SetObjField %d\n",n); | |
| 114 | +}#<< | |
| 115 | + | |
| 116 | +lookupAllHostAddr_rString_aaB( this : ref InetAddressImpl_obj, p0 : JString) : JArray | |
| 117 | +{#>> | |
| 118 | + | |
| 119 | + if (DEBUG) | |
| 120 | + sys->print("Entering lookupAllHostAddr\n"); | |
| 121 | + | |
| 122 | + iplist,AddrList: list of string; | |
| 123 | + hostname,str,temp: string; | |
| 124 | + j: int; | |
| 125 | + | |
| 126 | + hostname = p0.str; | |
| 127 | + if (DEBUG) | |
| 128 | + sys->print("hostname is %s \n", p0.str); | |
| 129 | + AddrList = srv->iph2a(hostname); | |
| 130 | + if (DEBUG) | |
| 131 | + sys->print("InetAddressImpl:Got AddrList\n"); | |
| 132 | + | |
| 133 | + | |
| 134 | + b:= array[len AddrList] of { array[jnet->IPADDRLEN] of byte }; | |
| 135 | + | |
| 136 | + if (AddrList != nil) { | |
| 137 | + for(i:=0;i<len AddrList;i++) { | |
| 138 | + str = hd AddrList; | |
| 139 | + if (DEBUG) | |
| 140 | + sys->print(" Addrlist hd = %s\n", str); | |
| 141 | + AddrList = tl AddrList; | |
| 142 | + | |
| 143 | + # insure net byte ordered byte[][] | |
| 144 | + ( j, iplist ) = sys->tokenize( str, "."); | |
| 145 | + for (k:=0; k<j; k++) { | |
| 146 | + temp = hd iplist; | |
| 147 | + if (DEBUG) | |
| 148 | + sys->print("iplist hd = %s\n", temp); | |
| 149 | + iplist = tl iplist; | |
| 150 | + if (DEBUG) | |
| 151 | + sys->print("b[%d][%d]\n", i,k); | |
| 152 | + b[i][k] = byte temp; | |
| 153 | + if (DEBUG) | |
| 154 | + sys->print("InetAddressGetHostByName: tokenize b[%d][%d] = %d\n", i, k, int b[i][k]); | |
| 155 | + } | |
| 156 | + } | |
| 157 | + return jni->MkAAByte( b ); | |
| 158 | + } else { | |
| 159 | + jni->ThrowException( "java.net.UnknownHostException", "Host unknown" ); | |
| 160 | + return nil; | |
| 161 | + } | |
| 162 | + | |
| 163 | +}#<< | |
| 164 | + | |
| 165 | +getHostByAddr_I_rString( this : ref InetAddressImpl_obj, p0 : int) : JString | |
| 166 | +{#>> | |
| 167 | + | |
| 168 | + address: string; | |
| 169 | + | |
| 170 | + # p0 is the address | |
| 171 | + # IPV4 only.... | |
| 172 | + | |
| 173 | + | |
| 174 | + if (DEBUG) | |
| 175 | + sys->print("Entering getHostByAddr\n"); | |
| 176 | + | |
| 177 | + if( !p0 ) | |
| 178 | + jni->ThrowException( "java.net.UnknownHostException", | |
| 179 | + "Gethostbyaddr Bad Address" ); | |
| 180 | + | |
| 181 | + if (DEBUG) | |
| 182 | + sys->print("GetHostByAddr: p0 = %d\n", p0); | |
| 183 | + | |
| 184 | + b:= array[jnet->IPADDRLEN] of byte; | |
| 185 | + | |
| 186 | + b[0] = byte ( p0 >> 24 ); | |
| 187 | + b[1] = byte ( p0 >> 16 ); | |
| 188 | + b[2] = byte ( p0 >> 8 ); | |
| 189 | + b[3] = byte p0; | |
| 190 | + | |
| 191 | + address = string b[0] + "." + string b[1] + "." + string b[2] + "." + | |
| 192 | + string b[3]; | |
| 193 | + | |
| 194 | + HostList := srv->ipa2h(address); | |
| 195 | + | |
| 196 | + if ( len HostList == 0 ) { | |
| 197 | + if (DEBUG) | |
| 198 | + sys->print("GetHostByAddr: ipa2h returned nil on %s\n", | |
| 199 | + address); | |
| 200 | + jni->ThrowException( "java.net.UnknownHostException", | |
| 201 | + "Gethostbyaddr Bad Address" ); | |
| 202 | + return nil; | |
| 203 | + } | |
| 204 | + | |
| 205 | + return jni->NewString( string hd HostList ); | |
| 206 | + | |
| 207 | +}#<< | |
| 208 | + | |
| 209 | +getInetFamily_I( this : ref InetAddressImpl_obj) : int | |
| 210 | +{#>> | |
| 211 | + | |
| 212 | + if (DEBUG) | |
| 213 | + sys->print("Entering getInetFamily\n"); | |
| 214 | + #This is a nasty piece of work here... | |
| 215 | + return AF_INET; | |
| 216 | + | |
| 217 | +}#<< | |
| 218 | + | |
| @@ -0,0 +1,17 @@ | ||
| 1 | +# javal v1.5 generated file: edit with care | |
| 2 | + | |
| 3 | +InetAddressImpl_L : module | |
| 4 | +{ | |
| 5 | + InetAddressImpl_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + }; | |
| 9 | + | |
| 10 | + init : fn( jni_p : JNI ); | |
| 11 | + getLocalHostName_rString : fn( this : ref InetAddressImpl_obj) : JString; | |
| 12 | + makeAnyLocalAddress_rInetAddress_V : fn( this : ref InetAddressImpl_obj, p0 : JObject); | |
| 13 | + lookupAllHostAddr_rString_aaB : fn( this : ref InetAddressImpl_obj, p0 : JString) : JArray; | |
| 14 | + getHostByAddr_I_rString : fn( this : ref InetAddressImpl_obj, p0 : int) : JString; | |
| 15 | + getInetFamily_I : fn( this : ref InetAddressImpl_obj) : int; | |
| 16 | + | |
| 17 | +}; | |
| @@ -0,0 +1,12 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +InetAddress_L : module | |
| 4 | +{ | |
| 5 | + InetAddress_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + hostName : JString; | |
| 9 | + address : int; | |
| 10 | + family : int; | |
| 11 | + }; | |
| 12 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,695 @@ | ||
| 1 | +implement PlainDatagramSocketImpl_L; | |
| 2 | + | |
| 3 | +# javal v1.5 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | +#<< | |
| 27 | + | |
| 28 | +include "PlainDatagramSocketImpl_L.m"; | |
| 29 | + | |
| 30 | +#>> extra post includes here | |
| 31 | + | |
| 32 | +include "jnet.m"; | |
| 33 | + jnet: JNET; | |
| 34 | + | |
| 35 | +include "java/io/FileDescriptor_L.m"; | |
| 36 | + fildes: FileDescriptor_L; | |
| 37 | + | |
| 38 | +include "InetAddress_L.m"; | |
| 39 | + inet: InetAddress_L; | |
| 40 | + | |
| 41 | +InetAddress_obj: import inet; #make sure p0 ref works properly | |
| 42 | + | |
| 43 | +include "DatagramPacket_L.m"; | |
| 44 | + pkt: DatagramPacket_L; | |
| 45 | + | |
| 46 | +include "srv.m"; | |
| 47 | + srv: Srv; | |
| 48 | + | |
| 49 | +sys: Sys; | |
| 50 | + | |
| 51 | +strp: String; | |
| 52 | + | |
| 53 | +c: Cast; | |
| 54 | + | |
| 55 | + | |
| 56 | +DEBUG, AF_INET: import jnet; | |
| 57 | +FD: import sys; | |
| 58 | +DatagramPacket_obj: import pkt; #make sure p0 ref works properly | |
| 59 | +FileDescriptor_obj: import fildes; | |
| 60 | +Value: import jni; | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | +#<< | |
| 65 | + | |
| 66 | +init( jni_p : JNI ) | |
| 67 | +{ | |
| 68 | + # save java native inteface mod instance | |
| 69 | + jni = jni_p; | |
| 70 | + #>>extra initialization here | |
| 71 | + | |
| 72 | + sys = jni->sys; | |
| 73 | + strp = jni->str; | |
| 74 | + c = jni->CastMod(); | |
| 75 | + if((srv = load Srv Srv->BUILTINPATH) == nil | |
| 76 | + && (srv = load Srv Srv->PATH) == nil) | |
| 77 | + jni->InitError( jni->sys->sprint( "java.net.PlainDatagramSocketImpl: could not load Srv: %r" ) ); | |
| 78 | + | |
| 79 | + #<< | |
| 80 | +} | |
| 81 | + | |
| 82 | +bind_I_rInetAddress_V( this : ref PlainDatagramSocketImpl_obj, p0 : int,p1 : JObject) | |
| 83 | +{#>> | |
| 84 | + | |
| 85 | + fd: ref FD; | |
| 86 | + buf:= array[50] of byte; | |
| 87 | + byteary:= array[6] of byte; | |
| 88 | + i,n: int; | |
| 89 | + str: string; | |
| 90 | + arg: list of string; | |
| 91 | + | |
| 92 | + # Create the localaddress/localport assoc to a socket...... | |
| 93 | + | |
| 94 | + # p1 is a ref to InetAddress_obj | |
| 95 | + # p0 is the localport | |
| 96 | + | |
| 97 | + if (DEBUG) | |
| 98 | + sys->print("PlainDgramBind: Entering....\n"); | |
| 99 | + | |
| 100 | + if( this.cfd == nil ) { | |
| 101 | + if (DEBUG) | |
| 102 | + sys->print("Attempt to Bind using cfd = nil\n"); | |
| 103 | + jni->ThrowException("java.net.SocketException", | |
| 104 | + "Socket closed"); | |
| 105 | + } | |
| 106 | + | |
| 107 | + # Check for address presence... | |
| 108 | + if (p1 == nil) { | |
| 109 | + if( DEBUG ) | |
| 110 | + sys->print("PlainDgramSocketImplBind: No address given\n"); | |
| 111 | + jni->ThrowException("java.lang.NullPointerException", "null Address" ); | |
| 112 | + } | |
| 113 | + | |
| 114 | + # assume IPv4... | |
| 115 | + | |
| 116 | + v := jni->GetObjField( p1, "address", "I"); | |
| 117 | + | |
| 118 | + if (DEBUG && v == nil) | |
| 119 | + sys->print("DGrambind: GetObjField returned nil\n"); | |
| 120 | + if (DEBUG) | |
| 121 | + sys->print("DGrambind: GetObjField done\n"); | |
| 122 | + vl := v.Int(); | |
| 123 | + | |
| 124 | + b := array[jnet->IPADDRLEN] of byte; | |
| 125 | + b[0] = byte (vl >> 24 ); | |
| 126 | + b[1] = byte (vl >> 16 ); | |
| 127 | + b[2] = byte (vl >> 8 ); | |
| 128 | + b[3] = byte vl; | |
| 129 | + | |
| 130 | + if (p0) | |
| 131 | + str = "announce " + string b[0] + "." + string b[1] + "." + | |
| 132 | + string b[2] + "." + string b[3] + "!" + | |
| 133 | + string p0; | |
| 134 | + else | |
| 135 | + str = "announce " + string b[0] + "." + string b[1] + | |
| 136 | + + "." + string b[2] + "." + string b[3] ; | |
| 137 | + | |
| 138 | + | |
| 139 | + n = sys->write( this.cfd.fd, array of byte str, len str ); | |
| 140 | + | |
| 141 | + if( n <= 0 ) { | |
| 142 | + if (DEBUG) | |
| 143 | + sys->print( "Datagram %s to ctl file failed\n", str); | |
| 144 | + jni->ThrowException( "java.net.SocketException", | |
| 145 | + "Bind error"); | |
| 146 | + } | |
| 147 | + | |
| 148 | + str = "/net/" + "udp/" + string this.connection + "/local"; | |
| 149 | + if (DEBUG) | |
| 150 | + sys->print( "PlainDatagramSocketBind: opening file %s to get local port\n", str); | |
| 151 | + fd = sys->open( str, sys->OREAD ); | |
| 152 | + if ( fd == nil ) { | |
| 153 | + if (DEBUG) | |
| 154 | + sys->print( "PlainDatagramSocketBind: Open of local file returned nil fd\n"); | |
| 155 | + jni->ThrowException( "java.net.SocketException", | |
| 156 | + "Bind local file open error"); | |
| 157 | + } | |
| 158 | + n = sys->read( fd, buf, len buf); | |
| 159 | + | |
| 160 | + | |
| 161 | + if ( n <= 0 ) { | |
| 162 | + if (DEBUG) | |
| 163 | + sys->print( "PlainDatagramSocketBind: Read of local file returned %d\n", n); | |
| 164 | + jni->ThrowException( "java.net.SocketException", | |
| 165 | + "Bind local file read error"); | |
| 166 | + } | |
| 167 | + | |
| 168 | + ( i, arg) = sys->tokenize(string buf[0:n], "!"); | |
| 169 | + arg = tl arg; | |
| 170 | + | |
| 171 | + if (DEBUG) | |
| 172 | + sys->print( "PlainDatagramSocketBind: Returning port # %d\n", int hd arg); | |
| 173 | + this.localPort = int hd arg; | |
| 174 | + | |
| 175 | + if (DEBUG) | |
| 176 | + sys->print("PlainDgramBind: Leaving....\n"); | |
| 177 | + | |
| 178 | +}#<< | |
| 179 | + | |
| 180 | +send_rDatagramPacket_V( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) | |
| 181 | +{#>> | |
| 182 | + #p0 - Datagram Packet obj ref | |
| 183 | + | |
| 184 | + b:= array[jnet->IPADDRLEN] of byte; | |
| 185 | + str: string; | |
| 186 | + | |
| 187 | + if (DEBUG) | |
| 188 | + sys->print("PlainDgramsend: Entering....\n"); | |
| 189 | + | |
| 190 | + if (this.cfd == nil ) { | |
| 191 | + if (DEBUG) | |
| 192 | + sys->print( "PlainDatagramSocketSend: ref FileDescriptor_obj for cfd is nil\n"); | |
| 193 | + jni->ThrowException( "java.net.SocketException", | |
| 194 | + "Socket closed"); | |
| 195 | + } | |
| 196 | + | |
| 197 | + if ( p0 == nil ) { | |
| 198 | + if (DEBUG) | |
| 199 | + sys->print( "PlainDatagramSocketSend: ref DatagramPacket_obj is nil\n"); | |
| 200 | + jni->ThrowException( "java.lang.NullPointerException", | |
| 201 | + "Null DatagramPacket arg"); | |
| 202 | + } | |
| 203 | + | |
| 204 | + #Check buf field... | |
| 205 | + Pb := jni->GetObjField( p0, "buf", "[B"); | |
| 206 | + if ( Pb == nil ) { | |
| 207 | + if (DEBUG) | |
| 208 | + sys->print( "PlainDatagramSocketSend: ref DatagramPacket_obj buf is nil\n"); | |
| 209 | + jni->ThrowException( "java.lang.NullPointerException", | |
| 210 | + "Null DatagramPacket_obj buffer ref"); | |
| 211 | + } | |
| 212 | + if (DEBUG) | |
| 213 | + sys->print("Dgramsend: GetObjField returned %x\n", Pb); | |
| 214 | + | |
| 215 | + Pbvl := Pb.Object(); | |
| 216 | + if (DEBUG) | |
| 217 | + sys->print("Dgramsend: GetObjField returned %x\n", Pbvl); | |
| 218 | + | |
| 219 | + | |
| 220 | + #Check address field.... | |
| 221 | + if (DEBUG) | |
| 222 | + sys->print("DGramsend: Doing GetObjField Packet.address\n"); | |
| 223 | + I := jni->GetObjField( p0, "address", "Ljava.net.InetAddress;"); | |
| 224 | + if ( I == nil ) { | |
| 225 | + if (DEBUG) | |
| 226 | + sys->print( "PlainDatagramSocketSend: ref DatagramPacket_obj address is nil\n"); | |
| 227 | + jni->ThrowException( "java.lang.NullPointerException", | |
| 228 | + "Null DatagramPacket_obj address ref"); | |
| 229 | + } | |
| 230 | + | |
| 231 | + #address is an InetAddress ref | |
| 232 | + Ivl := I.Object(); | |
| 233 | + if (DEBUG) | |
| 234 | + sys->print("Dgramsend: GetObjField returned %x\n", Ivl); | |
| 235 | + | |
| 236 | + if (DEBUG) | |
| 237 | + sys->print("DGramsend: Doing GetObjField Packet.address.address\n"); | |
| 238 | + v := jni->GetObjField( Ivl, "address", "I"); | |
| 239 | + | |
| 240 | + if (DEBUG && v == nil) | |
| 241 | + sys->print("DGramsend: GetObjField returned nil\n"); | |
| 242 | + vl := v.Int(); | |
| 243 | + | |
| 244 | + if (DEBUG) | |
| 245 | + sys->print("Dgramsend: GetObjField returned %d\n", vl); | |
| 246 | + | |
| 247 | + b[0] = byte (vl >> 24); | |
| 248 | + b[1] = byte (vl >> 16); | |
| 249 | + b[2] = byte (vl >> 8); | |
| 250 | + b[3] = byte (vl); | |
| 251 | + | |
| 252 | + a := string b[0]+"."+string b[1]+"."+string b[2]+ | |
| 253 | + "."+string b[3]; | |
| 254 | + | |
| 255 | + # Check port.... | |
| 256 | + if (DEBUG) | |
| 257 | + sys->print("DGramsend: Doing GetObjField Packet.port\n"); | |
| 258 | + v = jni->GetObjField( p0, "port", "I"); | |
| 259 | + | |
| 260 | + if (DEBUG && v == nil) | |
| 261 | + sys->print("DGramsend: GetObjField returned nil\n"); | |
| 262 | + | |
| 263 | + vl = v.Int(); | |
| 264 | + if (DEBUG) | |
| 265 | + sys->print("Dgramsend: GetObjField returned %d\n", vl); | |
| 266 | + if ( vl <= 0 ) | |
| 267 | + str = "connect " + a; | |
| 268 | + else | |
| 269 | + str = "connect " + a + "!" + string vl; | |
| 270 | + | |
| 271 | + if( DEBUG ) | |
| 272 | + sys->print( "DGramsend: connect str = %s\n", str); | |
| 273 | + | |
| 274 | + n := sys->write( this.cfd.fd, array of byte str, len array of byte str ); | |
| 275 | + if( n <= 0 ) { | |
| 276 | + if (DEBUG) | |
| 277 | + sys->print( "DGramsend: connect cmd failed %d\n", n); | |
| 278 | + jni->ThrowException( "java.net.SocketException", | |
| 279 | + "Datagram send ctl file error"); | |
| 280 | + } | |
| 281 | + | |
| 282 | + #Get buf.ary field.... | |
| 283 | + ar := c->ToJArrayB( Pbvl ); | |
| 284 | + n = sys->write( this.fd.fd, ar.ary, len ar.ary); | |
| 285 | + if ( n <= 0 ) { | |
| 286 | + # set length to zero... | |
| 287 | + val := ref Value.TInt(0); | |
| 288 | + jni->SetObjField( p0, "length", val ); | |
| 289 | + if (DEBUG) | |
| 290 | + sys->print( "PlainDatagramSocketSend: write of data file returned %d\n", n); | |
| 291 | + jni->ThrowException( "java.net.SocketException", | |
| 292 | + "Send: data file write error"); | |
| 293 | + } | |
| 294 | + | |
| 295 | + val := ref Value.TInt(n); | |
| 296 | + jni->SetObjField( p0, "length", val ); | |
| 297 | + | |
| 298 | + if (DEBUG) | |
| 299 | + sys->print("PlainDgramsend: Leaving...\n"); | |
| 300 | + | |
| 301 | +}#<< | |
| 302 | + | |
| 303 | +peek_rInetAddress_I( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) : int | |
| 304 | +{#>> | |
| 305 | + if (DEBUG) | |
| 306 | + sys->print( "PlainDatagramSocketPeek: Unsupported entry.\n"); | |
| 307 | + jni->ThrowException( "java.net.SocketException", | |
| 308 | + "Peek: Unsupported option"); | |
| 309 | + return -1; | |
| 310 | +}#<< | |
| 311 | + | |
| 312 | +receive_rDatagramPacket_V( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) | |
| 313 | +{#>> | |
| 314 | + | |
| 315 | + # p0 = ref DatagramPacket | |
| 316 | + | |
| 317 | + str,temp: string; | |
| 318 | + st: list of string; | |
| 319 | + m: int; | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + if (DEBUG) | |
| 324 | + sys->print("PlainDgramreceive: Entering...\n"); | |
| 325 | + | |
| 326 | + if (this.cfd == nil ) { | |
| 327 | + if (DEBUG) | |
| 328 | + sys->print( "PlainDatagramSocketRead: ref FileDescriptor_obj for cfd is nil\n"); | |
| 329 | + jni->ThrowException( "java.net.SocketException", | |
| 330 | + "Socket closed"); | |
| 331 | + } | |
| 332 | + | |
| 333 | + if ( p0 == nil ) { | |
| 334 | + if (DEBUG) | |
| 335 | + sys->print( "PlainDatagramSocketRead: ref DatagramPacket_obj is nil\n"); | |
| 336 | + jni->ThrowException( "java.lang.NullPointerException", | |
| 337 | + "Null DatagramPacket_obj ref"); | |
| 338 | + } | |
| 339 | + | |
| 340 | + #Check buf field... | |
| 341 | + Pb := jni->GetObjField( p0, "buf", "[B"); | |
| 342 | + if ( Pb == nil ) { | |
| 343 | + if (DEBUG) | |
| 344 | + sys->print( "PlainDatagramSocketRecv: ref DatagramPacket_obj buf is nil\n"); | |
| 345 | + jni->ThrowException( "java.lang.NullPointerException", | |
| 346 | + "Null DatagramPacket_obj buffer ref"); | |
| 347 | + } | |
| 348 | + if (DEBUG) | |
| 349 | + sys->print("DgramRecv: GetObjField returned %x\n", Pb); | |
| 350 | + | |
| 351 | + Pbvl := Pb.Object(); | |
| 352 | + if (DEBUG) | |
| 353 | + sys->print("DgramRecv: GetObjField returned %x\n", Pbvl); | |
| 354 | + | |
| 355 | + #Get buf.ary field.... | |
| 356 | + ar := c->ToJArrayB( Pbvl ); | |
| 357 | + | |
| 358 | + n := sys->read( this.fd.fd, ar.ary, len ar.ary); | |
| 359 | + val := ref Value.TInt(n); | |
| 360 | + jni->SetObjField( p0, "length", val ); | |
| 361 | + | |
| 362 | + if ( n < 0 ) { | |
| 363 | + if (DEBUG) | |
| 364 | + sys->print( "PlainDatagramSocketRead: read of data file returned %d\n", n); | |
| 365 | + jni->ThrowException( "java.net.SocketException", | |
| 366 | + "PlainDatagramSocketReceive: data file read error"); | |
| 367 | + } | |
| 368 | + | |
| 369 | + if (DEBUG) | |
| 370 | + sys->print( "PlainDatagramSocketReceive: read of data file: %s\n", string ar.ary[0:n]); | |
| 371 | + | |
| 372 | + # Timeout logic... | |
| 373 | + if( this.timeout != 0 ) { | |
| 374 | + temp = jnet->timeout + " " + string this.timeout; | |
| 375 | + rc := sys->write(this.cfd.fd, array of byte temp, | |
| 376 | + len array of byte temp); | |
| 377 | + if (DEBUG) | |
| 378 | + sys->print("DatagramSocketImplReceive: fixing timeout value %s\n", string this.timeout); | |
| 379 | + if ( rc <= 0 ) | |
| 380 | + jni->ThrowException("java.net.SocketException", | |
| 381 | + "DatagramSocketImplReceive: Unable to set timeout"); | |
| 382 | + } | |
| 383 | + | |
| 384 | + # Check status file for timeout... | |
| 385 | + | |
| 386 | + buf:= array[256] of byte; | |
| 387 | + | |
| 388 | + temp = "/net/udp/" + string this.connection + "/status"; | |
| 389 | + sfd := sys->open( temp, sys->OREAD ); | |
| 390 | + if (sfd == nil ) { | |
| 391 | + if (DEBUG) | |
| 392 | + sys->print( "DatagramSocketImplReceive: Open of status file %s returned nil fd\n", temp); | |
| 393 | + jni->ThrowException( "java.net.SocketException", | |
| 394 | + "DatagramSocketImplReceive: Read failed"); | |
| 395 | + } | |
| 396 | + | |
| 397 | + k := sys->read(sfd, buf, len buf); | |
| 398 | + | |
| 399 | + if ( k <= 0 ) { | |
| 400 | + if (DEBUG) | |
| 401 | + sys->print("DgramReceive: status file read: %d\n", n); | |
| 402 | + jni->ThrowException( "java.net.SocketException", | |
| 403 | + "DatagramSocketImplReceive: status file read failed"); | |
| 404 | + } | |
| 405 | + | |
| 406 | + | |
| 407 | + if (DEBUG) | |
| 408 | + sys->print("DgramSocketreceive: Got status: %s\n", string buf[0:k]); | |
| 409 | + | |
| 410 | + (m, st) = sys->tokenize( string buf[:k], " \n\t"); | |
| 411 | + | |
| 412 | + if ( m != 0 ) | |
| 413 | + for(i:=0;i<m;i++) { | |
| 414 | + str = hd st; | |
| 415 | + if ( strp->prefix( str, "timed-out" )) { | |
| 416 | + if (DEBUG) | |
| 417 | + sys->print( "DatagramSocketImplReceive: timeout\n"); | |
| 418 | + jni->ThrowException("java.io.InterruptedIOException", | |
| 419 | + "DatagramSocketImplReceive: Read timed out."); | |
| 420 | + } | |
| 421 | + st = tl st; | |
| 422 | + } | |
| 423 | + else | |
| 424 | + if (DEBUG) | |
| 425 | + sys->print( "DatagramSocketImplReceive: Can't tokenize\n"); | |
| 426 | + | |
| 427 | + | |
| 428 | + if (DEBUG) | |
| 429 | + sys->print( "DatagramSocketImplReceive: Doing NewObject\n"); | |
| 430 | + # Default constructor... | |
| 431 | + I_obj := jni->NewObject( jni->FindClass( "java/net/InetAddress" )); | |
| 432 | + | |
| 433 | + if (DEBUG) | |
| 434 | + sys->print( "DatagramSocketImplReceive: NewObject Done\n"); | |
| 435 | + str = "/net/" + "udp/" + string this.connection + "/remote"; | |
| 436 | + fd := sys->open(str, sys->OREAD); | |
| 437 | + | |
| 438 | + if ( fd == nil ) { | |
| 439 | + if (DEBUG) | |
| 440 | + sys->print("Dgramreceive: Can't open %s\n", str); | |
| 441 | + jni->ThrowException( "java.net.SocketException", | |
| 442 | + "DatagramSocketImplreceive: Unable to obtain remote fd\n"); | |
| 443 | + } | |
| 444 | + | |
| 445 | + n = sys->read(fd, buf, len buf); | |
| 446 | + | |
| 447 | + if (n <= 0) { | |
| 448 | + if (DEBUG) | |
| 449 | + sys->print("DgramSocketreceive: Can't read %s\n", str); | |
| 450 | + jni->ThrowException( "java.net.SocketException", | |
| 451 | + "DatagramSocketImplreceive: Unable to obtain remote addr\n"); | |
| 452 | + } | |
| 453 | + | |
| 454 | + if (DEBUG) | |
| 455 | + sys->print("DgramSocketreceive: Remote file read has %s\n", string buf[0:n]); | |
| 456 | + | |
| 457 | + (m, st) = sys->tokenize( string buf[:n], "!"); | |
| 458 | + if ( m == 0 ) { | |
| 459 | + if (DEBUG) | |
| 460 | + sys->print("DgramSocketReceive: Can't tokenize %s\n", str); | |
| 461 | + jni->ThrowException( "java.net.SocketException", | |
| 462 | + "DatagramSocketImplReceive: Unable to tokenize remote\n"); | |
| 463 | + } | |
| 464 | + | |
| 465 | + str = hd st; | |
| 466 | + st = tl st; | |
| 467 | + | |
| 468 | + iplist: list of string; | |
| 469 | + ( i, iplist ) = sys->tokenize( str, "."); | |
| 470 | + if (DEBUG) | |
| 471 | + sys->print("DgramSocketreceive: tokenize iplist i = %d\n", i); | |
| 472 | + b:= array[len iplist] of byte; | |
| 473 | + for (j:=0; j<i; j++) { | |
| 474 | + temp = hd iplist; | |
| 475 | + iplist = tl iplist; | |
| 476 | + b[j] = byte temp; | |
| 477 | + } | |
| 478 | + | |
| 479 | + i = 0; | |
| 480 | + i |= int b[0] <<24; | |
| 481 | + i |= int b[1] <<16; | |
| 482 | + i |= int b[2] <<8; | |
| 483 | + i |= int b[3]; | |
| 484 | + if (DEBUG ) | |
| 485 | + sys->print("DgramSocketreceive: shifted remote addr = %d\n",i); | |
| 486 | + | |
| 487 | + val = ref Value.TInt( int hd st ); | |
| 488 | + n = jni->SetObjField( p0, "port", val ); | |
| 489 | + if (DEBUG ) | |
| 490 | + sys->print("DgramSocketRecv: Return from SetObjField port %d\n",n ); | |
| 491 | + | |
| 492 | + nval := ref Value.TObject( I_obj ); | |
| 493 | + n = jni->SetObjField( p0, "address", nval ); | |
| 494 | + if (DEBUG ) | |
| 495 | + sys->print("DgramSocketRecv: Return from SetObjField addr %d\n",n ); | |
| 496 | + | |
| 497 | + if (DEBUG ) | |
| 498 | + sys->print("DgramSocketRecv: Finished setting InetAddr ref\n" ); | |
| 499 | + | |
| 500 | + val = ref Value.TInt( i ); | |
| 501 | + n = jni->SetObjField( I_obj, "address", val ); | |
| 502 | + if (DEBUG ) | |
| 503 | + sys->print("DgramSocketRecv: Return from Inetaddr addr SetObjField %d\n",n ); | |
| 504 | + | |
| 505 | + val = ref Value.TInt( jnet->AF_INET ); | |
| 506 | + n = jni->SetObjField( I_obj, "family", val ); | |
| 507 | + if (DEBUG ) | |
| 508 | + sys->print("DgramSocketRecv: Return from family SetObjField %d\n",n ); | |
| 509 | + | |
| 510 | + if (DEBUG) | |
| 511 | + sys->print("PlainDgramRecv: Leaving...\n"); | |
| 512 | + | |
| 513 | +}#<< | |
| 514 | + | |
| 515 | +setTTL_B_V( this : ref PlainDatagramSocketImpl_obj, p0 : int) | |
| 516 | +{#>> | |
| 517 | + if (DEBUG) | |
| 518 | + sys->print( "PlainDatagramSocketSetTTL: Unsupported.\n"); | |
| 519 | + jni->ThrowException( "java.net.SocketException", | |
| 520 | + "setTTL: Unsupported option"); | |
| 521 | +}#<< | |
| 522 | + | |
| 523 | +getTTL_B( this : ref PlainDatagramSocketImpl_obj) : int | |
| 524 | +{#>> | |
| 525 | + if (DEBUG) | |
| 526 | + sys->print( "PlainDatagramSocketGetTTL: Unsupported.\n"); | |
| 527 | + jni->ThrowException( "java.net.SocketException", | |
| 528 | + "getTTL: Unsupported option"); | |
| 529 | + return -1; | |
| 530 | +}#<< | |
| 531 | + | |
| 532 | +join_rInetAddress_V( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) | |
| 533 | +{#>> | |
| 534 | + if (DEBUG) | |
| 535 | + sys->print( "PlainDatagramSocketJoin: Unsupported.\n"); | |
| 536 | + jni->ThrowException( "java.net.SocketException", | |
| 537 | + "Join: Unsupported option"); | |
| 538 | +}#<< | |
| 539 | + | |
| 540 | +leave_rInetAddress_V( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) | |
| 541 | +{#>> | |
| 542 | + if (DEBUG) | |
| 543 | + sys->print( "PlainDatagramSocketLeave: Unsupported.\n"); | |
| 544 | + jni->ThrowException( "java.net.SocketException", | |
| 545 | + "Leave: Unsupported option"); | |
| 546 | +}#<< | |
| 547 | + | |
| 548 | +datagramSocketCreate_V( this : ref PlainDatagramSocketImpl_obj) | |
| 549 | +{#>> | |
| 550 | + | |
| 551 | + dir: string; | |
| 552 | + cfd: ref FD; | |
| 553 | + | |
| 554 | + if (DEBUG) | |
| 555 | + sys->print("DgramCreate: Entering...\n"); | |
| 556 | + | |
| 557 | + #Open clone device and allocate a connection | |
| 558 | + dir = "/net/udp/clone"; | |
| 559 | + cfd = sys->open(dir, sys->ORDWR); | |
| 560 | + if (cfd == nil) { | |
| 561 | + if( DEBUG ) | |
| 562 | + sys->print( "DgramCreate: Unable to open clone device\n"); | |
| 563 | + jni->ThrowException( "java.net.SocketException", | |
| 564 | + "Unable to create socket"); | |
| 565 | + } | |
| 566 | + | |
| 567 | + #The following gets a connection number string | |
| 568 | + buf := array[10] of byte; | |
| 569 | + n := sys->read(cfd, buf, len buf); | |
| 570 | + if (n < 0) { | |
| 571 | + if (DEBUG) | |
| 572 | + sys->print("DgramCreate: Ctl file read returned no connection num!\n"); | |
| 573 | + jni->ThrowException( "java.net.SocketException", | |
| 574 | + "Unable to create socket"); | |
| 575 | + } | |
| 576 | + | |
| 577 | + if (DEBUG) | |
| 578 | + sys->print("DgramCreate: ctl read connection #: %s\n", | |
| 579 | + string buf[:n]); | |
| 580 | + | |
| 581 | + if (DEBUG) | |
| 582 | + sys->print("DgramCreate: Storing cfd #\n"); | |
| 583 | + this.cfd.fd = cfd; | |
| 584 | + r := string buf[:n]; | |
| 585 | + if (DEBUG) | |
| 586 | + sys->print("DgramCreate: Storing conn #\n"); | |
| 587 | + this.connection = int r; | |
| 588 | + | |
| 589 | + #Open data file and get a handle... | |
| 590 | + dir = "/net/" + "udp/" + string this.connection + "/data"; | |
| 591 | + cfd = sys->open(dir, sys->ORDWR); | |
| 592 | + if (cfd == nil) { | |
| 593 | + if( DEBUG ) | |
| 594 | + sys->print( "DatagramCreate: Unable to open %s\n", dir); | |
| 595 | + jni->ThrowException( "java.net.SocketException", | |
| 596 | + "Unable to create socket"); | |
| 597 | + } | |
| 598 | + if (DEBUG) | |
| 599 | + sys->print("DgramCreate: Storing fd #\n"); | |
| 600 | + this.fd.fd = cfd; | |
| 601 | +}#<< | |
| 602 | + | |
| 603 | +datagramSocketClose_V( this : ref PlainDatagramSocketImpl_obj) | |
| 604 | +{#>> | |
| 605 | + | |
| 606 | + if (DEBUG) | |
| 607 | + sys->print( "In socket close routine"); | |
| 608 | + this.fd = nil; | |
| 609 | + this.cfd = nil; | |
| 610 | + | |
| 611 | + | |
| 612 | +}#<< | |
| 613 | + | |
| 614 | +socketSetOption_I_rObject_V( this : ref PlainDatagramSocketImpl_obj, p0 : int,p1 : JObject) | |
| 615 | +{#>> | |
| 616 | + | |
| 617 | + if( p0 == jnet->IP_MULTICAST_IF ){ | |
| 618 | + if (DEBUG) | |
| 619 | + sys->print("PlainDatagramSocketImplSetOption: MULTICAST"); | |
| 620 | + jni->ThrowException("java.net.SocketException", | |
| 621 | + "invalid DatagramSocket Option"); | |
| 622 | + } | |
| 623 | +}#<< | |
| 624 | + | |
| 625 | +socketGetOption_I_I( this : ref PlainDatagramSocketImpl_obj, p0 : int) : int | |
| 626 | +{#>> | |
| 627 | + | |
| 628 | + # p0 = option | |
| 629 | + | |
| 630 | + buf := array[256] of byte; | |
| 631 | + temp, str: string; | |
| 632 | + iplist, st: list of string; | |
| 633 | + m,i : int; | |
| 634 | + | |
| 635 | + ctype := "udp"; | |
| 636 | + if (DEBUG) | |
| 637 | + sys->print("PlainDatagramSocketImplGetOption: Entering...\n"); | |
| 638 | + | |
| 639 | + if ( this.fd == nil ) { | |
| 640 | + if (DEBUG) | |
| 641 | + sys->print("PlainDatagramSocketImplGetOption: Null this.fd\n"); | |
| 642 | + jni->ThrowException("java.net.SocketException", "Socket Closed"); | |
| 643 | + } | |
| 644 | + | |
| 645 | + if( p0 == jnet->IP_MULTICAST_IF ) { | |
| 646 | + if (DEBUG) | |
| 647 | + sys->print("PlainDatagramSocketImplGetOption: MULTICAST"); | |
| 648 | + jni->ThrowException("java.net.SocketException", "invalid DatagramSocket Option"); | |
| 649 | + } else if ( p0 == jnet->SO_BINADDR ) { | |
| 650 | + if (DEBUG) | |
| 651 | + sys->print("PlainDatagramSocketImplGetOption: BINADDR"); | |
| 652 | + sfd := sys->open("/dev/sysname", sys->OREAD); | |
| 653 | + if(( m = sys->read(sfd, buf, len buf)) < 0 ) { | |
| 654 | + if (DEBUG) | |
| 655 | + sys->print("DatagramSocketGetOpt: SO_BINADDR: /dev/sysna me read failed\n"); | |
| 656 | + return -1; | |
| 657 | + } | |
| 658 | + st = srv->iph2a(string buf[0:m]); | |
| 659 | + if (st == nil) { | |
| 660 | + if (DEBUG) | |
| 661 | + sys->print("DsockGetOpt: iph2a returned nil list\n"); | |
| 662 | + jni->ThrowException( "java.net.SocketException", | |
| 663 | + "socketGetOption: SO_BINADDR: Unable to get local addres s"); | |
| 664 | + } | |
| 665 | + str = hd st; | |
| 666 | + if (DEBUG) | |
| 667 | + sys->print("socketGetOption: st hd = %s\n", str); | |
| 668 | + # insure net byte ordered byte[] | |
| 669 | + ( i, iplist ) = sys->tokenize( str, "."); | |
| 670 | + if (DEBUG) | |
| 671 | + sys->print("socketGetOption: iplist tokenize i = %d\n", i); | |
| 672 | + b:= array[len iplist] of byte; | |
| 673 | + for (j:=0; j<i; j++) { | |
| 674 | + temp = hd iplist; | |
| 675 | + iplist = tl iplist; | |
| 676 | + b[j] = byte temp; | |
| 677 | + } | |
| 678 | + i=0; | |
| 679 | + i |= int ( b[0] << 24) ; | |
| 680 | + i |= int ( b[1] << 16 ); | |
| 681 | + i |= int ( b[2] << 8 ); | |
| 682 | + i |= int ( b[3] ); | |
| 683 | + if (DEBUG ) | |
| 684 | + sys->print("DgramSocketGetOpt: BINADDR = %d\n", i); | |
| 685 | + return i; | |
| 686 | + } else | |
| 687 | + jni->ThrowException( "java.net.SocketException", | |
| 688 | + "DatagramSocketGetOption: Unsupported Option."); | |
| 689 | + if (DEBUG) | |
| 690 | + sys->print("PlainDatagramSocketImplGetOption: Leaving...\n"); | |
| 691 | + | |
| 692 | + return -1; | |
| 693 | +}#<< | |
| 694 | + | |
| 695 | + | |
| @@ -0,0 +1,29 @@ | ||
| 1 | +# javal v1.5 generated file: edit with care | |
| 2 | + | |
| 3 | +PlainDatagramSocketImpl_L : module | |
| 4 | +{ | |
| 5 | + PlainDatagramSocketImpl_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + localPort : int; | |
| 9 | + fd : ref FileDescriptor_obj; | |
| 10 | + cfd : ref FileDescriptor_obj; | |
| 11 | + connection : int; | |
| 12 | + timeout : int; | |
| 13 | + }; | |
| 14 | + | |
| 15 | + init : fn( jni_p : JNI ); | |
| 16 | + bind_I_rInetAddress_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : int,p1 : JObject); | |
| 17 | + send_rDatagramPacket_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : JObject); | |
| 18 | + peek_rInetAddress_I : fn( this : ref PlainDatagramSocketImpl_obj, p0 : JObject) : int; | |
| 19 | + receive_rDatagramPacket_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : JObject); | |
| 20 | + setTTL_B_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : int); | |
| 21 | + getTTL_B : fn( this : ref PlainDatagramSocketImpl_obj) : int; | |
| 22 | + join_rInetAddress_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : JObject); | |
| 23 | + leave_rInetAddress_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : JObject); | |
| 24 | + datagramSocketCreate_V : fn( this : ref PlainDatagramSocketImpl_obj); | |
| 25 | + datagramSocketClose_V : fn( this : ref PlainDatagramSocketImpl_obj); | |
| 26 | + socketSetOption_I_rObject_V : fn( this : ref PlainDatagramSocketImpl_obj, p0 : int,p1 : JObject); | |
| 27 | + socketGetOption_I_I : fn( this : ref PlainDatagramSocketImpl_obj, p0 : int) : int; | |
| 28 | + | |
| 29 | +}; | |
Empty file added.
| @@ -0,0 +1,685 @@ | ||
| 1 | +implement PlainSocketImpl_L; | |
| 2 | + | |
| 3 | +include "jni.m"; | |
| 4 | + jni : JNI; | |
| 5 | + ClassModule, | |
| 6 | + JString, | |
| 7 | + JArray, | |
| 8 | + JArrayI, | |
| 9 | + JArrayC, | |
| 10 | + JArrayB, | |
| 11 | + JArrayS, | |
| 12 | + JArrayJ, | |
| 13 | + JArrayF, | |
| 14 | + JArrayD, | |
| 15 | + JArrayZ, | |
| 16 | + JArrayJObject, | |
| 17 | + JArrayJClass, | |
| 18 | + JArrayJString, | |
| 19 | + JClass, | |
| 20 | + JObject : import jni; | |
| 21 | + | |
| 22 | +#>> extra pre includes here | |
| 23 | +#<< | |
| 24 | + | |
| 25 | +include "PlainSocketImpl_L.m"; | |
| 26 | + | |
| 27 | +#>> extra post includes here | |
| 28 | + | |
| 29 | +include "jnet.m"; | |
| 30 | + jnet: JNET; | |
| 31 | + | |
| 32 | +include "java/io/FileDescriptor_L.m"; | |
| 33 | + fildes: FileDescriptor_L; | |
| 34 | + | |
| 35 | +include "InetAddress_L.m"; | |
| 36 | + inet: InetAddress_L; | |
| 37 | + | |
| 38 | +include "srv.m"; | |
| 39 | + srv: Srv; | |
| 40 | + | |
| 41 | + | |
| 42 | +FileDescriptor_obj: import fildes; | |
| 43 | +InetAddress_obj: import inet; | |
| 44 | + | |
| 45 | +# This next file was once generated by javal, now it must be hand crafted. | |
| 46 | +include "SocketImpl_L.m"; | |
| 47 | + sock: SocketImpl_L; | |
| 48 | + | |
| 49 | + sys: Sys; | |
| 50 | + | |
| 51 | + strp: String; | |
| 52 | + | |
| 53 | +DEBUG: import jnet; | |
| 54 | +FD: import sys; | |
| 55 | +SocketImpl_obj: import sock; | |
| 56 | +Value: import jni; | |
| 57 | + | |
| 58 | +#<< | |
| 59 | + | |
| 60 | +init( jni_p : JNI ) | |
| 61 | +{ | |
| 62 | + # save java native inteface mod instance | |
| 63 | + jni = jni_p; | |
| 64 | + #>>extra initialization here | |
| 65 | + | |
| 66 | + sys = jni->sys; | |
| 67 | + strp = jni->str; | |
| 68 | + if((srv = load Srv Srv->BUILTINPATH) == nil | |
| 69 | + && (srv = load Srv Srv->PATH) == nil) | |
| 70 | + jni->InitError( jni->sys->sprint( "java.net.PlainSocketImpl: could not load Srv: %r" ) ); | |
| 71 | + | |
| 72 | + #<< | |
| 73 | +} | |
| 74 | + | |
| 75 | +socketCreate_Z_V( this : ref PlainSocketImpl_obj, p0 : int) | |
| 76 | +{#>> | |
| 77 | + | |
| 78 | + cfd,fd: ref FD; | |
| 79 | + dir,ctype: string; | |
| 80 | + | |
| 81 | + if (DEBUG) | |
| 82 | + sys->print("Entering socketCreate\n"); | |
| 83 | + | |
| 84 | + # Set socket ctype... | |
| 85 | + if ( p0 ) { | |
| 86 | + ctype = "tcp"; | |
| 87 | + this.ctype = jnet->SOCK_STREAM; | |
| 88 | + } else { | |
| 89 | + ctype = "udp"; | |
| 90 | + this.ctype = jnet->SOCK_DGRAM; | |
| 91 | + } | |
| 92 | + | |
| 93 | + #Open clone device and allocate a connection | |
| 94 | + dir = "/net/" + ctype + "/clone"; | |
| 95 | + cfd = sys->open(dir, sys->ORDWR); | |
| 96 | + if (cfd == nil) { | |
| 97 | + if( DEBUG ) | |
| 98 | + sys->print( "Unable to open clone device\n"); | |
| 99 | + jni->ThrowException( "java.net.SocketException", | |
| 100 | + "Unable to create socket"); | |
| 101 | + } | |
| 102 | + this.cfd.fd = cfd; | |
| 103 | + | |
| 104 | + buf := array[10] of byte; | |
| 105 | + n := sys->read(cfd, buf, len buf); | |
| 106 | + if (n < 0) { | |
| 107 | + if (DEBUG) | |
| 108 | + sys->print("socketCreate bad ctl file read\n"); | |
| 109 | + jni->ThrowException( "java.net.SocketException", | |
| 110 | + "socketCreate: Unable to create socket"); | |
| 111 | + } | |
| 112 | + if (DEBUG) | |
| 113 | + sys->print("socketCreate: ctl read connection #: %s\n", string buf[0:n]); | |
| 114 | + s := string buf[:n]; | |
| 115 | + | |
| 116 | + if (DEBUG) | |
| 117 | + sys->print("socketCreate: s is %s\n", s ); | |
| 118 | + this.connection = int s; | |
| 119 | + | |
| 120 | + # Populate data fd........ | |
| 121 | + dir = "/net/" + ctype + "/" + string this.connection + "/data"; | |
| 122 | + if (DEBUG) | |
| 123 | + sys->print("socketCreate: data dir: %s\n", dir); | |
| 124 | + fd = sys->open(dir, sys->ORDWR); | |
| 125 | + | |
| 126 | + if ( fd == nil ) { | |
| 127 | + if (DEBUG) | |
| 128 | + sys->print("socketCreate: Attempt to open %s - no fd returned\n", dir); | |
| 129 | + jni->ThrowException( "java.net.SocketException", | |
| 130 | + "Connect error: can't open connection"); | |
| 131 | + } | |
| 132 | + | |
| 133 | + this.fd.fd = fd; | |
| 134 | + | |
| 135 | + if (DEBUG) | |
| 136 | + sys->print("socketCreate: leaving \n"); | |
| 137 | +}#<< | |
| 138 | + | |
| 139 | +socketConnect_rInetAddress_I_V( this : ref PlainSocketImpl_obj, p0 : ref InetAddress_obj,p1 : int) | |
| 140 | +{#>> | |
| 141 | + b:= array[4] of byte; | |
| 142 | + buf:= array[50] of byte; | |
| 143 | + port,str,ctype: string; | |
| 144 | + arg: list of string; | |
| 145 | + i,n: int; | |
| 146 | + fd: ref FD; | |
| 147 | + | |
| 148 | + if (DEBUG) | |
| 149 | + sys->print("socketConnect: entering.. \n"); | |
| 150 | + # Get network ctype and address and port....... | |
| 151 | + | |
| 152 | + # Note p0 is an InetAddress_obj ref..... | |
| 153 | + if ( p0 != nil ) { | |
| 154 | + b[0] = byte (p0.address >> 24); | |
| 155 | + b[1] = byte (p0.address >> 16); | |
| 156 | + b[2] = byte (p0.address >> 8); | |
| 157 | + b[3] = byte (p0.address); | |
| 158 | + str = string b[0]+"."+string b[1]+"."+string b[2]+ | |
| 159 | + "."+string b[3]; | |
| 160 | + if( DEBUG ) { | |
| 161 | + sys->print( "socketConnect: byte array = %s\n", str ); | |
| 162 | + } | |
| 163 | + } else { | |
| 164 | + if( DEBUG ) | |
| 165 | + sys->print( "socketConnect: InetAddress ref = nil!\n"); | |
| 166 | + jni->ThrowException( "java.lang.NullPointerException", | |
| 167 | + "Null InetAddress"); | |
| 168 | + } | |
| 169 | + | |
| 170 | + if (this.ctype == jnet->SOCK_STREAM) | |
| 171 | + ctype = "tcp"; | |
| 172 | + else | |
| 173 | + ctype = "udp"; | |
| 174 | + | |
| 175 | + | |
| 176 | + # port is the third arg... | |
| 177 | + if (p1>0) | |
| 178 | + port = string p1; | |
| 179 | + else { | |
| 180 | + if( DEBUG ) | |
| 181 | + sys->print( "socketConnect: No server port arg provided\n"); | |
| 182 | + jni->ThrowException( "java.net.SocketException", | |
| 183 | + "No port argument"); | |
| 184 | + } | |
| 185 | + | |
| 186 | + # Make string to write to ctl and issue connect.... | |
| 187 | + | |
| 188 | + cstr := "connect " + str + "!" + port; | |
| 189 | + if( DEBUG ) | |
| 190 | + sys->print( "socketConnect: connect str = %s\n", cstr); | |
| 191 | + if ( this.cfd != nil ) | |
| 192 | + n = sys->write( this.cfd.fd, array of byte cstr, | |
| 193 | + len array of byte cstr ); | |
| 194 | + else { | |
| 195 | + if (DEBUG) | |
| 196 | + sys->print("socketConnect: ctl fd == nil!\n"); | |
| 197 | + jni->ThrowException( "java.lang.NullPointerException", | |
| 198 | + "socketConnect: ctl file fd nil"); | |
| 199 | + } | |
| 200 | + | |
| 201 | + if( n <= 0 ) { | |
| 202 | + if (DEBUG) | |
| 203 | + sys->print( "Connect cmd to ctl file returned bad byte count %d\n",n); | |
| 204 | + jni->ThrowException( "java.net.SocketException", | |
| 205 | + "Connect write error"); | |
| 206 | + } | |
| 207 | + this.address = p0; | |
| 208 | + this.port = p1; | |
| 209 | + | |
| 210 | + # Populate local port........ | |
| 211 | + | |
| 212 | + if (this.localport == 0) { # If there was no bind | |
| 213 | + cstr = "/net/"+ctype+"/"+string this.connection+"/local"; | |
| 214 | + fd = sys->open(cstr, sys->OREAD); | |
| 215 | + if ( fd == nil ) { | |
| 216 | + if (DEBUG) | |
| 217 | + sys->print("socketConnect: Open %s failed.\n", | |
| 218 | + cstr ); | |
| 219 | + jni->ThrowException( "java.net.SocketException", | |
| 220 | + "Connect error"); | |
| 221 | + } | |
| 222 | + n = sys->read( fd, buf, len buf ); | |
| 223 | + if ( n <= 0 ) { | |
| 224 | + if (DEBUG) | |
| 225 | + sys->print("Connect Error: Read of %s returned %d\n", cstr ,n ); | |
| 226 | + jni->ThrowException( "java.net.SocketException", | |
| 227 | + "Connect error"); | |
| 228 | + } | |
| 229 | + | |
| 230 | + if (DEBUG) | |
| 231 | + sys->print("socketConnect: Read of %s returned %s\n", | |
| 232 | + cstr, string buf[:n]); | |
| 233 | + ( i, arg) = sys->tokenize(string buf[0:n], "!"); | |
| 234 | + if (i == 0) { | |
| 235 | + if (DEBUG) | |
| 236 | + sys->print("Connect Error: tokenize of /local"); | |
| 237 | + jni->ThrowException( "java.net.SocketException", | |
| 238 | + "Connect error"); | |
| 239 | + } | |
| 240 | + arg = tl arg; | |
| 241 | + str = hd arg; | |
| 242 | + if (DEBUG) | |
| 243 | + sys->print("socketConnect: Tokenize for local port returned %s\n", str); | |
| 244 | + this.localport = int str; | |
| 245 | + } | |
| 246 | +}#<< | |
| 247 | + | |
| 248 | +socketBind_rInetAddress_I_V( this : ref PlainSocketImpl_obj, p0 : ref InetAddress_obj,p1 : int) | |
| 249 | +{#>> | |
| 250 | + | |
| 251 | + buf:= array[50] of byte; | |
| 252 | + b := array[jnet->IPADDRLEN] of byte; | |
| 253 | + i: int; | |
| 254 | + arg: list of string; | |
| 255 | + | |
| 256 | + if (DEBUG) | |
| 257 | + sys->print("Entering socketBind\n"); | |
| 258 | + | |
| 259 | + # Create the localaddress/localport assoc to a socket...... | |
| 260 | + | |
| 261 | + # Note p0 is a ref to InetAddress_obj | |
| 262 | + # The ip address was shifted in previously so... | |
| 263 | + # IPV4 only.... | |
| 264 | + if ( p0 != nil ) { | |
| 265 | + if (DEBUG) | |
| 266 | + sys->print( "socketBind: p0.address = %d\n",p0.address); | |
| 267 | + b[0] = byte (p0.address >> 24); | |
| 268 | + b[1] = byte (p0.address >> 16); | |
| 269 | + b[2] = byte (p0.address >> 8); | |
| 270 | + b[3] = byte (p0.address); | |
| 271 | + x := string b[0]+"."+string b[1]+"."+string b[2]+ | |
| 272 | + "."+string b[3]; | |
| 273 | + if (DEBUG) | |
| 274 | + sys->print("socketBind: Bind using %s \n", x); | |
| 275 | + } else | |
| 276 | + jni->ThrowException( "java.lang.NullPointerException", | |
| 277 | + "Null InetAddress"); | |
| 278 | + | |
| 279 | + if( this.fd == nil ) { | |
| 280 | + if (DEBUG) | |
| 281 | + sys->print("Attempt to Bind using cfd = nil\n"); | |
| 282 | + jni->ThrowException("java.net.SocketException", "Null Socket"); | |
| 283 | + } | |
| 284 | + | |
| 285 | + # bind is announce | |
| 286 | + | |
| 287 | + if (p1) | |
| 288 | + str := "announce " + string b[0] + "." + string b[1] + | |
| 289 | + + "." + string b[2] + "." + | |
| 290 | + string b[3] + "!" + string p1; | |
| 291 | + else | |
| 292 | + str = "announce " + string b[0] + "." + string b[1] + | |
| 293 | + + "." + string b[2] + "." + string b[3] ; | |
| 294 | + | |
| 295 | + if( DEBUG ) | |
| 296 | + sys->print("socketBind: announce port is: %s\n", string p1); | |
| 297 | + | |
| 298 | + | |
| 299 | + n := sys->write( this.cfd.fd, array of byte str, len array of byte str ); | |
| 300 | + | |
| 301 | + if( n <= 0 ) { | |
| 302 | + if (DEBUG) | |
| 303 | + sys->print( "socketBind: %s to ctl failed\n", str); | |
| 304 | + jni->ThrowException( "java.net.SocketException", | |
| 305 | + "Bind error"); | |
| 306 | + } | |
| 307 | + | |
| 308 | + # Populate local port........ | |
| 309 | + if (this.ctype == jnet->SOCK_STREAM) | |
| 310 | + ctype := "tcp"; | |
| 311 | + else | |
| 312 | + ctype = "udp"; | |
| 313 | + | |
| 314 | + cstr := "/net/"+ctype+"/"+string this.connection+"/local"; | |
| 315 | + fd := sys->open(cstr, sys->OREAD); | |
| 316 | + if ( fd == nil ) { | |
| 317 | + if (DEBUG) | |
| 318 | + sys->print("socketBind: Open %s failed.\n", | |
| 319 | + cstr ); | |
| 320 | + jni->ThrowException( "java.net.SocketException", | |
| 321 | + "Bind error"); | |
| 322 | + } | |
| 323 | + n = sys->read( fd, buf, len buf ); | |
| 324 | + if ( n <= 0 ) { | |
| 325 | + if (DEBUG) | |
| 326 | + sys->print("Bind Error: Read of %s returned %d\n", cstr ,n ); | |
| 327 | + jni->ThrowException( "java.net.SocketException", | |
| 328 | + "Bind error - opening /local"); | |
| 329 | + } | |
| 330 | + | |
| 331 | + if (DEBUG) | |
| 332 | + sys->print("socketConnect: Read of %s returned %s\n", | |
| 333 | + cstr, string buf[:n]); | |
| 334 | + ( i, arg) = sys->tokenize(string buf[0:n], "!"); | |
| 335 | + if (i == 0) { | |
| 336 | + if (DEBUG) | |
| 337 | + sys->print("Bind Error: tokenize of /local"); | |
| 338 | + jni->ThrowException( "java.net.SocketException", | |
| 339 | + "Bind error"); | |
| 340 | + } | |
| 341 | + arg = tl arg; | |
| 342 | + str = hd arg; | |
| 343 | + if (DEBUG) | |
| 344 | + sys->print("socketBind: Tokenize for local port returned %s\n", str); | |
| 345 | + this.localport = int str; | |
| 346 | + this.address = p0; | |
| 347 | +}#<< | |
| 348 | + | |
| 349 | +socketListen_I_V( this : ref PlainSocketImpl_obj, p0 : int) | |
| 350 | +{#>> | |
| 351 | + | |
| 352 | + # Maybe should just return here max q is always 5...... | |
| 353 | + if (DEBUG) | |
| 354 | + sys->print( "In socket listen routine\n"); | |
| 355 | + | |
| 356 | +}#<< | |
| 357 | + | |
| 358 | +socketAccept_rSocketImpl_V( this : ref PlainSocketImpl_obj, p0 : ref SocketImpl_obj ) | |
| 359 | +{#>> | |
| 360 | + # p0 is a ref to SocketImpl_obj | |
| 361 | + | |
| 362 | + ctype,dir: string; | |
| 363 | + buf := array[200] of byte; | |
| 364 | + str: string; | |
| 365 | + st: list of string; | |
| 366 | + m,n : int; | |
| 367 | + | |
| 368 | + if (DEBUG) | |
| 369 | + sys->print( "In socketAccept\n"); | |
| 370 | + | |
| 371 | + if ( p0 == nil ) { | |
| 372 | + if( DEBUG ) | |
| 373 | + sys->print( "socketAccept: PlainSocketImpl ref = nil!\n"); | |
| 374 | + jni->ThrowException( "java.lang.NullPointerException", | |
| 375 | + "Null Socket Ptr"); | |
| 376 | + } | |
| 377 | + | |
| 378 | + if (this.ctype == jnet->SOCK_STREAM) | |
| 379 | + ctype = "tcp"; | |
| 380 | + else | |
| 381 | + ctype = "udp"; | |
| 382 | + | |
| 383 | + if( this.timeout != 0 ) { | |
| 384 | + temp:= jnet->timeout + " " + string this.timeout; | |
| 385 | + if (DEBUG) | |
| 386 | + sys->print("socketAccept: writing to ctl: %s\n", temp); | |
| 387 | + if ( this.cfd != nil ) | |
| 388 | + rc := sys->write(this.cfd.fd, array of byte temp, | |
| 389 | + len array of byte temp); | |
| 390 | + else { | |
| 391 | + if (DEBUG) | |
| 392 | + sys->print("socketAccept: ctl fd is nil\n"); | |
| 393 | + jni->ThrowException( "java.lang.NullPointerException", | |
| 394 | + "Null CTL FD"); | |
| 395 | + } | |
| 396 | + | |
| 397 | + | |
| 398 | + if (DEBUG) | |
| 399 | + sys->print("socketAccept: wrote to ctl: %s\n", temp); | |
| 400 | + if ( rc <= 0 ) { | |
| 401 | + if (DEBUG) | |
| 402 | + sys->print("socketAccept: Bad write to ctl: %s\n", temp); | |
| 403 | + jni->ThrowException("java.net.SocketException", | |
| 404 | + "socketAccept: Unable to set timeout"); | |
| 405 | + } | |
| 406 | + } | |
| 407 | + | |
| 408 | + dir = "/net/" + ctype + "/" + string this.connection + "/listen"; | |
| 409 | + if ((lfd := sys->open(dir, sys->ORDWR)) == nil ) { | |
| 410 | + if (DEBUG) | |
| 411 | + sys->print( "Open of listen file %s returned nil fd\n", dir); | |
| 412 | + jni->ThrowException( "java.net.SocketException", | |
| 413 | + "socketAccept: accept failed"); | |
| 414 | + } | |
| 415 | + | |
| 416 | + # Check status file to see if timed out... | |
| 417 | + dir = "/net/" + ctype + "/" + string this.connection + "/status"; | |
| 418 | + if ((sfd := sys->open(dir, sys->OREAD)) == nil ) { | |
| 419 | + if (DEBUG) | |
| 420 | + sys->print( "socketAccept: Open of status file %s returned nil fd\n", dir); | |
| 421 | + jni->ThrowException( "java.net.SocketException", | |
| 422 | + "socketAccept: status file open failed"); | |
| 423 | + } | |
| 424 | + | |
| 425 | + n = sys->read(sfd, buf, len buf); | |
| 426 | + if ( n <= 0 ) { | |
| 427 | + if (DEBUG) | |
| 428 | + sys->print("socketAccept: status file read: %d\n", n); | |
| 429 | + jni->ThrowException( "java.net.SocketException", | |
| 430 | + "socketAccept: status file read failed"); | |
| 431 | + } | |
| 432 | + | |
| 433 | + if (DEBUG) | |
| 434 | + sys->print("socketAccept: Got status: %s\n", string buf[0:n]); | |
| 435 | + (m, st) = sys->tokenize( string buf[:n], " \t\n"); | |
| 436 | + | |
| 437 | + for(i:=0;i<m;i++) { | |
| 438 | + str = hd st; | |
| 439 | + if ( strp->prefix( str, "timed-out" )) { | |
| 440 | + if (DEBUG) | |
| 441 | + sys->print( "socketAccept: Status is timeout\n"); | |
| 442 | + jni->ThrowException("java.io.InterruptedIOException", | |
| 443 | + "socketAccept: accept timed out."); | |
| 444 | + } | |
| 445 | + st = tl st; | |
| 446 | + } | |
| 447 | + | |
| 448 | + # Need to save the dfd and cfd. Note SocketImpl is abstract... | |
| 449 | + if (DEBUG) | |
| 450 | + sys->print( "socketAccept: Storing fd from listen in SocketImpl_obj\n"); | |
| 451 | + # Get connection... | |
| 452 | + n = sys->read(lfd, buf, len buf); | |
| 453 | + if (n <= 0) { | |
| 454 | + if (DEBUG) | |
| 455 | + sys->print(" SocketAccept: ctl file read bad return code\n"); | |
| 456 | + jni->ThrowException( "java.net.SocketException", | |
| 457 | + "socketAccept: Unable to accept socket"); | |
| 458 | + } | |
| 459 | + | |
| 460 | + if (DEBUG) | |
| 461 | + sys->print("socketAccept: listen ctl conn #: %s\n", string buf[0:n]); | |
| 462 | + | |
| 463 | + s := string buf[0:n]; | |
| 464 | + if (DEBUG) | |
| 465 | + sys->print("socketAccept: storing connection number = %d in SocketImpl.\n", int s ); | |
| 466 | + p0.connection = int s; # save connection number | |
| 467 | + if (DEBUG) | |
| 468 | + sys->print("socketAccept: storing connection ctype = %d in SocketImpl.\n", this.ctype ); | |
| 469 | + p0.ctype = this.ctype; # save connection ctype | |
| 470 | + | |
| 471 | + dir = "/net/" + ctype + "/" + string p0.connection + "/data"; | |
| 472 | + if ((fd := sys->open( dir, sys->ORDWR)) == nil ) { | |
| 473 | + if (DEBUG) | |
| 474 | + sys->print(" SocketAccept: open of %s failed\n", dir); | |
| 475 | + | |
| 476 | + jni->ThrowException( "java.net.SocketException", | |
| 477 | + "Unable to open accepted socket"); | |
| 478 | + } | |
| 479 | + if (DEBUG) | |
| 480 | + sys->print("SocketAccept: About to store dfd in SocketImpl fd (abstract class)\n"); | |
| 481 | + p0.fd.fd = fd; #Store data file fd..... | |
| 482 | + | |
| 483 | + if (DEBUG) | |
| 484 | + sys->print(" socketAccept: storing accepted cfd now\n" ); | |
| 485 | + p0.cfd.fd = lfd; # store in class... | |
| 486 | + | |
| 487 | +}#<< | |
| 488 | + | |
| 489 | +socketAvailable_I( this : ref PlainSocketImpl_obj) : int | |
| 490 | +{#>> | |
| 491 | + | |
| 492 | + if (DEBUG) | |
| 493 | + sys->print( "In socket available routine\n"); | |
| 494 | + jni->ThrowException( "java.io.IOException", "socketAvailable: Unsupported function" ); | |
| 495 | + return -1; | |
| 496 | + | |
| 497 | +}#<< | |
| 498 | + | |
| 499 | +socketClose_V( this : ref PlainSocketImpl_obj) | |
| 500 | +{#>> | |
| 501 | + if (DEBUG) | |
| 502 | + sys->print( "In socket close routine\n"); | |
| 503 | + this.fd = nil; | |
| 504 | + this.cfd = nil; | |
| 505 | + this = nil; | |
| 506 | + | |
| 507 | +}#<< | |
| 508 | + | |
| 509 | +initProto_V( ) | |
| 510 | +{#>> | |
| 511 | + if (DEBUG) | |
| 512 | + sys->print( "In initProto routine\n"); | |
| 513 | + return; | |
| 514 | +}#<< | |
| 515 | + | |
| 516 | +socketSetOption_I_Z_rObject_V( this : ref PlainSocketImpl_obj, p0 : int,p1 : int,p2 : JObject) | |
| 517 | +{#>> | |
| 518 | + # p0 = opt | |
| 519 | + # p1 = enable | |
| 520 | + # p2 = val | |
| 521 | + | |
| 522 | + if (DEBUG) | |
| 523 | + sys->print( "In SocketSetOption routine"); | |
| 524 | + | |
| 525 | + if ( this.cfd == nil ) { | |
| 526 | + if (DEBUG) | |
| 527 | + sys->print("PlainSocketImplSetOption: Null this.fd\n"); | |
| 528 | + jni->ThrowException("java.net.SocketException", "Socket Closed"); | |
| 529 | + } | |
| 530 | + | |
| 531 | + if (this.ctype == jnet->SOCK_STREAM) | |
| 532 | + ctype := "tcp"; | |
| 533 | + else | |
| 534 | + ctype = "udp"; | |
| 535 | + | |
| 536 | + if( p0 == jnet->TCP_NODELAY ) | |
| 537 | + s := "tcp_nodelay " + string p1; | |
| 538 | + else if ( p0 == jnet->SO_LINGER ) | |
| 539 | + if ( p1 > 0 ) { | |
| 540 | + if( p2 != nil ) { | |
| 541 | + v := jni->GetObjField( p2, "value", "I"); | |
| 542 | + vl := v.Int(); | |
| 543 | + s = "linger " + string vl; | |
| 544 | + } | |
| 545 | + } else | |
| 546 | + s = "linger " + "-1"; | |
| 547 | + else | |
| 548 | + jni->ThrowException( "java.net.SocketException", | |
| 549 | + "Socket Option Unsupported"); | |
| 550 | + | |
| 551 | + if ( DEBUG ) | |
| 552 | + sys->print("SocketSetOpt: Option given is: %s\n", s ); | |
| 553 | + | |
| 554 | + n := sys->write( this.cfd.fd, array of byte s, len array of byte s ); | |
| 555 | + | |
| 556 | + if( n <= 0 ) { | |
| 557 | + if (DEBUG) | |
| 558 | + sys->print( "SetSockOpt: cmd to ctl file returned bad byte count %d\n",n); | |
| 559 | + jni->ThrowException( "java.net.SocketException", | |
| 560 | + "SetSocketOption error"); | |
| 561 | + } | |
| 562 | +}#<< | |
| 563 | + | |
| 564 | +socketGetOption_I_I( this : ref PlainSocketImpl_obj, p0 : int) : int | |
| 565 | +{#>> | |
| 566 | + | |
| 567 | + temp,ctype,dir: string; | |
| 568 | + buf:= array[256] of byte; | |
| 569 | + s,str: string; | |
| 570 | + iplist,st: list of string; | |
| 571 | + m,n,i : int; | |
| 572 | + | |
| 573 | + # p0 == socket option | |
| 574 | + | |
| 575 | + if (DEBUG) | |
| 576 | + sys->print( "In SocketGetOption routine"); | |
| 577 | + | |
| 578 | + if ( this.fd == nil ) { | |
| 579 | + if (DEBUG) | |
| 580 | + sys->print("PlainSocketImplGetOption: this.fd is null\n"); | |
| 581 | + jni->ThrowException("java.net.SocketException", "Socket Closed"); | |
| 582 | + } | |
| 583 | + | |
| 584 | + | |
| 585 | + if (this.ctype == jnet->SOCK_STREAM) | |
| 586 | + ctype = "tcp"; | |
| 587 | + else | |
| 588 | + ctype = "udp"; | |
| 589 | + | |
| 590 | + if (p0 == jnet->SO_LINGER ) | |
| 591 | + s = "linger"; | |
| 592 | + else if ( p0 == jnet->TCP_NODELAY ) | |
| 593 | + s = "tcp_nodelay"; | |
| 594 | + else if ( p0 == jnet->SO_BINADDR ){ | |
| 595 | + sfd := sys->open("/dev/sysname", sys->OREAD); | |
| 596 | + if ( sfd == nil ) { | |
| 597 | + jni->ThrowException( "java.net.SocketException", | |
| 598 | + "socketGetOpt: Inferno sysname file open failed"); | |
| 599 | + } | |
| 600 | + | |
| 601 | + if(( m = sys->read(sfd, buf, len buf)) < 0 ) { | |
| 602 | + if (DEBUG) | |
| 603 | + sys->print("SocketGetOpt: SO_BINADDR: /dev/sysname read failed\n"); | |
| 604 | + return -1; | |
| 605 | + } | |
| 606 | + st = srv->iph2a(string buf[0:m]); | |
| 607 | + if (st == nil) { | |
| 608 | + if (DEBUG) | |
| 609 | + sys->print("sockGetOpt: iph2a returned nil list\n"); | |
| 610 | + jni->ThrowException( "java.net.SocketException", | |
| 611 | + "socketGetOption: SO_BINADDR: Unable to get local address"); | |
| 612 | + } | |
| 613 | + str = hd st; | |
| 614 | + if (DEBUG) | |
| 615 | + sys->print("socketGetOption: st hd = %s\n", str); | |
| 616 | + # insure net byte ordered byte[] | |
| 617 | + ( i, iplist ) = sys->tokenize( str, "."); | |
| 618 | + if ( i == 0 ) { | |
| 619 | + if (DEBUG) | |
| 620 | + sys->print("sockGetOpt: tokenize 0 size list\n"); | |
| 621 | + jni->ThrowException( "java.net.SocketException", | |
| 622 | + "socketGetOption: SO_BINADDR: Unable tokenize local address"); | |
| 623 | + } | |
| 624 | + b:= array[len iplist] of byte; | |
| 625 | + for (j:=0; j<len iplist; j++) { | |
| 626 | + temp = hd iplist; | |
| 627 | + if (DEBUG ) | |
| 628 | + sys->print("socketGetOpt: temp = %s\n", temp); | |
| 629 | + iplist = tl iplist; | |
| 630 | + b[j] = byte temp; | |
| 631 | + } | |
| 632 | + i=0; | |
| 633 | + i |= int ( b[0] << 24) ; | |
| 634 | + i |= int ( b[1] << 16 ); | |
| 635 | + i |= int ( b[2] << 8 ); | |
| 636 | + i |= int ( b[3] ); | |
| 637 | + if (DEBUG ) | |
| 638 | + sys->print("socketGetOpt: returning BINADDR = %d\n", i); | |
| 639 | + return i; | |
| 640 | + } else | |
| 641 | + jni->ThrowException( "java.net.SocketException", | |
| 642 | + "socketGetOption: Unknown Option"); | |
| 643 | + | |
| 644 | + | |
| 645 | + # Get status file string ... | |
| 646 | + dir = "/net/" + ctype + "/" + string this.connection + "/status"; | |
| 647 | + | |
| 648 | + if ((sfd := sys->open( dir, sys->OREAD )) == nil ) { | |
| 649 | + if (DEBUG) | |
| 650 | + sys->print("socketGetOpt: Open status file %s return"+ | |
| 651 | + "ed nil fd\n", dir); | |
| 652 | + jni->ThrowException( "java.net.SocketException", | |
| 653 | + "socketGetOpt: Inferno Status file open failed"); | |
| 654 | + } | |
| 655 | + | |
| 656 | + n = sys->read(sfd, buf, len buf); | |
| 657 | + if ( n <= 0 ) { | |
| 658 | + if( DEBUG ) | |
| 659 | + sys->print("socketGetOpt: status file bad read %d\n", n); | |
| 660 | + return -1; | |
| 661 | + } | |
| 662 | + if (DEBUG) | |
| 663 | + sys->print("socketGetOpt: status file has: %s\n", string buf[0:n]); | |
| 664 | + | |
| 665 | + (m, st) = sys->tokenize( string buf[:n], " \t\n"); | |
| 666 | + if ( m == 0 ) | |
| 667 | + jni->ThrowException( "java.net.SocketException", | |
| 668 | + "socketGetOption: Unable to tokenize status info"); | |
| 669 | + | |
| 670 | + for(i=0;i<m;i++) { | |
| 671 | + str = hd st; | |
| 672 | + st = tl st; | |
| 673 | + if ( strp->prefix( str, s )) { | |
| 674 | + if (p0 == jnet -> SO_LINGER) | |
| 675 | + return int hd st; | |
| 676 | + else if ( p0 == jnet -> TCP_NODELAY) | |
| 677 | + if ( int hd st != 0 ) | |
| 678 | + return 0; | |
| 679 | + else | |
| 680 | + break; | |
| 681 | + } | |
| 682 | + } | |
| 683 | + | |
| 684 | + return -1; | |
| 685 | +}#<< | |
| @@ -0,0 +1,30 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +PlainSocketImpl_L : module | |
| 4 | +{ | |
| 5 | + PlainSocketImpl_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + cfd : ref FileDescriptor_obj; | |
| 9 | + ctype : int; | |
| 10 | + connection : int; | |
| 11 | + fd : ref FileDescriptor_obj; | |
| 12 | + address : ref InetAddress_obj; | |
| 13 | + port : int; | |
| 14 | + localport : int; | |
| 15 | + timeout : int; | |
| 16 | + }; | |
| 17 | + | |
| 18 | + init : fn( jni_p : JNI ); | |
| 19 | + socketCreate_Z_V : fn( this : ref PlainSocketImpl_obj, p0 : int); | |
| 20 | + socketConnect_rInetAddress_I_V : fn( this : ref PlainSocketImpl_obj, p0 : ref InetAddress_obj,p1 : int); | |
| 21 | + socketBind_rInetAddress_I_V : fn( this : ref PlainSocketImpl_obj, p0 : ref InetAddress_obj,p1 : int); | |
| 22 | + socketListen_I_V : fn( this : ref PlainSocketImpl_obj, p0 : int); | |
| 23 | + socketAccept_rSocketImpl_V : fn( this : ref PlainSocketImpl_obj, p0 : ref SocketImpl_obj); | |
| 24 | + socketAvailable_I : fn( this : ref PlainSocketImpl_obj) : int; | |
| 25 | + socketClose_V : fn( this : ref PlainSocketImpl_obj); | |
| 26 | + initProto_V : fn( ); | |
| 27 | + socketSetOption_I_Z_rObject_V : fn( this : ref PlainSocketImpl_obj, p0 : int,p1 : int,p2 : JObject); | |
| 28 | + socketGetOption_I_I : fn( this : ref PlainSocketImpl_obj, p0 : int) : int; | |
| 29 | + | |
| 30 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,19 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +SocketImpl_L : module | |
| 4 | +{ | |
| 5 | + SocketImpl_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + cfd : ref FileDescriptor_obj; | |
| 9 | + ctype: int; | |
| 10 | + connection: int; | |
| 11 | + fd : ref FileDescriptor_obj; | |
| 12 | + address : ref InetAddress_obj; | |
| 13 | + port : int; | |
| 14 | + localport : int; | |
| 15 | + }; | |
| 16 | + | |
| 17 | + init : fn( jni_p : JNI ); | |
| 18 | + | |
| 19 | +}; | |
Empty file added.
| @@ -0,0 +1,173 @@ | ||
| 1 | +implement SocketInputStream_L; | |
| 2 | + | |
| 3 | +include "jni.m"; | |
| 4 | + jni : JNI; | |
| 5 | + ClassModule, | |
| 6 | + JString, | |
| 7 | + JArray, | |
| 8 | + JArrayI, | |
| 9 | + JArrayC, | |
| 10 | + JArrayB, | |
| 11 | + JArrayS, | |
| 12 | + JArrayJ, | |
| 13 | + JArrayF, | |
| 14 | + JArrayD, | |
| 15 | + JArrayZ, | |
| 16 | + JArrayJObject, | |
| 17 | + JArrayJString, | |
| 18 | + JClass, | |
| 19 | + JObject : import jni; | |
| 20 | + | |
| 21 | +#>> extra pre includes here | |
| 22 | + | |
| 23 | +#<< | |
| 24 | + | |
| 25 | +include "SocketInputStream_L.m"; | |
| 26 | + | |
| 27 | +#>> extra post includes here | |
| 28 | + | |
| 29 | +include "jnet.m"; | |
| 30 | + jnet: JNET; | |
| 31 | + | |
| 32 | +include "java/io/FileDescriptor_L.m"; | |
| 33 | + fildes: FileDescriptor_L; | |
| 34 | + | |
| 35 | +include "InetAddress_L.m"; | |
| 36 | + inet: InetAddress_L; | |
| 37 | + | |
| 38 | +FileDescriptor_obj: import fildes; | |
| 39 | +InetAddress_obj: import inet; | |
| 40 | + | |
| 41 | +include "SocketImpl_L.m"; | |
| 42 | + sock: SocketImpl_L; | |
| 43 | + | |
| 44 | +SocketImpl_obj: import sock; | |
| 45 | + | |
| 46 | +include "PlainSocketImpl_L.m"; | |
| 47 | + psock: PlainSocketImpl_L; | |
| 48 | + | |
| 49 | +sys: Sys; | |
| 50 | +strp: String; | |
| 51 | +DEBUG: import jnet; | |
| 52 | +FD: import sys; | |
| 53 | + | |
| 54 | +PlainSocketImpl_obj: import psock; | |
| 55 | + | |
| 56 | +#<< | |
| 57 | + | |
| 58 | +init( jni_p : JNI ) | |
| 59 | +{ | |
| 60 | + # save java native inteface mod instance | |
| 61 | + jni = jni_p; | |
| 62 | + #>>extra initialization here | |
| 63 | + | |
| 64 | + sys = jni->sys; | |
| 65 | + strp = jni->str; | |
| 66 | + | |
| 67 | + #<< | |
| 68 | +} | |
| 69 | + | |
| 70 | +socketRead_aB_I_I_I( this : ref SocketInputStream_obj, p0 : JArrayB,p1 : int,p2 : int) : int | |
| 71 | +{#>> | |
| 72 | + | |
| 73 | + | |
| 74 | + st: list of string; | |
| 75 | + str: string; | |
| 76 | + m: int; | |
| 77 | + | |
| 78 | + # p1 = offset | |
| 79 | + # p2 = length | |
| 80 | + | |
| 81 | + if (p0 == nil ) { | |
| 82 | + if ( DEBUG ) | |
| 83 | + sys->print( "socketRead: p0 ptr to JArrayB is nil\n"); | |
| 84 | + jni->ThrowException( "java.lang.NullPointerException", ""); | |
| 85 | + } | |
| 86 | + | |
| 87 | + if (this.fd == nil ) { | |
| 88 | + if ( DEBUG ) | |
| 89 | + sys->print( "socketRead: this.fd == 0, socket must be closed\n"); | |
| 90 | + jni->ThrowException( "java.net.SocketException", "Socket was closed"); | |
| 91 | + } | |
| 92 | + | |
| 93 | + if ( p2 <0 || p1 < 0 || p1 + p2 > len p0.ary ) { | |
| 94 | + if ( DEBUG ) | |
| 95 | + sys->print( "socketRead: offset: %d/length: %d wrong in byte array\n",p1,p2); | |
| 96 | + jni->ThrowException( "java.lang.ArrayIndexOutOfBoundsException", ""); | |
| 97 | + } | |
| 98 | + | |
| 99 | + | |
| 100 | + if (this.impl == nil ) { | |
| 101 | + if ( DEBUG ) | |
| 102 | + sys->print( "socketRead: p0 ptr to SocketImpl is nil\n"); | |
| 103 | + jni->ThrowException( "java.lang.NullPointerException", "null SocketImpl ref"); | |
| 104 | + } | |
| 105 | + | |
| 106 | + | |
| 107 | + # The TIMEOUT logic... Note modifications to SocketInputStream_L.m | |
| 108 | + # had to be made to support impl ptr as a ref to PlainSocketImpl_obj instead | |
| 109 | + # of JOBJECT... | |
| 110 | + | |
| 111 | + if( this.impl.timeout != 0 ) { | |
| 112 | + temp:= jnet->timeout + " " + string this.impl.timeout; | |
| 113 | + rc := sys->write(this.impl.cfd.fd, array of byte temp, len temp); | |
| 114 | + if (DEBUG) | |
| 115 | + sys->print("socketRead: fixing timeout value %s\n", string this.impl.timeout); | |
| 116 | + if ( rc <= 0 ) | |
| 117 | + jni->ThrowException("java.net.SocketException", | |
| 118 | + "socketRead: Unable to set timeout"); | |
| 119 | + } | |
| 120 | + | |
| 121 | + # Do Read of data file into buffer... | |
| 122 | + if (DEBUG) | |
| 123 | + sys->print("Reading into JArrayB for %d bytes\n",p2); | |
| 124 | + | |
| 125 | + n := sys->read(this.fd.fd, array of byte p0.ary[p1: ], p2); | |
| 126 | + | |
| 127 | + if (DEBUG) | |
| 128 | + sys->print("SocketInputStream: read of socket: %s\n", string p0.ary[p1:n]); | |
| 129 | + | |
| 130 | + # Check status file to for timeout... | |
| 131 | + | |
| 132 | + if (this.impl.ctype == jnet->SOCK_STREAM) | |
| 133 | + ctype:= "tcp"; | |
| 134 | + else | |
| 135 | + ctype = "udp"; | |
| 136 | + | |
| 137 | + buf:= array[256] of byte; | |
| 138 | + | |
| 139 | + dir := "/net/" + ctype + "/" + string this.impl.connection + "/status"; | |
| 140 | + sfd := sys->open( dir, sys->OREAD ); | |
| 141 | + if (sfd == nil ) { | |
| 142 | + if (DEBUG) | |
| 143 | + sys->print( "socketInputStreamRead: Open of status file %s returned nil fd\n", dir); | |
| 144 | + jni->ThrowException( "java.net.SocketException", | |
| 145 | + "socketInputStreamRead: Read failed"); | |
| 146 | + } | |
| 147 | + | |
| 148 | + k := sys->read(sfd, buf, len buf); | |
| 149 | + if (DEBUG) | |
| 150 | + sys->print("socketInputStreamRead: status file has: %s\n", string buf[0:k]); | |
| 151 | + if ( k > 0 ) { | |
| 152 | + (m, st) = sys->tokenize( string buf, " \t\n"); | |
| 153 | + for(i:=0;i<m;i++) { | |
| 154 | + str = hd st; | |
| 155 | + if ( strp->prefix( str, "timed-out" )) { | |
| 156 | + if (DEBUG) | |
| 157 | + sys->print( "socketAccept: timeout\n"); | |
| 158 | + jni->ThrowException("java.io.InterruptedIOException", | |
| 159 | + "socketInputStreamRead: Read timed out."); | |
| 160 | + } | |
| 161 | + st = tl st; | |
| 162 | + } | |
| 163 | + } | |
| 164 | + | |
| 165 | + | |
| 166 | + if ( n < 0 ) { | |
| 167 | + if ( DEBUG ) | |
| 168 | + sys->print( "socketRead: Read failed with code %d\n", n); | |
| 169 | + jni->ThrowException( "java.net.SocketException", "Read failed"); | |
| 170 | + } | |
| 171 | + return n; | |
| 172 | + | |
| 173 | +}#<< | |
| @@ -0,0 +1,17 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +SocketInputStream_L : module | |
| 4 | +{ | |
| 5 | + SocketInputStream_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + fd : ref FileDescriptor_obj; | |
| 9 | + eof : int; | |
| 10 | + impl : ref PlainSocketImpl_obj; | |
| 11 | + temp : JArrayB; | |
| 12 | + }; | |
| 13 | + | |
| 14 | + init : fn( jni_p : JNI ); | |
| 15 | + socketRead_aB_I_I_I : fn( this : ref SocketInputStream_obj, p0 : JArrayB,p1 : int,p2 : int) : int; | |
| 16 | + | |
| 17 | +}; | |
Empty file added.
Empty file added.
| @@ -0,0 +1,95 @@ | ||
| 1 | +implement SocketOutputStream_L; | |
| 2 | + | |
| 3 | +include "jni.m"; | |
| 4 | + jni : JNI; | |
| 5 | + ClassModule, | |
| 6 | + JString, | |
| 7 | + JArray, | |
| 8 | + JArrayI, | |
| 9 | + JArrayC, | |
| 10 | + JArrayB, | |
| 11 | + JArrayS, | |
| 12 | + JArrayJ, | |
| 13 | + JArrayF, | |
| 14 | + JArrayD, | |
| 15 | + JArrayZ, | |
| 16 | + JArrayJObject, | |
| 17 | + JArrayJString, | |
| 18 | + JClass, | |
| 19 | + JObject : import jni; | |
| 20 | + | |
| 21 | +#>> extra pre includes here | |
| 22 | + | |
| 23 | +#<< | |
| 24 | + | |
| 25 | +include "SocketOutputStream_L.m"; | |
| 26 | + | |
| 27 | +#>> extra post includes here | |
| 28 | + | |
| 29 | + | |
| 30 | +include "jnet.m"; | |
| 31 | + jnet: JNET; | |
| 32 | + | |
| 33 | +include "java/io/FileDescriptor_L.m"; | |
| 34 | + fildes: FileDescriptor_L; | |
| 35 | + | |
| 36 | +include "InetAddress_L.m"; | |
| 37 | + inet: InetAddress_L; | |
| 38 | + | |
| 39 | +sys: Sys; | |
| 40 | + | |
| 41 | +DEBUG: import jnet; | |
| 42 | +FD: import sys; | |
| 43 | +FileDescriptor_obj: import fildes; | |
| 44 | +InetAddress_obj: import inet; | |
| 45 | + | |
| 46 | +#<< | |
| 47 | + | |
| 48 | +init( jni_p : JNI ) | |
| 49 | +{ | |
| 50 | + # save java native inteface mod instance | |
| 51 | + jni = jni_p; | |
| 52 | + #>>extra initialization here | |
| 53 | + | |
| 54 | + sys = jni->sys; | |
| 55 | + | |
| 56 | + if (DEBUG) | |
| 57 | + sys->print("socketOutputStream: init()\n"); | |
| 58 | + #<< | |
| 59 | +} | |
| 60 | + | |
| 61 | +socketWrite_aB_I_I_V( this : ref SocketOutputStream_obj, p0 : JArrayB,p1 : int,p2 : int) | |
| 62 | +{#>> | |
| 63 | + | |
| 64 | + | |
| 65 | + if (this.fd == nil ) { | |
| 66 | + if ( DEBUG ) | |
| 67 | + sys->print( "socketWrite: this.fd == 0, socket must be closed\n"); | |
| 68 | + jni->ThrowException( "java.net.SocketException", "Socket was closed"); | |
| 69 | + } | |
| 70 | + | |
| 71 | + if ( p2 <0 || p1 < 0 || p1 + p2 > len p0.ary ) { | |
| 72 | + if ( DEBUG ) | |
| 73 | + sys->print( "socketWrite: offset: %d/length: %d wrong in byte array\n",p1,p2); | |
| 74 | + jni->ThrowException( "java.lang.ArrayIndexOutOfBoundsException", ""); | |
| 75 | + } | |
| 76 | + | |
| 77 | + if (p0 == nil ) { | |
| 78 | + if ( DEBUG ) | |
| 79 | + sys->print( "socketWrite: p0 ptr to JArrayB is nil\n"); | |
| 80 | + jni->ThrowException( "java.lang.NullPointerException", ""); | |
| 81 | + } | |
| 82 | + | |
| 83 | + # Write into buffer... | |
| 84 | + if (DEBUG) | |
| 85 | + sys->print("Writing into JArrayB for %d bytes\n",p2); | |
| 86 | + n := sys->write(this.fd.fd, p0.ary[p1: ], p2); | |
| 87 | + if ( n < 0 ) { | |
| 88 | + if ( DEBUG ) | |
| 89 | + sys->print( "socketWrite: Read failed with code %d\n", n); | |
| 90 | + jni->ThrowException( "java.net.SocketException", "Write failed"); | |
| 91 | + } | |
| 92 | + return; | |
| 93 | + | |
| 94 | +}#<< | |
| 95 | + | |
| @@ -0,0 +1,16 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +SocketOutputStream_L : module | |
| 4 | +{ | |
| 5 | + SocketOutputStream_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + fd : ref FileDescriptor_obj; | |
| 9 | + impl : JObject; | |
| 10 | + temp : JArrayB; | |
| 11 | + }; | |
| 12 | + | |
| 13 | + init : fn( jni_p : JNI ); | |
| 14 | + socketWrite_aB_I_I_V : fn( this : ref SocketOutputStream_obj, p0 : JArrayB,p1 : int,p2 : int); | |
| 15 | + | |
| 16 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,23 @@ | ||
| 1 | +JNET: module | |
| 2 | +{ | |
| 3 | + # These are taken from solaris | |
| 4 | + | |
| 5 | + AF_INET: con 2; | |
| 6 | + INADDR_ANY: con 0; | |
| 7 | + | |
| 8 | + SOCK_STREAM: con 2; | |
| 9 | + SOCK_DGRAM: con 1; | |
| 10 | + SO_LINGER: con 16r80; | |
| 11 | + SO_REUSEADDR: con 16r04; | |
| 12 | + TCP_NODELAY: con 16r01; | |
| 13 | + | |
| 14 | + SO_BINADDR: con 16r0F; | |
| 15 | + IP_MULTICAST_IF: con 16r10; | |
| 16 | + | |
| 17 | + timeout: con "rcvtimeo"; | |
| 18 | + linger: con "linger"; | |
| 19 | + nodelay: con "nodelay"; | |
| 20 | + | |
| 21 | + IPADDRLEN: con 4; | |
| 22 | + DEBUG: con 0; | |
| 23 | +}; | |
| @@ -0,0 +1,100 @@ | ||
| 1 | +<../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + BindException.dis\ | |
| 5 | + ConnectException.dis\ | |
| 6 | + ContentHandler.dis\ | |
| 7 | + ContentHandlerFactory.dis\ | |
| 8 | + DatagramPacket.dis\ | |
| 9 | + DatagramSocket.dis\ | |
| 10 | + DatagramSocketImpl.dis\ | |
| 11 | + FileNameMap.dis\ | |
| 12 | + HttpURLConnection.dis\ | |
| 13 | + InetAddress.dis\ | |
| 14 | + InetAddressImpl.dis\ | |
| 15 | + MalformedURLException.dis\ | |
| 16 | + MulticastSocket.dis\ | |
| 17 | +# for NoRouteToHostException.dis\ | |
| 18 | + r9PkdNz+JgG1Itcw2f6YJ.dis\ | |
| 19 | +# for PlainDatagramSocketImpl.dis\ | |
| 20 | + 5zd2a5CaD3UBT8TZHMXzK.dis\ | |
| 21 | + PlainSocketImpl.dis\ | |
| 22 | + ProtocolException.dis\ | |
| 23 | + ServerSocket.dis\ | |
| 24 | + Socket.dis\ | |
| 25 | + SocketException.dis\ | |
| 26 | + SocketImpl.dis\ | |
| 27 | + SocketImplFactory.dis\ | |
| 28 | + SocketInputStream.dis\ | |
| 29 | + SocketOptions.dis\ | |
| 30 | + SocketOutputStream.dis\ | |
| 31 | + URL.dis\ | |
| 32 | + URLConnection.dis\ | |
| 33 | + URLEncoder.dis\ | |
| 34 | + URLStreamHandler.dis\ | |
| 35 | +# for URLStreamHandlerFactory.dis\ | |
| 36 | + O1DuMby-OVJt3a8-blgAl.dis\ | |
| 37 | + UnknownContentHandler.dis\ | |
| 38 | + UnknownHostException.dis\ | |
| 39 | +# for UnknownServiceException.dis\ | |
| 40 | + r10zsfdVB4eiod6AyF43R.dis\ | |
| 41 | +# Limbo code\ | |
| 42 | + InetAddressImpl_L.dis\ | |
| 43 | +# for PlainDatagramSocketImpl_L.dis\ | |
| 44 | + 5zd2a5CaD3UBT8TZHMXzK_L.dis\ | |
| 45 | + PlainSocketImpl_L.dis\ | |
| 46 | + SocketInputStream_L.dis\ | |
| 47 | + SocketOutputStream_L.dis\ | |
| 48 | + | |
| 49 | +MODULES=\ | |
| 50 | + $ROOT/java/module/classloader.m\ | |
| 51 | + $ROOT/java/module/jni.m\ | |
| 52 | + $ROOT/java/module/cast.m\ | |
| 53 | + DatagramPacket_L.m\ | |
| 54 | + DatagramSocketImpl_L.m\ | |
| 55 | + InetAddressImpl_L.m\ | |
| 56 | + InetAddress_L.m\ | |
| 57 | + PlainDatagramSocketImpl_L.m\ | |
| 58 | + PlainSocketImpl_L.m\ | |
| 59 | + SocketImpl_L.m\ | |
| 60 | + SocketInputStream_L.m\ | |
| 61 | + SocketOutputStream_L.m\ | |
| 62 | + jnet.m\ | |
| 63 | + | |
| 64 | +SYSMODULES=\ | |
| 65 | + draw.m\ | |
| 66 | + hash.m\ | |
| 67 | + keyring.m\ | |
| 68 | + loader.m\ | |
| 69 | + math.m\ | |
| 70 | + string.m\ | |
| 71 | + sys.m\ | |
| 72 | + | |
| 73 | +DISBIN=$ROOT/java/dis/java/java/net | |
| 74 | + | |
| 75 | +<$ROOT/mkfiles/mkjava | |
| 76 | + | |
| 77 | +LIMBOINCL=\ | |
| 78 | + $LIMBOINCL\ | |
| 79 | + -I$ROOT/java/pkg\ | |
| 80 | + | |
| 81 | +InetAddressImpl.dis: InetAddress.class | |
| 82 | + j2d InetAddressImpl.class | |
| 83 | + | |
| 84 | +r9PkdNz+JgG1Itcw2f6YJ.dis: NoRouteToHostException.class | |
| 85 | + j2d NoRouteToHostException.class | |
| 86 | + | |
| 87 | +5zd2a5CaD3UBT8TZHMXzK.dis: PlainDatagramSocketImpl.class | |
| 88 | + j2d PlainDatagramSocketImpl.class | |
| 89 | + | |
| 90 | +UnknownContentHandler.dis: URLConnection.class | |
| 91 | + j2d UnknownContentHandler.class | |
| 92 | + | |
| 93 | +O1DuMby-OVJt3a8-blgAl.dis: URLStreamHandlerFactory.class | |
| 94 | + j2d URLStreamHandlerFactory.class | |
| 95 | + | |
| 96 | +r10zsfdVB4eiod6AyF43R.dis: UnknownServiceException.class | |
| 97 | + j2d UnknownServiceException.class | |
| 98 | + | |
| 99 | +5zd2a5CaD3UBT8TZHMXzK_L.dis: PlainDatagramSocketImpl_L.b | |
| 100 | + limbo $LIMBOFLAGS $LIMBOINCL -gw -o $target PlainDatagramSocketImpl_L.b | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,22 @@ | ||
| 1 | +<../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + DigestException.dis\ | |
| 5 | + DigestOutputStream.dis\ | |
| 6 | + MessageDigest.dis\ | |
| 7 | +# for NoSuchAlgorithmException.dis\ | |
| 8 | + RnrbF1WrtSRsKMq-afpiR.dis\ | |
| 9 | +# for NoSuchProviderException.dis\ | |
| 10 | + 5GZfzesuxCFJ93DgPnKzv.dis\ | |
| 11 | + Provider.dis\ | |
| 12 | + Security.dis\ | |
| 13 | + | |
| 14 | +DISBIN=$ROOT/java/dis/java/java/security | |
| 15 | + | |
| 16 | +<$ROOT/mkfiles/mkjava | |
| 17 | + | |
| 18 | +RnrbF1WrtSRsKMq-afpiR.dis: NoSuchAlgorithmException.class | |
| 19 | + j2d $prereq | |
| 20 | + | |
| 21 | +5GZfzesuxCFJ93DgPnKzv.dis: NoSuchProviderException.class | |
| 22 | + j2d $prereq | |
Empty file added.
| @@ -0,0 +1,782 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)Calendar.java 1.23 97/01/29 | |
| 3 | + * | |
| 4 | + * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved | |
| 5 | + * (C) Copyright IBM Corp. 1996 - All Rights Reserved | |
| 6 | + * | |
| 7 | + * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 8 | + * | |
| 9 | + * The original version of this source code and documentation is copyrighted | |
| 10 | + * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These | |
| 11 | + * materials are provided under terms of a License Agreement between Taligent | |
| 12 | + * and Sun. This technology is protected by multiple US and International | |
| 13 | + * patents. This notice and attribution to Taligent may not be removed. | |
| 14 | + * Taligent is a registered trademark of Taligent, Inc. | |
| 15 | + * | |
| 16 | + * Permission to use, copy, modify, and distribute this software | |
| 17 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 18 | + * fee is hereby granted provided that this copyright notice | |
| 19 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 20 | + * for further important copyright and licensing information. | |
| 21 | + * | |
| 22 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 23 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 24 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 25 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 26 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 27 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | +package java.util; | |
| 32 | + | |
| 33 | +import java.io.Serializable; | |
| 34 | +import java.io.ObjectInputStream; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * <code>Calendar</code> is an abstract base class for converting between | |
| 38 | + * a <code>Date</code> object and a set of integer fields such as | |
| 39 | + * <code>YEAR</code>, <code>MONTH</code>, <code>DAY</code>, <code>HOUR</code>, | |
| 40 | + * and so on. (A <code>Date</code> object represents a specific instant in | |
| 41 | + * time with millisecond precision. See | |
| 42 | + * <a href="java.util.Date.html"><code>java.util.Date</code></a> | |
| 43 | + * for information about the <code>Date</code> class.) | |
| 44 | + * | |
| 45 | + * <p> | |
| 46 | + * Subclasses of <code>Calendar</code> interpret a <code>Date</code> | |
| 47 | + * according to the rules of a specific calendar system. The JDK | |
| 48 | + * provides one concrete subclass of <code>Calendar</code>: | |
| 49 | + * <code>GregorianCalendar</code>. Future subclasses could represent | |
| 50 | + * the various types of lunar calendars in use in many parts of the world. | |
| 51 | + * | |
| 52 | + * <p> | |
| 53 | + * Like other locale-sensitive classes, <code>Calendar</code> provides a | |
| 54 | + * class method, <code>getInstance</code>, for getting a generally useful | |
| 55 | + * object of this type. <code>Calendar</code>'s <code>getInstance</code> method | |
| 56 | + * returns a <code>GregorianCalendar</code> object whose | |
| 57 | + * time fields have been initialized with the current date and time: | |
| 58 | + * <blockquote> | |
| 59 | + * <pre> | |
| 60 | + * Calendar rightNow = Calendar.getInstance(); | |
| 61 | + * </pre> | |
| 62 | + * </blockquote> | |
| 63 | + * | |
| 64 | + * <p> | |
| 65 | + * A <code>Calendar</code> object can produce all the time field values | |
| 66 | + * needed to implement the date-time formatting for a particular language | |
| 67 | + * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional). | |
| 68 | + * | |
| 69 | + * <p> | |
| 70 | + * When computing a <code>Date</code> from time fields, two special circumstances | |
| 71 | + * may arise: there may be insufficient information to compute the | |
| 72 | + * <code>Date</code> (such as only year and month but no day in the month), | |
| 73 | + * or there may be inconsistent information (such as "Tuesday, July 15, 1996" | |
| 74 | + * -- July 15, 1996 is actually a Monday). | |
| 75 | + * | |
| 76 | + * <p> | |
| 77 | + * <strong>Insufficient information.</strong> The calendar will use default | |
| 78 | + * information to specify the missing fields. This may vary by calendar; for | |
| 79 | + * the Gregorian calendar, the default for a field is the same as that of the | |
| 80 | + * start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc. | |
| 81 | + * | |
| 82 | + * <p> | |
| 83 | + * <strong>Inconsistent information.</strong> The calendar will give preference | |
| 84 | + * to the combinations of fields in the following order (and disregard other | |
| 85 | + * inconsistent information). | |
| 86 | + * | |
| 87 | + * <blockquote> | |
| 88 | + * <pre> | |
| 89 | + * month + day-of-month | |
| 90 | + * month + week-of-month + day-of-week | |
| 91 | + * month + day-of-week-of-month + day-of-week | |
| 92 | + * day-of-year | |
| 93 | + * day-of-week + week-of-year | |
| 94 | + * hour-of-day | |
| 95 | + * ampm + hour-of-ampm | |
| 96 | + * </pre> | |
| 97 | + * </blockquote> | |
| 98 | + * | |
| 99 | + * <p> | |
| 100 | + * <strong>Note:</strong> for some non-Gregorian calendars, different | |
| 101 | + * fields may be necessary for complete disambiguation. For example, a full | |
| 102 | + * specification of the historial Arabic astronomical calendar requires year, | |
| 103 | + * month, day-of-month <em>and</em> day-of-week in some cases. | |
| 104 | + * | |
| 105 | + * <p> | |
| 106 | + * <strong>Note:</strong> There are certain possible ambiguities in | |
| 107 | + * interpretation of certain singular times, which are resolved in the | |
| 108 | + * following ways: | |
| 109 | + * <ol> | |
| 110 | + * <li> 24:00:00 "belongs" to the following day. That is, | |
| 111 | + * 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970 | |
| 112 | + * | |
| 113 | + * <li> Although historically not precise, midnight also belongs to "am", | |
| 114 | + * and noon belongs to "pm", so on the same day, | |
| 115 | + * 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm | |
| 116 | + * </ol> | |
| 117 | + * | |
| 118 | + * <p> | |
| 119 | + * The date or time format strings are not part of the definition of a | |
| 120 | + * calendar, as those must be modifiable or overridable by the user at | |
| 121 | + * runtime. Use <a href="java.text.DateFormat.html">java.text.DateFormat</a> | |
| 122 | + * to format dates. | |
| 123 | + * | |
| 124 | + * <p> | |
| 125 | + * <code>Calendar</code> provides an API for field "rolling", where fields | |
| 126 | + * can be incremented or decremented, but wrap around. For example, rolling the | |
| 127 | + * month up in the date "September 12, 1996" results in "October 12, 1996". | |
| 128 | + * | |
| 129 | + * <p> | |
| 130 | + * <code>Calendar</code> also provides a date arithmetic function for | |
| 131 | + * adding the specified (signed) amount of time to a particular time field. | |
| 132 | + * For example, subtracting 5 days from the date "September 12, 1996" results | |
| 133 | + * in "September 7, 1996". | |
| 134 | + * | |
| 135 | + * @see Date | |
| 136 | + * @see GregorianCalendar | |
| 137 | + * @see TimeZone | |
| 138 | + * @see java.text.DateFormat | |
| 139 | + * @version 1.17 06 Jan 1997 | |
| 140 | + * @author Mark Davis, David Goldsmith, Chen-Lieh Huang | |
| 141 | + */ | |
| 142 | +public abstract class Calendar implements Serializable, Cloneable { | |
| 143 | + | |
| 144 | + /** | |
| 145 | + * Useful constant for date and time. Used in time fields. | |
| 146 | + * ERA is calendar specific. | |
| 147 | + */ | |
| 148 | + public final static int ERA = 0; | |
| 149 | + /** | |
| 150 | + * Useful constant for date and time. Used in time fields. | |
| 151 | + */ | |
| 152 | + public final static int YEAR = 1; | |
| 153 | + /** | |
| 154 | + * Useful constant for date and time. Used in time fields. | |
| 155 | + */ | |
| 156 | + public final static int MONTH = 2; | |
| 157 | + /** | |
| 158 | + * Useful constant for date and time. Used in time fields. | |
| 159 | + */ | |
| 160 | + public final static int WEEK_OF_YEAR = 3; | |
| 161 | + /** | |
| 162 | + * Useful constant for date and time. Used in time fields. | |
| 163 | + */ | |
| 164 | + public final static int WEEK_OF_MONTH = 4; | |
| 165 | + /** | |
| 166 | + * Useful constant for date and time. Used in time fields. | |
| 167 | + * DATE is the time field name for day-of-month. | |
| 168 | + */ | |
| 169 | + public final static int DATE = 5; | |
| 170 | + /** | |
| 171 | + * Useful constant for date and time. Used in time fields. | |
| 172 | + * This is a synonym for DATE. | |
| 173 | + */ | |
| 174 | + public final static int DAY_OF_MONTH = 5; | |
| 175 | + /** | |
| 176 | + * Useful constant for date and time. Used in time fields. | |
| 177 | + */ | |
| 178 | + public final static int DAY_OF_YEAR = 6; | |
| 179 | + /** | |
| 180 | + * Useful constant for date and time. Used in time fields. | |
| 181 | + */ | |
| 182 | + public final static int DAY_OF_WEEK = 7; | |
| 183 | + /** | |
| 184 | + * Useful constant for date and time. Used in time fields. | |
| 185 | + */ | |
| 186 | + public final static int DAY_OF_WEEK_IN_MONTH = 8; | |
| 187 | + /** | |
| 188 | + * Useful constant for date and time. Used in time fields. | |
| 189 | + */ | |
| 190 | + public final static int AM_PM = 9; | |
| 191 | + /** | |
| 192 | + * Useful constant for date and time. Used in time fields. | |
| 193 | + * HOUR is used for the 12-hour clock. | |
| 194 | + */ | |
| 195 | + public final static int HOUR = 10; | |
| 196 | + /** | |
| 197 | + * Useful constant for date and time. Used in time fields. | |
| 198 | + * HOUR_OF_DAY is used for the 24-hour clock. | |
| 199 | + */ | |
| 200 | + public final static int HOUR_OF_DAY = 11; | |
| 201 | + /** | |
| 202 | + * Useful constant for date and time. Used in time fields. | |
| 203 | + */ | |
| 204 | + public final static int MINUTE = 12; | |
| 205 | + /** | |
| 206 | + * Useful constant for date and time. Used in time fields. | |
| 207 | + */ | |
| 208 | + public final static int SECOND = 13; | |
| 209 | + /** | |
| 210 | + * Useful constant for date and time. Used in time fields. | |
| 211 | + */ | |
| 212 | + public final static int MILLISECOND = 14; | |
| 213 | + /** | |
| 214 | + * Useful constant for date and time. Used in time fields. | |
| 215 | + */ | |
| 216 | + public final static int ZONE_OFFSET = 15; | |
| 217 | + /** | |
| 218 | + * Useful constant for date and time. Used in time fields. | |
| 219 | + */ | |
| 220 | + public final static int DST_OFFSET = 16; | |
| 221 | + /** | |
| 222 | + * Useful constant for date and time. | |
| 223 | + * FIELD_COUNT is used for the time field array creation. | |
| 224 | + */ | |
| 225 | + public final static int FIELD_COUNT = 17; | |
| 226 | + | |
| 227 | + /** | |
| 228 | + * Useful constant for days of week. Used in GregorianCalendar. | |
| 229 | + */ | |
| 230 | + public final static int SUNDAY = 1; | |
| 231 | + /** | |
| 232 | + * Useful constant for days of week. Used in GregorianCalendar. | |
| 233 | + */ | |
| 234 | + public final static int MONDAY = 2; | |
| 235 | + /** | |
| 236 | + * Useful constant for days of week. Used in GregorianCalendar. | |
| 237 | + */ | |
| 238 | + public final static int TUESDAY = 3; | |
| 239 | + /** | |
| 240 | + * Useful constant for days of week. Used in GregorianCalendar. | |
| 241 | + */ | |
| 242 | + public final static int WEDNESDAY = 4; | |
| 243 | + /** | |
| 244 | + * Useful constant for days of week. Used in GregorianCalendar. | |
| 245 | + */ | |
| 246 | + public final static int THURSDAY = 5; | |
| 247 | + /** | |
| 248 | + * Useful constant for days of week. Used in GregorianCalendar. | |
| 249 | + */ | |
| 250 | + public final static int FRIDAY = 6; | |
| 251 | + /** | |
| 252 | + * Useful constant for days of week. Used in GregorianCalendar. | |
| 253 | + */ | |
| 254 | + public final static int SATURDAY = 7; | |
| 255 | + /** | |
| 256 | + * Useful constant for month. Used in GregorianCalendar. | |
| 257 | + * Note: Calendar month is now 0-based. | |
| 258 | + */ | |
| 259 | + public final static int JANUARY = 0; | |
| 260 | + /** | |
| 261 | + * Useful constant for month. Used in GregorianCalendar. | |
| 262 | + */ | |
| 263 | + public final static int FEBRUARY = 1; | |
| 264 | + /** | |
| 265 | + * Useful constant for month. Used in GregorianCalendar. | |
| 266 | + */ | |
| 267 | + public final static int MARCH = 2; | |
| 268 | + /** | |
| 269 | + * Useful constant for month. Used in GregorianCalendar. | |
| 270 | + */ | |
| 271 | + public final static int APRIL = 3; | |
| 272 | + /** | |
| 273 | + * Useful constant for month. Used in GregorianCalendar. | |
| 274 | + */ | |
| 275 | + public final static int MAY = 4; | |
| 276 | + /** | |
| 277 | + * Useful constant for month. Used in GregorianCalendar. | |
| 278 | + */ | |
| 279 | + public final static int JUNE = 5; | |
| 280 | + /** | |
| 281 | + * Useful constant for month. Used in GregorianCalendar. | |
| 282 | + */ | |
| 283 | + public final static int JULY = 6; | |
| 284 | + /** | |
| 285 | + * Useful constant for month. Used in GregorianCalendar. | |
| 286 | + */ | |
| 287 | + public final static int AUGUST = 7; | |
| 288 | + /** | |
| 289 | + * Useful constant for month. Used in GregorianCalendar. | |
| 290 | + */ | |
| 291 | + public final static int SEPTEMBER = 8; | |
| 292 | + /** | |
| 293 | + * Useful constant for month. Used in GregorianCalendar. | |
| 294 | + */ | |
| 295 | + public final static int OCTOBER = 9; | |
| 296 | + /** | |
| 297 | + * Useful constant for month. Used in GregorianCalendar. | |
| 298 | + */ | |
| 299 | + public final static int NOVEMBER = 10; | |
| 300 | + /** | |
| 301 | + * Useful constant for month. Used in GregorianCalendar. | |
| 302 | + */ | |
| 303 | + public final static int DECEMBER = 11; | |
| 304 | + /** | |
| 305 | + * Useful constant for month. Used in GregorianCalendar. | |
| 306 | + * UNDECIMBER is an artifical name. This 13th month is for lunar | |
| 307 | + * calendars. | |
| 308 | + */ | |
| 309 | + public final static int UNDECIMBER = 12; | |
| 310 | + /** | |
| 311 | + * Useful constant for hour in 12-hour clock. Used in GregorianCalendar. | |
| 312 | + */ | |
| 313 | + public final static int AM = 0; | |
| 314 | + /** | |
| 315 | + * Useful constant for hour in 12-hour clock. Used in GregorianCalendar. | |
| 316 | + */ | |
| 317 | + public final static int PM = 1; | |
| 318 | + | |
| 319 | + // | |
| 320 | + // Internal notes: | |
| 321 | + // Calendar contains two kinds of time representations: current "time" in | |
| 322 | + // milliseconds, and a set of time "fields" representing the current time. | |
| 323 | + // Calling setTime() method only sets the current time without recomputing | |
| 324 | + // the time fields until the next get() method is called. Similarly, | |
| 325 | + // calling one of the set() methods only sets time fields without | |
| 326 | + // recomputing the current time value until the next getTime() method is | |
| 327 | + // called. | |
| 328 | + // | |
| 329 | + | |
| 330 | + /** | |
| 331 | + * The time fields containing values into which the millis is computed. | |
| 332 | + */ | |
| 333 | + protected int fields[]; | |
| 334 | + /** | |
| 335 | + * The flags which tell if a specified time field for the calendar is set. | |
| 336 | + */ | |
| 337 | + protected boolean isSet[]; | |
| 338 | + /** | |
| 339 | + * The current time set for the calendar. | |
| 340 | + */ | |
| 341 | + protected long time; | |
| 342 | + /** | |
| 343 | + * The flag which indicates if the current time is set for the calendar. | |
| 344 | + */ | |
| 345 | + protected boolean isTimeSet; | |
| 346 | + /** | |
| 347 | + * The flag which tells if the time fields are set for the calendar. | |
| 348 | + */ | |
| 349 | + protected boolean areFieldsSet; | |
| 350 | + | |
| 351 | + /** | |
| 352 | + * @see #setLenient | |
| 353 | + */ | |
| 354 | + private boolean lenient=true; | |
| 355 | + | |
| 356 | + /** | |
| 357 | + * Time zone affects the time calculation done by Calendar. Calendar uses | |
| 358 | + * the time zone data to produce the local time. Both firstDayOfWeek | |
| 359 | + * and minimalDaysInFirstWeek are locale-dependent. For example, | |
| 360 | + * in US locale, firstDayOfWeek is SUNDAY; minimalDaysInFirstWeek is 1. | |
| 361 | + * They are used to figure out the week count for a specific date for | |
| 362 | + * a given locale. These must be set when a Calendar is constructed. | |
| 363 | + */ | |
| 364 | + private TimeZone zone; | |
| 365 | + private int firstDayOfWeek; | |
| 366 | + private int minimalDaysInFirstWeek; | |
| 367 | + | |
| 368 | + /** | |
| 369 | + * Constructs a Calendar with the default time zone as returned | |
| 370 | + * by TimeZone.getDefault(), and the default locale. | |
| 371 | + * @see TimeZone#getDefault | |
| 372 | + */ | |
| 373 | + protected Calendar() | |
| 374 | + { | |
| 375 | + throw new NoSuchElementException(); | |
| 376 | + } | |
| 377 | + | |
| 378 | + /** | |
| 379 | + * Constructs a Calendar with the given time zone and locale. | |
| 380 | + * @param zone the given time zone. | |
| 381 | + */ | |
| 382 | + protected Calendar(TimeZone zone, Locale aLocale) | |
| 383 | + { | |
| 384 | + throw new NoSuchElementException(); | |
| 385 | + } | |
| 386 | + | |
| 387 | + /** | |
| 388 | + * Gets a Calendar using the default timezone and locale. | |
| 389 | + * @return a Calendar. | |
| 390 | + */ | |
| 391 | + public static synchronized Calendar getInstance() | |
| 392 | + { | |
| 393 | + throw new NoSuchElementException(); | |
| 394 | + } | |
| 395 | + | |
| 396 | + /** | |
| 397 | + * Gets a Calendar using the given timezone and default locale. | |
| 398 | + * @param zone the given timezone. | |
| 399 | + * @return a Calendar. | |
| 400 | + */ | |
| 401 | + public static synchronized Calendar getInstance(TimeZone zone) | |
| 402 | + { | |
| 403 | + throw new NoSuchElementException(); | |
| 404 | + } | |
| 405 | + | |
| 406 | + /** | |
| 407 | + * Gets a Calendar using the default timezone and given locale. | |
| 408 | + * @param aLocale the given locale. | |
| 409 | + * @return a Calendar. | |
| 410 | + */ | |
| 411 | + public static synchronized Calendar getInstance(Locale aLocale) | |
| 412 | + { | |
| 413 | + throw new NoSuchElementException(); | |
| 414 | + } | |
| 415 | + | |
| 416 | + /** | |
| 417 | + * Gets a Calendar using the given timezone and given locale. | |
| 418 | + * @param zone the given timezone. | |
| 419 | + * @param aLocale the given locale. | |
| 420 | + * @return a Calendar. | |
| 421 | + */ | |
| 422 | + public static synchronized Calendar getInstance(TimeZone zone, | |
| 423 | + Locale aLocale) | |
| 424 | + { | |
| 425 | + throw new NoSuchElementException(); | |
| 426 | + } | |
| 427 | + | |
| 428 | + /** | |
| 429 | + * Gets the set of locales for which Calendars are installed. | |
| 430 | + * @return the set of locales for which Calendars are installed. | |
| 431 | + */ | |
| 432 | + public static synchronized Locale[] getAvailableLocales() | |
| 433 | + { | |
| 434 | + throw new NoSuchElementException(); | |
| 435 | + } | |
| 436 | + | |
| 437 | + /** | |
| 438 | + * Converts Calendar's time field values to UTC as milliseconds. | |
| 439 | + */ | |
| 440 | + protected abstract void computeTime(); | |
| 441 | + | |
| 442 | + /** | |
| 443 | + * Converts UTC as milliseconds to time field values. | |
| 444 | + * This allows you to sync up the time field values with | |
| 445 | + * a new time that is set for the calendar. | |
| 446 | + */ | |
| 447 | + protected abstract void computeFields(); | |
| 448 | + | |
| 449 | + /** | |
| 450 | + * Gets this Calendar's current time. | |
| 451 | + * @return the current time. | |
| 452 | + */ | |
| 453 | + public final Date getTime() { | |
| 454 | + throw new NoSuchElementException(); | |
| 455 | + } | |
| 456 | + | |
| 457 | + /** | |
| 458 | + * Sets this Calendar's current time with the given Date. | |
| 459 | + * @param date the given Date. | |
| 460 | + */ | |
| 461 | + public final void setTime(Date date) { | |
| 462 | + throw new NoSuchElementException(); | |
| 463 | + } | |
| 464 | + | |
| 465 | + /** | |
| 466 | + * Gets this Calendar's current time as a long. | |
| 467 | + * @return the current time as milliseconds from the epoch. | |
| 468 | + */ | |
| 469 | + protected long getTimeInMillis() { | |
| 470 | + throw new NoSuchElementException(); | |
| 471 | + } | |
| 472 | + | |
| 473 | + /** | |
| 474 | + * Sets this Calendar's current time from the given long value. | |
| 475 | + * @param date the new time in milliseconds from the epoch. | |
| 476 | + */ | |
| 477 | + protected void setTimeInMillis( long millis ) { | |
| 478 | + throw new NoSuchElementException(); | |
| 479 | + } | |
| 480 | + | |
| 481 | + | |
| 482 | + /** | |
| 483 | + * Gets the value for a given time field. | |
| 484 | + * @param field the given time field. | |
| 485 | + * @return the value for the given time field. | |
| 486 | + */ | |
| 487 | + public final int get(int field) | |
| 488 | + { | |
| 489 | + throw new NoSuchElementException(); | |
| 490 | + } | |
| 491 | + | |
| 492 | + /** | |
| 493 | + * Gets the value for a given time field. This is an internal | |
| 494 | + * fast time field value getter for the subclasses. | |
| 495 | + * @param field the given time field. | |
| 496 | + * @return the value for the given time field. | |
| 497 | + */ | |
| 498 | + protected final int internalGet(int field) | |
| 499 | + { | |
| 500 | + throw new NoSuchElementException(); | |
| 501 | + } | |
| 502 | + | |
| 503 | + /** | |
| 504 | + * Sets the time field with the given value. | |
| 505 | + * @param field the given time field. | |
| 506 | + * @param value the value to be set for the given time field. | |
| 507 | + */ | |
| 508 | + public final void set(int field, int value) | |
| 509 | + { | |
| 510 | + throw new NoSuchElementException(); | |
| 511 | + } | |
| 512 | + | |
| 513 | + /** | |
| 514 | + * Sets the values for the fields year, month, and date. | |
| 515 | + * @param year the value used to set the YEAR time field. | |
| 516 | + * @param month the value used to set the MONTH time field. | |
| 517 | + * Month value is 0-based. e.g., 0 for January. | |
| 518 | + * @param date the value used to set the DATE time field. | |
| 519 | + */ | |
| 520 | + public final void set(int year, int month, int date) | |
| 521 | + { | |
| 522 | + throw new NoSuchElementException(); | |
| 523 | + } | |
| 524 | + | |
| 525 | + /** | |
| 526 | + * Sets the values for the fields year, month, date, hour, and minute. | |
| 527 | + * @param year the value used to set the YEAR time field. | |
| 528 | + * @param month the value used to set the MONTH time field. | |
| 529 | + * Month value is 0-based. e.g., 0 for January. | |
| 530 | + * @param date the value used to set the DATE time field. | |
| 531 | + * @param hour the value used to set the HOUR_OF_DAY time field. | |
| 532 | + * @param minute the value used to set the MINUTE time field. | |
| 533 | + */ | |
| 534 | + public final void set(int year, int month, int date, int hour, int minute) | |
| 535 | + { | |
| 536 | + throw new NoSuchElementException(); | |
| 537 | + } | |
| 538 | + | |
| 539 | + /** | |
| 540 | + * Sets the values for the fields year, month, date, hour, minute, | |
| 541 | + * and second. | |
| 542 | + * @param year the value used to set the YEAR time field. | |
| 543 | + * @param month the value used to set the MONTH time field. | |
| 544 | + * Month value is 0-based. e.g., 0 for January. | |
| 545 | + * @param date the value used to set the DATE time field. | |
| 546 | + * @param hour the value used to set the HOUR_OF_DAY time field. | |
| 547 | + * @param minute the value used to set the MINUTE time field. | |
| 548 | + * @param second the value used to set the SECOND time field. | |
| 549 | + */ | |
| 550 | + public final void set(int year, int month, int date, int hour, int minute, | |
| 551 | + int second) | |
| 552 | + { | |
| 553 | + throw new NoSuchElementException(); | |
| 554 | + } | |
| 555 | + | |
| 556 | + /** | |
| 557 | + * Clears the values of all the time fields. | |
| 558 | + */ | |
| 559 | + public final void clear() | |
| 560 | + { | |
| 561 | + throw new NoSuchElementException(); | |
| 562 | + } | |
| 563 | + | |
| 564 | + /** | |
| 565 | + * Clears the value in the given time field. | |
| 566 | + * @param field the time field to be cleared. | |
| 567 | + */ | |
| 568 | + public final void clear(int field) | |
| 569 | + { | |
| 570 | + throw new NoSuchElementException(); | |
| 571 | + } | |
| 572 | + | |
| 573 | + /** | |
| 574 | + * Determines if the given time field has a value set. | |
| 575 | + * @return true if the given time field has a value set; false otherwise. | |
| 576 | + */ | |
| 577 | + public final boolean isSet(int field) | |
| 578 | + { | |
| 579 | + throw new NoSuchElementException(); | |
| 580 | + } | |
| 581 | + | |
| 582 | + /** | |
| 583 | + * Fills in any unset fields in the time field list. | |
| 584 | + */ | |
| 585 | + protected void complete() | |
| 586 | + { | |
| 587 | + throw new NoSuchElementException(); | |
| 588 | + } | |
| 589 | + | |
| 590 | + /** | |
| 591 | + * Compares the time field records. | |
| 592 | + * Equivalent to comparing result of conversion to UTC. | |
| 593 | + * @param when the Calendar to be compared with this Calendar. | |
| 594 | + * @return true if the current time of this Calendar is before | |
| 595 | + * the time of Calendar when; false otherwise. | |
| 596 | + */ | |
| 597 | + abstract public boolean before(Object when); | |
| 598 | + | |
| 599 | + /** | |
| 600 | + * Compares the time field records. | |
| 601 | + * Equivalent to comparing result of conversion to UTC. | |
| 602 | + * @param when the Calendar to be compared with this Calendar. | |
| 603 | + * @return true if the current time of this Calendar is after | |
| 604 | + * the time of Calendar when; false otherwise. | |
| 605 | + */ | |
| 606 | + abstract public boolean after(Object when); | |
| 607 | + | |
| 608 | + /** | |
| 609 | + * Date Arithmetic function. | |
| 610 | + * Adds the specified (signed) amount of time to the given time field, | |
| 611 | + * based on the calendar's rules. For example, to subtract 5 days from | |
| 612 | + * the current time of the calendar, you can achieve it by calling: | |
| 613 | + * <p>add(Calendar.DATE, -5). | |
| 614 | + * @param field the time field. | |
| 615 | + * @param amount the amount of date or time to be added to the field. | |
| 616 | + */ | |
| 617 | + abstract public void add(int field, int amount); | |
| 618 | + | |
| 619 | + /** | |
| 620 | + * Time Field Rolling function. | |
| 621 | + * Rolls (up/down) a single unit of time on the given time field. For | |
| 622 | + * example, to roll the current date up by one day, you can achieve it | |
| 623 | + * by calling: | |
| 624 | + * <p>roll(Calendar.DATE, true). | |
| 625 | + * When rolling on the year or Calendar.YEAR field, it will roll the year | |
| 626 | + * value in the range between 1 and the value returned by calling | |
| 627 | + * getMaximum(Calendar.YEAR). | |
| 628 | + * When rolling on the month or Calendar.MONTH field, other fields like | |
| 629 | + * date might conflict and, need to be changed. For instance, | |
| 630 | + * rolling the month on the date 01/31/96 will result in 03/02/96. | |
| 631 | + * When rolling on the hour-in-day or Calendar.HOUR_OF_DAY field, it will | |
| 632 | + * roll the hour value in the range between 0 and 23, which is zero-based. | |
| 633 | + * @param field the time field. | |
| 634 | + * @param up indicates if the value of the specified time field is to be | |
| 635 | + * rolled up or rolled down. Use true if rolling up, false otherwise. | |
| 636 | + */ | |
| 637 | + abstract public void roll(int field, boolean up); | |
| 638 | + | |
| 639 | + /** | |
| 640 | + * Sets the time zone with the given time zone value. | |
| 641 | + * @param value the given time zone. | |
| 642 | + */ | |
| 643 | + public void setTimeZone(TimeZone value) | |
| 644 | + { | |
| 645 | + throw new NoSuchElementException(); | |
| 646 | + } | |
| 647 | + | |
| 648 | + /** | |
| 649 | + * Gets the time zone. | |
| 650 | + * @return the time zone object associated with this calendar. | |
| 651 | + */ | |
| 652 | + public TimeZone getTimeZone() | |
| 653 | + { | |
| 654 | + throw new NoSuchElementException(); | |
| 655 | + } | |
| 656 | + | |
| 657 | + /** | |
| 658 | + * Specify whether or not date/time interpretation is to be lenient. With | |
| 659 | + * lenient interpretation, a date such as "February 942, 1996" will be | |
| 660 | + * treated as being equivalent to the 941st day after February 1, 1996. | |
| 661 | + * With strict interpretation, such dates will cause an exception to be | |
| 662 | + * thrown. | |
| 663 | + * | |
| 664 | + * @see java.text.DateFormat#setLenient | |
| 665 | + */ | |
| 666 | + public void setLenient(boolean lenient) | |
| 667 | + { | |
| 668 | + throw new NoSuchElementException(); | |
| 669 | + } | |
| 670 | + | |
| 671 | + /** | |
| 672 | + * Tell whether date/time interpretation is to be lenient. | |
| 673 | + */ | |
| 674 | + public boolean isLenient() | |
| 675 | + { | |
| 676 | + throw new NoSuchElementException(); | |
| 677 | + } | |
| 678 | + | |
| 679 | + /** | |
| 680 | + * Sets what the first day of the week is; e.g., Sunday in US, | |
| 681 | + * Monday in France. | |
| 682 | + * @param value the given first day of the week. | |
| 683 | + */ | |
| 684 | + public void setFirstDayOfWeek(int value) | |
| 685 | + { | |
| 686 | + throw new NoSuchElementException(); | |
| 687 | + } | |
| 688 | + | |
| 689 | + /** | |
| 690 | + * Gets what the first day of the week is; e.g., Sunday in US, | |
| 691 | + * Monday in France. | |
| 692 | + * @return the first day of the week. | |
| 693 | + */ | |
| 694 | + public int getFirstDayOfWeek() | |
| 695 | + { | |
| 696 | + throw new NoSuchElementException(); | |
| 697 | + } | |
| 698 | + | |
| 699 | + /** | |
| 700 | + * Sets what the minimal days required in the first week of the year are; | |
| 701 | + * For example, if the first week is defined as one that contains the first | |
| 702 | + * day of the first month of a year, call the method with value 1. If it | |
| 703 | + * must be a full week, use value 7. | |
| 704 | + * @param value the given minimal days required in the first week | |
| 705 | + * of the year. | |
| 706 | + */ | |
| 707 | + public void setMinimalDaysInFirstWeek(int value) | |
| 708 | + { | |
| 709 | + throw new NoSuchElementException(); | |
| 710 | + } | |
| 711 | + | |
| 712 | + /** | |
| 713 | + * Gets what the minimal days required in the first week of the year are; | |
| 714 | + * e.g., if the first week is defined as one that contains the first day | |
| 715 | + * of the first month of a year, getMinimalDaysInFirstWeek returns 1. If | |
| 716 | + * the minimal days required must be a full week, getMinimalDaysInFirstWeek | |
| 717 | + * returns 7. | |
| 718 | + * @return the minimal days required in the first week of the year. | |
| 719 | + */ | |
| 720 | + public int getMinimalDaysInFirstWeek() | |
| 721 | + { | |
| 722 | + throw new NoSuchElementException(); | |
| 723 | + } | |
| 724 | + | |
| 725 | + /** | |
| 726 | + * Gets the minimum value for the given time field. | |
| 727 | + * e.g., for Gregorian DAY_OF_MONTH, 1. | |
| 728 | + * @param field the given time field. | |
| 729 | + * @return the minimum value for the given time field. | |
| 730 | + */ | |
| 731 | + abstract public int getMinimum(int field); | |
| 732 | + | |
| 733 | + /** | |
| 734 | + * Gets the maximum value for the given time field. | |
| 735 | + * e.g. for Gregorian DAY_OF_MONTH, 31. | |
| 736 | + * @param field the given time field. | |
| 737 | + * @return the maximum value for the given time field. | |
| 738 | + */ | |
| 739 | + abstract public int getMaximum(int field); | |
| 740 | + | |
| 741 | + /** | |
| 742 | + * Gets the highest minimum value for the given field if varies. | |
| 743 | + * Otherwise same as getMinimum(). For Gregorian, no difference. | |
| 744 | + * @param field the given time field. | |
| 745 | + * @return the highest minimum value for the given time field. | |
| 746 | + */ | |
| 747 | + abstract public int getGreatestMinimum(int field); | |
| 748 | + | |
| 749 | + /** | |
| 750 | + * Gets the lowest maximum value for the given field if varies. | |
| 751 | + * Otherwise same as getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28. | |
| 752 | + * @param field the given time field. | |
| 753 | + * @return the lowest maximum value for the given time field. | |
| 754 | + */ | |
| 755 | + abstract public int getLeastMaximum(int field); | |
| 756 | + | |
| 757 | + /** | |
| 758 | + * Overrides Cloneable | |
| 759 | + */ | |
| 760 | + public Object clone() | |
| 761 | + { | |
| 762 | + throw new NoSuchElementException(); | |
| 763 | + } | |
| 764 | + | |
| 765 | + | |
| 766 | + // =======================privates=============================== | |
| 767 | + | |
| 768 | + /** | |
| 769 | + * Both firstDayOfWeek and minimalDaysInFirstWeek are locale-dependent. | |
| 770 | + * They are used to figure out the week count for a specific date for | |
| 771 | + * a given locale. These must be set when a Calendar is constructed. | |
| 772 | + * @param desiredLocale the given locale. | |
| 773 | + */ | |
| 774 | + private void setWeekCountData(Locale desiredLocale) | |
| 775 | + { | |
| 776 | + throw new NoSuchElementException(); | |
| 777 | + } | |
| 778 | + | |
| 779 | + private void readObject(ObjectInputStream s) { | |
| 780 | + throw new NoSuchElementException(); | |
| 781 | + } | |
| 782 | +} | |
Empty file added.
| @@ -0,0 +1,180 @@ | ||
| 1 | +implement Date_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | +include "daytime.m"; | |
| 27 | + localtime : ref Daytime->Tm; | |
| 28 | + gmttime : ref Daytime->Tm; | |
| 29 | + daytime : Daytime; | |
| 30 | + sys : import jni; | |
| 31 | + FALSE : import jni; | |
| 32 | + TRUE : import jni; | |
| 33 | +month := array[] of { | |
| 34 | + "Jan", "Feb", "Mar", "Apr", "May", "Jun", | |
| 35 | + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" | |
| 36 | +}; | |
| 37 | + | |
| 38 | +#<< | |
| 39 | + | |
| 40 | +include "Date_L.m"; | |
| 41 | + | |
| 42 | +#>> extra post includes here | |
| 43 | + | |
| 44 | +#<< | |
| 45 | + | |
| 46 | +init( jni_p : JNI ) | |
| 47 | +{ | |
| 48 | + # save java native inteface mod instance | |
| 49 | + jni = jni_p; | |
| 50 | + #>>extra initialization here | |
| 51 | + sys = jni->sys; | |
| 52 | + daytime = load Daytime Daytime->PATH; | |
| 53 | + if(daytime == nil) | |
| 54 | + jni->InitError( sys->sprint( "java.util.Date: could not load %s: %r", Daytime->PATH ) ); | |
| 55 | + #<< | |
| 56 | +} | |
| 57 | + | |
| 58 | +toString_rString( this : ref Date_obj) : JString | |
| 59 | +{#>> | |
| 60 | + if (this.expanded != byte TRUE) | |
| 61 | + expand_V(this); | |
| 62 | + if (this.expanded != byte TRUE) | |
| 63 | + jni->ThrowException("java.lang.IllegalArgumentException", "could not expand time"); | |
| 64 | + s := daytime->text(localtime); | |
| 65 | + return (jni->NewString( s)); | |
| 66 | +}#<< | |
| 67 | + | |
| 68 | +toLocaleString_rString( this : ref Date_obj) : JString | |
| 69 | +{#>> | |
| 70 | + s : string; | |
| 71 | + # | |
| 72 | + # put the date in the following format | |
| 73 | + # 09-Sep-97 9:15:24 PM | |
| 74 | + # | |
| 75 | + if (this.expanded != byte TRUE) | |
| 76 | + expand_V(this); | |
| 77 | + if (this.expanded != byte TRUE) | |
| 78 | + jni->ThrowException("java.lang.IllegalArgumentException", "could not expand time"); | |
| 79 | + | |
| 80 | + if ((int this.tm_hour) >= 12) { | |
| 81 | + s = sys->sprint( "%.2d-%s-%.2d %d:%.2d:%.2d PM", | |
| 82 | + int this.tm_mday, | |
| 83 | + month[int this.tm_mon], | |
| 84 | + this.tm_year, | |
| 85 | + (int this.tm_hour) - 12, | |
| 86 | + int this.tm_min, | |
| 87 | + int this.tm_sec); | |
| 88 | + } else { | |
| 89 | + s = sys->sprint( "%.2d-%s-%.2d %d:%.2d:%.2d AM", | |
| 90 | + int this.tm_mday, | |
| 91 | + month[int this.tm_mon], | |
| 92 | + this.tm_year, | |
| 93 | + int this.tm_hour, | |
| 94 | + int this.tm_min, | |
| 95 | + int this.tm_sec); | |
| 96 | + } | |
| 97 | + return (jni->NewString( s)); | |
| 98 | +}#<< | |
| 99 | + | |
| 100 | +toGMTString_rString( this : ref Date_obj) : JString | |
| 101 | +{#>> | |
| 102 | + s : string; | |
| 103 | + if (this.valueValid != byte TRUE) | |
| 104 | + computeValue_V( this); | |
| 105 | + if (this.valueValid != byte TRUE) | |
| 106 | + jni->ThrowException("java.lang.IllegalArgumentException", "could not compute time"); | |
| 107 | + t := (big this.value) / big 1000; | |
| 108 | + #10 Sep 1997 02:15:24 GMT | |
| 109 | + s = sys->sprint( "%.2d %s %d %.2d:%.2d:%.2d GMT", | |
| 110 | + int this.tm_mday, | |
| 111 | + month[int this.tm_mon], | |
| 112 | + this.tm_year + 1900, | |
| 113 | + int this.tm_hour, | |
| 114 | + int this.tm_min, | |
| 115 | + int this.tm_sec); | |
| 116 | + | |
| 117 | + gmttime = daytime->gmt(int t); | |
| 118 | + return (jni->NewString( s)); | |
| 119 | +}#<< | |
| 120 | + | |
| 121 | +expand_V( this : ref Date_obj) | |
| 122 | +{#>> | |
| 123 | + # | |
| 124 | + # this routine assumes there is a valid date stored | |
| 125 | + # in this.value. If not, return error. | |
| 126 | + # | |
| 127 | + if (this.value <= (big 0)) { | |
| 128 | + this.expanded = byte FALSE; | |
| 129 | + this.tm_millis = 0; | |
| 130 | + this.tm_sec = byte 0; | |
| 131 | + this.tm_min = byte 0; | |
| 132 | + this.tm_hour = byte 0; | |
| 133 | + this.tm_mday = byte 0; | |
| 134 | + this.tm_mon = byte 0; | |
| 135 | + this.tm_wday = byte 0; | |
| 136 | + this.tm_yday = 0; | |
| 137 | + this.tm_year = 0; | |
| 138 | + this.tm_isdst = 0; | |
| 139 | + return; | |
| 140 | + } | |
| 141 | + t := (big this.value) / big 1000; | |
| 142 | + localtime = daytime->local(int t); | |
| 143 | + # | |
| 144 | + # set the following to 0 since java code is not using them. | |
| 145 | + # | |
| 146 | + this.tm_millis = 0; | |
| 147 | + this.tm_isdst = 0; # flag for alternate daylight savings time | |
| 148 | + # | |
| 149 | + # these values come from calculations done by local(). | |
| 150 | + # | |
| 151 | + this.tm_sec = byte localtime.sec; | |
| 152 | + this.tm_min = byte localtime.min; | |
| 153 | + this.tm_hour = byte localtime.hour; | |
| 154 | + this.tm_mday = byte localtime.mday; # day of the month - [1, 31] | |
| 155 | + this.tm_mon = byte localtime.mon; # months since January - [0, 11] | |
| 156 | + this.tm_wday = byte localtime.wday; # days since Sunday - [0, 6] | |
| 157 | + this.tm_yday = localtime.yday; # days since January 1 - [0, 365] | |
| 158 | + this.tm_year = localtime.year; # years since 1900 | |
| 159 | + this.expanded = byte TRUE; | |
| 160 | +}#<< | |
| 161 | + | |
| 162 | +computeValue_V( this : ref Date_obj) | |
| 163 | +{#>> | |
| 164 | + now := daytime->now(); | |
| 165 | + localtime = daytime->local(now); | |
| 166 | + localtime.sec = int this.tm_sec; | |
| 167 | + localtime.min = int this.tm_min; | |
| 168 | + localtime.hour = int this.tm_hour; | |
| 169 | + localtime.mday = int this.tm_mday; | |
| 170 | + localtime.mon = int this.tm_mon; | |
| 171 | + localtime.year = int this.tm_year; | |
| 172 | + localtime.wday = int this.tm_wday; | |
| 173 | + localtime.yday = int this.tm_yday; | |
| 174 | + | |
| 175 | + t := daytime->tm2epoch(localtime); | |
| 176 | + this.value = (big t) * big 1000; | |
| 177 | + this.valueValid = byte TRUE; | |
| 178 | +}#<< | |
| 179 | + | |
| 180 | + | |
| @@ -0,0 +1,30 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +Date_L : module | |
| 4 | +{ | |
| 5 | + Date_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + value : big; | |
| 9 | + valueValid : byte; | |
| 10 | + expanded : byte; | |
| 11 | + tm_millis : int; | |
| 12 | + tm_sec : byte; | |
| 13 | + tm_min : byte; | |
| 14 | + tm_hour : byte; | |
| 15 | + tm_mday : byte; | |
| 16 | + tm_mon : byte; | |
| 17 | + tm_wday : byte; | |
| 18 | + tm_yday : int; | |
| 19 | + tm_year : int; | |
| 20 | + tm_isdst : int; | |
| 21 | + }; | |
| 22 | + | |
| 23 | + init : fn( jni_p : JNI ); | |
| 24 | + toString_rString : fn( this : ref Date_obj) : JString; | |
| 25 | + toLocaleString_rString : fn( this : ref Date_obj) : JString; | |
| 26 | + toGMTString_rString : fn( this : ref Date_obj) : JString; | |
| 27 | + expand_V : fn( this : ref Date_obj); | |
| 28 | + computeValue_V : fn( this : ref Date_obj); | |
| 29 | + | |
| 30 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,557 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)GregorianCalendar.java 1.20 97/03/09 | |
| 3 | + * | |
| 4 | + * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved | |
| 5 | + * (C) Copyright IBM Corp. 1996 - All Rights Reserved | |
| 6 | + * | |
| 7 | + * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 8 | + * | |
| 9 | + * The original version of this source code and documentation is copyrighted | |
| 10 | + * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These | |
| 11 | + * materials are provided under terms of a License Agreement between Taligent | |
| 12 | + * and Sun. This technology is protected by multiple US and International | |
| 13 | + * patents. This notice and attribution to Taligent may not be removed. | |
| 14 | + * Taligent is a registered trademark of Taligent, Inc. | |
| 15 | + * | |
| 16 | + * Permission to use, copy, modify, and distribute this software | |
| 17 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 18 | + * fee is hereby granted provided that this copyright notice | |
| 19 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 20 | + * for further important copyright and licensing information. | |
| 21 | + * | |
| 22 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 23 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 24 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 25 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 26 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 27 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | +package java.util; | |
| 32 | + | |
| 33 | +import java.io.ObjectInputStream; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * <code>GregorianCalendar</code> is a concrete subclass of | |
| 37 | + * <a href="java.util.Calendar.html"><code>Calendar</code></a> | |
| 38 | + * and provides the standard calendar used by most of the world. | |
| 39 | + * | |
| 40 | + * <p> | |
| 41 | + * The standard (Gregorian) calendar has 2 eras, BC and AD. | |
| 42 | + * | |
| 43 | + * <p> | |
| 44 | + * This implementation handles a single discontinuity, which corresponds | |
| 45 | + * by default to the date the Gregorian calendar was instituted (October 15, | |
| 46 | + * 1582 in some countries, later in others). This cutover date may be changed | |
| 47 | + * by the caller. | |
| 48 | + * | |
| 49 | + * <p> | |
| 50 | + * Prior to the institution of the Gregorian calendar, New Year's Day was | |
| 51 | + * March 25. To avoid confusion, this calendar always uses January 1. A manual | |
| 52 | + * adjustment may be made if desired for dates that are prior to the Gregorian | |
| 53 | + * changeover and which fall between January 1 and March 24. | |
| 54 | + * | |
| 55 | + * <p> | |
| 56 | + * <strong>Example:</strong> | |
| 57 | + * <blockquote> | |
| 58 | + * <pre> | |
| 59 | + * // get the supported ids for GMT-08:00 (Pacific Standard Time) | |
| 60 | + * String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); | |
| 61 | + * // if no ids were returned, something is wrong. get out. | |
| 62 | + * if (ids.length == 0) | |
| 63 | + * System.exit(0); | |
| 64 | + * | |
| 65 | + * // begin output | |
| 66 | + * System.out.println("Current Time"); | |
| 67 | + * | |
| 68 | + * // create a Pacific Standard Time time zone | |
| 69 | + * SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); | |
| 70 | + * | |
| 71 | + * // set up rules for daylight savings time | |
| 72 | + * pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); | |
| 73 | + * pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); | |
| 74 | + * | |
| 75 | + * // create a GregorianCalendar with the Pacific Daylight time zone | |
| 76 | + * // and the current date and time | |
| 77 | + * Calendar calendar = new GregorianCalendar(pdt); | |
| 78 | + * Date trialTime = new Date(); | |
| 79 | + * calendar.setTime(trialTime); | |
| 80 | + * | |
| 81 | + * // print out a bunch of interesting things | |
| 82 | + * System.out.println("ERA: " + calendar.get(Calendar.ERA)); | |
| 83 | + * System.out.println("YEAR: " + calendar.get(Calendar.YEAR)); | |
| 84 | + * System.out.println("MONTH: " + calendar.get(Calendar.MONTH)); | |
| 85 | + * System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR)); | |
| 86 | + * System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH)); | |
| 87 | + * System.out.println("DATE: " + calendar.get(Calendar.DATE)); | |
| 88 | + * System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH)); | |
| 89 | + * System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR)); | |
| 90 | + * System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK)); | |
| 91 | + * System.out.println("DAY_OF_WEEK_IN_MONTH: " | |
| 92 | + * + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH)); | |
| 93 | + * System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM)); | |
| 94 | + * System.out.println("HOUR: " + calendar.get(Calendar.HOUR)); | |
| 95 | + * System.out.println("HOUR_OF_DAY: " + calendar.get(Calendar.HOUR_OF_DAY)); | |
| 96 | + * System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE)); | |
| 97 | + * System.out.println("SECOND: " + calendar.get(Calendar.SECOND)); | |
| 98 | + * System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND)); | |
| 99 | + * System.out.println("ZONE_OFFSET: " | |
| 100 | + * + (calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000))); | |
| 101 | + * System.out.println("DST_OFFSET: " | |
| 102 | + * + (calendar.get(Calendar.DST_OFFSET)/(60*60*1000))); | |
| 103 | + | |
| 104 | + * System.out.println("Current Time, with hour reset to 3"); | |
| 105 | + * calendar.clear(Calendar.HOUR_OF_DAY); // so doesn't override | |
| 106 | + * calendar.set(Calendar.HOUR, 3); | |
| 107 | + * System.out.println("ERA: " + calendar.get(Calendar.ERA)); | |
| 108 | + * System.out.println("YEAR: " + calendar.get(Calendar.YEAR)); | |
| 109 | + * System.out.println("MONTH: " + calendar.get(Calendar.MONTH)); | |
| 110 | + * System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR)); | |
| 111 | + * System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH)); | |
| 112 | + * System.out.println("DATE: " + calendar.get(Calendar.DATE)); | |
| 113 | + * System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH)); | |
| 114 | + * System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR)); | |
| 115 | + * System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK)); | |
| 116 | + * System.out.println("DAY_OF_WEEK_IN_MONTH: " | |
| 117 | + * + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH)); | |
| 118 | + * System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM)); | |
| 119 | + * System.out.println("HOUR: " + calendar.get(Calendar.HOUR)); | |
| 120 | + * System.out.println("HOUR_OF_DAY: " + calendar.get(Calendar.HOUR_OF_DAY)); | |
| 121 | + * System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE)); | |
| 122 | + * System.out.println("SECOND: " + calendar.get(Calendar.SECOND)); | |
| 123 | + * System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND)); | |
| 124 | + * System.out.println("ZONE_OFFSET: " | |
| 125 | + * + (calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000))); // in hours | |
| 126 | + * System.out.println("DST_OFFSET: " | |
| 127 | + * + (calendar.get(Calendar.DST_OFFSET)/(60*60*1000))); // in hours | |
| 128 | + * </pre> | |
| 129 | + * </blockquote> | |
| 130 | + * | |
| 131 | + * @see Calendar | |
| 132 | + * @see TimeZone | |
| 133 | + * @version 1.20 03/09/97 | |
| 134 | + * @author David Goldsmith, Mark Davis, Chen-Lieh Huang | |
| 135 | + */ | |
| 136 | +public class GregorianCalendar extends Calendar { | |
| 137 | + | |
| 138 | + // Internal notes: | |
| 139 | + // This algorithm is based on the one presented on pp. 10-12 of | |
| 140 | + // "Numerical Recipes in C", William H. Press, et. al., Cambridge | |
| 141 | + // University Press 1988, ISBN 0-521-35465-X. | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * Useful constant for GregorianCalendar. | |
| 145 | + */ | |
| 146 | + public static final int BC = 0; | |
| 147 | + /** | |
| 148 | + * Useful constant for GregorianCalendar. | |
| 149 | + */ | |
| 150 | + public static final int AD = 1; | |
| 151 | + | |
| 152 | + // Note that the Julian date used here is not a true Julian date, since | |
| 153 | + // it is measured from midnight, not noon. | |
| 154 | + | |
| 155 | + private static final long julianDayOffset = 2440588; | |
| 156 | + private static final int millisPerDay = 24 * 60 * 60 * 1000; | |
| 157 | + private static final int numDays[] | |
| 158 | + = {0,31,59,90,120,151,181,212,243,273,304,334}; // 0-based, for day-in-year | |
| 159 | + private static final int leapNumDays[] | |
| 160 | + = {0,31,60,91,121,152,182,213,244,274,305,335}; // 0-based, for day-in-year | |
| 161 | + private static final int maxDaysInMonth[] | |
| 162 | + = {31,28,31,30,31,30,31,31,30,31,30,31}; // 0-based | |
| 163 | + | |
| 164 | + // This is measured from the standard epoch, not in Julian Days. | |
| 165 | + // Default is 00:00:00 local time, October 15, 1582. | |
| 166 | + private long gregorianCutover = -12219292800000L; | |
| 167 | + | |
| 168 | + /** | |
| 169 | + * Converts time as milliseconds to Julian date. | |
| 170 | + * @param millis the given milliseconds. | |
| 171 | + * @return the Julian date number. | |
| 172 | + */ | |
| 173 | + private static final long millisToJulianDay(long millis) | |
| 174 | + { | |
| 175 | + throw new NoSuchElementException(); | |
| 176 | + } | |
| 177 | + | |
| 178 | + /** | |
| 179 | + * Converts Julian date to time as milliseconds. | |
| 180 | + * @param julian the given Julian date number. | |
| 181 | + * @return time as milliseconds. | |
| 182 | + */ | |
| 183 | + private static final long julianDayToMillis(long julian) | |
| 184 | + { | |
| 185 | + throw new NoSuchElementException(); | |
| 186 | + } | |
| 187 | + | |
| 188 | + /** | |
| 189 | + * Constructs a default GregorianCalendar using the current time | |
| 190 | + * in the default time zone with the default locale. | |
| 191 | + */ | |
| 192 | + public GregorianCalendar() | |
| 193 | + { | |
| 194 | + throw new NoSuchElementException(); | |
| 195 | + } | |
| 196 | + | |
| 197 | + /** | |
| 198 | + * Constructs a GregorianCalendar based on the current time | |
| 199 | + * in the given time zone with the default locale. | |
| 200 | + * @param zone the given time zone. | |
| 201 | + */ | |
| 202 | + public GregorianCalendar(TimeZone zone) | |
| 203 | + { | |
| 204 | + throw new NoSuchElementException(); | |
| 205 | + } | |
| 206 | + | |
| 207 | + /** | |
| 208 | + * Constructs a GregorianCalendar based on the current time | |
| 209 | + * in the default time zone with the given locale. | |
| 210 | + * @param aLocale the given locale. | |
| 211 | + */ | |
| 212 | + public GregorianCalendar(Locale aLocale) | |
| 213 | + { | |
| 214 | + throw new NoSuchElementException(); | |
| 215 | + } | |
| 216 | + | |
| 217 | + /** | |
| 218 | + * Constructs a GregorianCalendar based on the current time | |
| 219 | + * in the given time zone with the given locale. | |
| 220 | + * @param zone the given time zone. | |
| 221 | + * @param aLocale the given locale. | |
| 222 | + */ | |
| 223 | + public GregorianCalendar(TimeZone zone, Locale aLocale) | |
| 224 | + { | |
| 225 | + throw new NoSuchElementException(); | |
| 226 | + } | |
| 227 | + | |
| 228 | + /** | |
| 229 | + * Constructs a GregorianCalendar with the given date set | |
| 230 | + * in the default time zone with the default locale. | |
| 231 | + * @param year the value used to set the YEAR time field in the calendar. | |
| 232 | + * @param month the value used to set the MONTH time field in the calendar. | |
| 233 | + * Month value is 0-based. e.g., 0 for January. | |
| 234 | + * @param date the value used to set the DATE time field in the calendar. | |
| 235 | + */ | |
| 236 | + public GregorianCalendar(int year, int month, int date) | |
| 237 | + { | |
| 238 | + throw new NoSuchElementException(); | |
| 239 | + } | |
| 240 | + | |
| 241 | + /** | |
| 242 | + * Constructs a GregorianCalendar with the given date | |
| 243 | + * and time set for the default time zone with the default locale. | |
| 244 | + * @param year the value used to set the YEAR time field in the calendar. | |
| 245 | + * @param month the value used to set the MONTH time field in the calendar. | |
| 246 | + * Month value is 0-based. e.g., 0 for January. | |
| 247 | + * @param date the value used to set the DATE time field in the calendar. | |
| 248 | + * @param hour the value used to set the HOUR_OF_DAY time field | |
| 249 | + * in the calendar. | |
| 250 | + * @param minute the value used to set the MINUTE time field | |
| 251 | + * in the calendar. | |
| 252 | + */ | |
| 253 | + public GregorianCalendar(int year, int month, int date, int hour, | |
| 254 | + int minute) | |
| 255 | + { | |
| 256 | + throw new NoSuchElementException(); | |
| 257 | + } | |
| 258 | + | |
| 259 | + /** | |
| 260 | + * Constructs a GregorianCalendar with the given date | |
| 261 | + * and time set for the default time zone with the default locale. | |
| 262 | + * @param year the value used to set the YEAR time field in the calendar. | |
| 263 | + * @param month the value used to set the MONTH time field in the calendar. | |
| 264 | + * Month value is 0-based. e.g., 0 for January. | |
| 265 | + * @param date the value used to set the DATE time field in the calendar. | |
| 266 | + * @param hour the value used to set the HOUR_OF_DAY time field | |
| 267 | + * in the calendar. | |
| 268 | + * @param minute the value used to set the MINUTE time field | |
| 269 | + * in the calendar. | |
| 270 | + * @param second the value used to set the SECOND time field | |
| 271 | + * in the calendar. | |
| 272 | + */ | |
| 273 | + public GregorianCalendar(int year, int month, int date, int hour, | |
| 274 | + int minute, int second) | |
| 275 | + { | |
| 276 | + throw new NoSuchElementException(); | |
| 277 | + } | |
| 278 | + | |
| 279 | + /** | |
| 280 | + * Sets the GregorianCalendar change date. This is the point when the | |
| 281 | + * switch from Julian dates to Gregorian dates occurred. Default is | |
| 282 | + * 00:00:00 local time, October 15, 1582. Previous to this time and date | |
| 283 | + * will be Julian dates. | |
| 284 | + * | |
| 285 | + * @param date the given Gregorian cutover date. | |
| 286 | + */ | |
| 287 | + public void setGregorianChange(Date date) | |
| 288 | + { | |
| 289 | + throw new NoSuchElementException(); | |
| 290 | + } | |
| 291 | + | |
| 292 | + /** | |
| 293 | + * Gets the Gregorian Calendar change date. This is the point when the | |
| 294 | + * switch from Julian dates to Gregorian dates occurred. Default is | |
| 295 | + * 00:00:00 local time, October 15, 1582. Previous to | |
| 296 | + * this time and date will be Julian dates. | |
| 297 | + * @return the Gregorian cutover time for this calendar. | |
| 298 | + */ | |
| 299 | + public final Date getGregorianChange() | |
| 300 | + { | |
| 301 | + throw new NoSuchElementException(); | |
| 302 | + } | |
| 303 | + | |
| 304 | + // Converts the time field list to the time as milliseconds. | |
| 305 | + private final void timeToFields(long theTime) | |
| 306 | + { | |
| 307 | + throw new NoSuchElementException(); | |
| 308 | + } | |
| 309 | + | |
| 310 | + | |
| 311 | + /** | |
| 312 | + * @param date day-of-year or day-of-month. Month is zero based. | |
| 313 | + * @param day day-of-week for date. Zero based. | |
| 314 | + * @param firstDatesDay the day-of-week for the first day of the year | |
| 315 | + * or month. | |
| 316 | + * @param firstDay the first day of the week for the calendar. | |
| 317 | + * e.g. Sunday for US. | |
| 318 | + * @param minimalDaysInFirstWeek the minimal number of days in the | |
| 319 | + * week to qualify as the first week; otherwise partial week belongs | |
| 320 | + * to last (year/month). | |
| 321 | + * <note> weekCount is the number of weeks in the (year/month) for the | |
| 322 | + * date. If zero, belongs to last (year/month). You MUST add the date to | |
| 323 | + * the last day of the previous (year/month), and call this method again! | |
| 324 | + * @return week number, one-based. | |
| 325 | + */ | |
| 326 | + private static int weekNumber(int date, int day, int firstDatesDay, | |
| 327 | + int firstDay, int minimalDaysInFirstWeek) | |
| 328 | + { | |
| 329 | + throw new NoSuchElementException(); | |
| 330 | + } | |
| 331 | + | |
| 332 | + | |
| 333 | + // XXX Currently this method has a bug, and it is not being used. | |
| 334 | + private static int dateFrom(int weekNumber, int day, int firstDatesDay, | |
| 335 | + int firstDay, int minimalDaysInFirstWeek) | |
| 336 | + { | |
| 337 | + throw new NoSuchElementException(); | |
| 338 | + } | |
| 339 | + | |
| 340 | + | |
| 341 | + /** | |
| 342 | + * Determines if the given year is a leap year. Returns true if the | |
| 343 | + * given year is a leap year. | |
| 344 | + * @param year the given year. | |
| 345 | + * @return true if the given year is a leap year; false otherwise. | |
| 346 | + */ | |
| 347 | + public boolean isLeapYear(int year) | |
| 348 | + { | |
| 349 | + throw new NoSuchElementException(); | |
| 350 | + } | |
| 351 | + | |
| 352 | + /** | |
| 353 | + * Overrides Calendar | |
| 354 | + * Converts UTC as milliseconds to time field values. | |
| 355 | + */ | |
| 356 | + protected void computeFields() | |
| 357 | + { | |
| 358 | + throw new NoSuchElementException(); | |
| 359 | + } | |
| 360 | + | |
| 361 | + /** | |
| 362 | + * Validates the values of the set time fields. | |
| 363 | + */ | |
| 364 | + private boolean validateFields() | |
| 365 | + { | |
| 366 | + throw new NoSuchElementException(); | |
| 367 | + } | |
| 368 | + | |
| 369 | + /** | |
| 370 | + * Validates the value of the given time field. | |
| 371 | + */ | |
| 372 | + private boolean boundsCheck(int value, int field) | |
| 373 | + { | |
| 374 | + throw new NoSuchElementException(); | |
| 375 | + } | |
| 376 | + | |
| 377 | + /** | |
| 378 | + * Overrides Calendar | |
| 379 | + * Converts time field values to UTC as milliseconds. | |
| 380 | + * @exception IllegalArgumentException if an unknown field is given. | |
| 381 | + */ | |
| 382 | + protected void computeTime() | |
| 383 | + { | |
| 384 | + throw new NoSuchElementException(); | |
| 385 | + } | |
| 386 | + | |
| 387 | + /** | |
| 388 | + * Overrides Cloneable | |
| 389 | + */ | |
| 390 | + public Object clone() | |
| 391 | + { | |
| 392 | + throw new NoSuchElementException(); | |
| 393 | + } | |
| 394 | + | |
| 395 | + /** | |
| 396 | + * Override hashCode. | |
| 397 | + * Generates the hash code for the GregorianCalendar object | |
| 398 | + */ | |
| 399 | + public synchronized int hashCode() | |
| 400 | + { | |
| 401 | + throw new NoSuchElementException(); | |
| 402 | + } | |
| 403 | + | |
| 404 | + /** | |
| 405 | + * Overrides Calendar | |
| 406 | + * Compares the time field records. | |
| 407 | + * Equivalent to comparing result of conversion to UTC. | |
| 408 | + * Please see Calendar.equals for descriptions on parameters and | |
| 409 | + * the return value. | |
| 410 | + */ | |
| 411 | + public boolean equals(Object obj) | |
| 412 | + { | |
| 413 | + throw new NoSuchElementException(); | |
| 414 | + } | |
| 415 | + | |
| 416 | + /** | |
| 417 | + * Overrides Calendar | |
| 418 | + * Compares the time field records. | |
| 419 | + * Equivalent to comparing result of conversion to UTC. | |
| 420 | + * Please see Calendar.before for descriptions on parameters and | |
| 421 | + * the return value. | |
| 422 | + */ | |
| 423 | + public boolean before(Object when) | |
| 424 | + { | |
| 425 | + throw new NoSuchElementException(); | |
| 426 | + } | |
| 427 | + | |
| 428 | + /** | |
| 429 | + * Overrides Calendar | |
| 430 | + * Compares the time field records. | |
| 431 | + * Equivalent to comparing result of conversion to UTC. | |
| 432 | + * Please see Calendar.after for descriptions on parameters and | |
| 433 | + * the return value. | |
| 434 | + */ | |
| 435 | + public boolean after(Object when) | |
| 436 | + { | |
| 437 | + throw new NoSuchElementException(); | |
| 438 | + } | |
| 439 | + | |
| 440 | + /** | |
| 441 | + * Overrides Calendar | |
| 442 | + * Date Arithmetic function. | |
| 443 | + * Adds the specified (signed) amount of time to the given time field, | |
| 444 | + * based on the calendar's rules. | |
| 445 | + * @param field the time field. | |
| 446 | + * @param amount the amount of date or time to be added to the field. | |
| 447 | + * @exception IllegalArgumentException if an unknown field is given. | |
| 448 | + */ | |
| 449 | + public void add(int field, int amount) | |
| 450 | + { | |
| 451 | + throw new NoSuchElementException(); | |
| 452 | + } | |
| 453 | + | |
| 454 | + | |
| 455 | + /** | |
| 456 | + * Overrides Calendar | |
| 457 | + * Time Field Rolling function. | |
| 458 | + * Rolls (up/down) a single unit of time on the given time field. | |
| 459 | + * @param field the time field. | |
| 460 | + * @param up Indicates if rolling up or rolling down the field value. | |
| 461 | + * @exception IllegalArgumentException if an unknown field value is given. | |
| 462 | + */ | |
| 463 | + public void roll(int field, boolean up) | |
| 464 | + { | |
| 465 | + throw new NoSuchElementException(); | |
| 466 | + } | |
| 467 | + | |
| 468 | + | |
| 469 | + // Roll the time field value down by 1. | |
| 470 | + private void rollDown(int field) | |
| 471 | + { | |
| 472 | + throw new NoSuchElementException(); | |
| 473 | + } | |
| 474 | + | |
| 475 | + | |
| 476 | + /** | |
| 477 | + * <pre> | |
| 478 | + * Field names Minimum Greatest Minimum Least Maximum Maximum | |
| 479 | + * ----------- ------- ---------------- ------------- ------- | |
| 480 | + * ERA 0 0 1 1 | |
| 481 | + * YEAR 1 1 5,000,000 5,000,000 | |
| 482 | + * MONTH 0 0 11 11 | |
| 483 | + * WEEK_OF_YEAR 1 1 53 54 | |
| 484 | + * WEEK_OF_MONTH 1 1 4 6 | |
| 485 | + * DAY_OF_MONTH 1 1 28 31 | |
| 486 | + * DAY_OF_YEAR 1 1 365 366 | |
| 487 | + * DAY_OF_WEEK 1 1 7 7 | |
| 488 | + * DAY_OF_WEEK_IN_MONTH -1 -1 4 6 | |
| 489 | + * AM_PM 0 0 1 1 | |
| 490 | + * HOUR 0 0 11 12 | |
| 491 | + * HOUR_OF_DAY 0 0 23 23 | |
| 492 | + * MINUTE 0 0 59 59 | |
| 493 | + * SECOND 0 0 59 59 | |
| 494 | + * MILLISECOND 0 0 999 999 | |
| 495 | + * ZONE_OFFSET -12*60*60*1000 -12*60*60*1000 12*60*60*1000 12*60*60*1000 | |
| 496 | + * DST_OFFSET 0 0 1*60*60*1000 1*60*60*1000 | |
| 497 | + * </pre> | |
| 498 | + */ | |
| 499 | + private static final int MinValues[] | |
| 500 | + = {0,1,0,1,1,1,1,1,-1,0,0,0,0,0,0,-12*60*60*1000,0}; | |
| 501 | + private static final int GreatestMinValues[] | |
| 502 | + = {0,1,0,1,1,1,1,1,-1,0,0,0,0,0,0,-12*60*60*1000,0};// same as MinValues | |
| 503 | + private static final int LeastMaxValues[] | |
| 504 | + = {1,5000000,11,53,4,28,365,7,4,1,11,23,59,59,999, | |
| 505 | + 12*60*60*1000,1*60*60*1000}; | |
| 506 | + private static final int MaxValues[] | |
| 507 | + = {1,5000000,11,54,6,31,366,7,6,1,12,23,59,59,999, | |
| 508 | + 12*60*60*1000,1*60*60*1000}; | |
| 509 | + | |
| 510 | + /** | |
| 511 | + * Returns minimum value for the given field. | |
| 512 | + * e.g. for Gregorian DAY_OF_MONTH, 1 | |
| 513 | + * Please see Calendar.getMinimum for descriptions on parameters and | |
| 514 | + * the return value. | |
| 515 | + */ | |
| 516 | + public int getMinimum(int field) | |
| 517 | + { | |
| 518 | + throw new NoSuchElementException(); | |
| 519 | + } | |
| 520 | + | |
| 521 | + /** | |
| 522 | + * Returns maximum value for the given field. | |
| 523 | + * e.g. for Gregorian DAY_OF_MONTH, 31 | |
| 524 | + * Please see Calendar.getMaximum for descriptions on parameters and | |
| 525 | + * the return value. | |
| 526 | + */ | |
| 527 | + public int getMaximum(int field) | |
| 528 | + { | |
| 529 | + throw new NoSuchElementException(); | |
| 530 | + } | |
| 531 | + | |
| 532 | + /** | |
| 533 | + * Returns highest minimum value for the given field if varies. | |
| 534 | + * Otherwise same as getMinimum(). For Gregorian, no difference. | |
| 535 | + * Please see Calendar.getGreatestMinimum for descriptions on parameters | |
| 536 | + * and the return value. | |
| 537 | + */ | |
| 538 | + public int getGreatestMinimum(int field) | |
| 539 | + { | |
| 540 | + throw new NoSuchElementException(); | |
| 541 | + } | |
| 542 | + | |
| 543 | + /** | |
| 544 | + * Returns lowest maximum value for the given field if varies. | |
| 545 | + * Otherwise same as getMaximum(). For Gregorian DAY_OF_MONTH, 28 | |
| 546 | + * Please see Calendar.getLeastMaximum for descriptions on parameters and | |
| 547 | + * the return value. | |
| 548 | + */ | |
| 549 | + public int getLeastMaximum(int field) | |
| 550 | + { | |
| 551 | + throw new NoSuchElementException(); | |
| 552 | + } | |
| 553 | + | |
| 554 | + private void readObject(ObjectInputStream s) { | |
| 555 | + throw new NoSuchElementException(); | |
| 556 | + } | |
| 557 | +} | |
Empty file added.
| @@ -0,0 +1,169 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)ListResourceBundle.java 1.6 97/01/29 | |
| 3 | + * | |
| 4 | + * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved | |
| 5 | + * (C) Copyright IBM Corp. 1996 - All Rights Reserved | |
| 6 | + * | |
| 7 | + * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 8 | + * | |
| 9 | + * The original version of this source code and documentation is copyrighted | |
| 10 | + * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These | |
| 11 | + * materials are provided under terms of a License Agreement between Taligent | |
| 12 | + * and Sun. This technology is protected by multiple US and International | |
| 13 | + * patents. This notice and attribution to Taligent may not be removed. | |
| 14 | + * Taligent is a registered trademark of Taligent, Inc. | |
| 15 | + * | |
| 16 | + * Permission to use, copy, modify, and distribute this software | |
| 17 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 18 | + * fee is hereby granted provided that this copyright notice | |
| 19 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 20 | + * for further important copyright and licensing information. | |
| 21 | + * | |
| 22 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 23 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 24 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 25 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 26 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 27 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | +package java.util; | |
| 32 | +import java.util.Hashtable; | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * <code>ListResourceBundle</code> is a abstract subclass of | |
| 36 | + * <code>ResourceBundle</code> that manages resources for a locale | |
| 37 | + * in a convenient and easy to use list. See <code>ResourceBundle</code> for | |
| 38 | + * more information about resource bundles in general. | |
| 39 | + * | |
| 40 | + * <P> | |
| 41 | + * Subclasses must override <code>getContents</code> and provide an array, | |
| 42 | + * where each item in the array is a pair of objects. | |
| 43 | + * The first element of each pair is a <code>String</code> key, and the second | |
| 44 | + * is the value associated with that key. | |
| 45 | + * | |
| 46 | + * <p> | |
| 47 | + * In the following example, the keys are of the form "s1"... The actual | |
| 48 | + * keys are entirely up to your choice, so long as they are the same as | |
| 49 | + * the keys you use in your program to retrieve the objects from the bundle. | |
| 50 | + * Keys are case-sensitive. <code>MyResource</code> is the default version | |
| 51 | + * of the bundle family, and <code>MyResource_fr</code> is the french version: | |
| 52 | + * <blockquote> | |
| 53 | + * <pre> | |
| 54 | + * //==================== | |
| 55 | + * class MyResource extends ListResourceBundle { | |
| 56 | + * public Object[][] getContents() { | |
| 57 | + * return contents; | |
| 58 | + * } | |
| 59 | + * static final Object[][] contents = { | |
| 60 | + * // LOCALIZE THIS | |
| 61 | + * {"s1", "3"}, // starting value in choice field | |
| 62 | + * {"s2", "MyDisk"}, // starting value in string field | |
| 63 | + * {"s3", "3 Mar 96"}, // starting value in date field | |
| 64 | + * {"s4", "The disk '{1}' contained {0} on {2}."}, // initial pattern | |
| 65 | + * {"s5", "0"}, // first choice number | |
| 66 | + * {"s6", "no files"}, // first choice value | |
| 67 | + * {"s7", "1"}, // second choice number | |
| 68 | + * {"s8", "one file"}, // second choice value | |
| 69 | + * {"s9", "2"}, // third choice number | |
| 70 | + * {"s10", "{0}|3 files"}, // third choice value | |
| 71 | + * {"s11", "format threw an exception: {0}"}, // generic exception message | |
| 72 | + * {"s12", "ERROR"}, // what to show in field in case of error | |
| 73 | + * {"s14", "Result"}, // label for formatted stuff | |
| 74 | + * {"s13", "Dialog"}, // standard font | |
| 75 | + * {"s15", "Pattern"}, // label for standard pattern | |
| 76 | + * {"s16", new Dimension(1,5)} // real object, not just string | |
| 77 | + * // END OF MATERIAL TO LOCALIZE | |
| 78 | + * }; | |
| 79 | + * } | |
| 80 | + * //==================== | |
| 81 | + * class MyResource_fr extends ListResourceBundle { | |
| 82 | + * public Object[][] getContents() { | |
| 83 | + * return contents; | |
| 84 | + } | |
| 85 | + * static final Object[][] contents = { | |
| 86 | + * // LOCALIZE THIS | |
| 87 | + * {"s1", "3"}, // starting value in choice field | |
| 88 | + * {"s2", "MonDisk"}, // starting value in string field | |
| 89 | + * {"s3", "3 Mar 96"}, // starting value in date field | |
| 90 | + * {"s4", "Le disk '{1}' a {0} a {2}."}, // initial pattern | |
| 91 | + * {"s5", "0"}, // first choice number | |
| 92 | + * {"s6", "pas de files"}, // first choice value | |
| 93 | + * {"s7", "1"}, // second choice number | |
| 94 | + * {"s8", "une file"}, // second choice value | |
| 95 | + * {"s9", "2"}, // third choice number | |
| 96 | + * {"s10", "{0}|3 files"}, // third choice value | |
| 97 | + * {"s11", "Le format a jete une exception: {0}"}, // generic exception message | |
| 98 | + * {"s12", "ERROR"}, // what to show in field in case of error | |
| 99 | + * {"s14", "Resulte"}, // label for formatted stuff | |
| 100 | + * {"s13", "Dialogue"}, // standard font | |
| 101 | + * {"s15", "Pattern"}, // label for standard pattern | |
| 102 | + * {"s16", new Dimension(1,3)} // real object, not just string | |
| 103 | + * // END OF MATERIAL TO LOCALIZE | |
| 104 | + * }; | |
| 105 | + * } | |
| 106 | + * </pre> | |
| 107 | + * </blockquote> | |
| 108 | + * @see ResourceBundle | |
| 109 | + * @see PropertyResourceBundle | |
| 110 | + */ | |
| 111 | +public abstract class ListResourceBundle extends ResourceBundle { | |
| 112 | + /** | |
| 113 | + * Override of ResourceBundle, same semantics | |
| 114 | + */ | |
| 115 | + public final Object handleGetObject(String key) { | |
| 116 | + // lazily load the lookup hashtable. | |
| 117 | + if (lookup == null) { | |
| 118 | + loadLookup(); | |
| 119 | + } | |
| 120 | + return lookup.get(key); // this class ignores locales | |
| 121 | + } | |
| 122 | + | |
| 123 | + /** | |
| 124 | + * Implementation of ResourceBundle.getKeys. | |
| 125 | + */ | |
| 126 | + public Enumeration getKeys() { | |
| 127 | + // lazily load the lookup hashtable. | |
| 128 | + if (lookup == null) { | |
| 129 | + loadLookup(); | |
| 130 | + } | |
| 131 | + Enumeration result = null; | |
| 132 | + if (parent != null) { | |
| 133 | + Hashtable temp = new Hashtable(); | |
| 134 | + for (Enumeration parentKeys = parent.getKeys() ; | |
| 135 | + parentKeys.hasMoreElements() ; /* nothing */) { | |
| 136 | + temp.put(parentKeys.nextElement(), this); | |
| 137 | + } | |
| 138 | + for (Enumeration thisKeys = lookup.keys(); | |
| 139 | + thisKeys.hasMoreElements() ; /* nothing */) { | |
| 140 | + temp.put(thisKeys.nextElement(), this); | |
| 141 | + } | |
| 142 | + result = temp.keys(); | |
| 143 | + } else { | |
| 144 | + result = lookup.keys(); | |
| 145 | + } | |
| 146 | + return result; | |
| 147 | + } | |
| 148 | + | |
| 149 | + /** | |
| 150 | + * See class description. | |
| 151 | + */ | |
| 152 | + abstract protected Object[][] getContents(); | |
| 153 | + | |
| 154 | + // ==================privates==================== | |
| 155 | + | |
| 156 | + /** | |
| 157 | + * We lazily load the lookup hashtable. This function does the | |
| 158 | + * loading. | |
| 159 | + */ | |
| 160 | + private void loadLookup() { | |
| 161 | + Object[][] contents = getContents(); | |
| 162 | + lookup = new Hashtable(contents.length); | |
| 163 | + for (int i = 0; i < contents.length; ++i) { | |
| 164 | + lookup.put(contents[i][0],contents[i][1]); | |
| 165 | + } | |
| 166 | + } | |
| 167 | + | |
| 168 | + private Hashtable lookup = null; | |
| 169 | +} | |
| @@ -0,0 +1,631 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)Locale.java 1.21 97/01/29 | |
| 3 | + * | |
| 4 | + * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved | |
| 5 | + * (C) Copyright IBM Corp. 1996 - All Rights Reserved | |
| 6 | + * | |
| 7 | + * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 8 | + * | |
| 9 | + * The original version of this source code and documentation is copyrighted | |
| 10 | + * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These | |
| 11 | + * materials are provided under terms of a License Agreement between Taligent | |
| 12 | + * and Sun. This technology is protected by multiple US and International | |
| 13 | + * patents. This notice and attribution to Taligent may not be removed. | |
| 14 | + * Taligent is a registered trademark of Taligent, Inc. | |
| 15 | + * | |
| 16 | + * Permission to use, copy, modify, and distribute this software | |
| 17 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 18 | + * fee is hereby granted provided that this copyright notice | |
| 19 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 20 | + * for further important copyright and licensing information. | |
| 21 | + * | |
| 22 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 23 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 24 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 25 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 26 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 27 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | +package java.util; | |
| 32 | +import java.io.Serializable; | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * | |
| 36 | + * A <code>Locale</code> object represents a specific geographical, political, | |
| 37 | + * or cultural region. An operation that requires a <code>Locale</code> to perform | |
| 38 | + * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code> | |
| 39 | + * to tailor information for the user. For example, displaying a number | |
| 40 | + * is a locale-sensitive operation--the number should be formatted | |
| 41 | + * according to the customs/conventions of the user's native country, | |
| 42 | + * region, or culture. | |
| 43 | + * | |
| 44 | + * <P> | |
| 45 | + * You create a <code>Locale</code> object using one of the two constructors in | |
| 46 | + * this class: | |
| 47 | + * <blockquote> | |
| 48 | + * <pre> | |
| 49 | + * Locale(String language, String country) | |
| 50 | + * Locale(String language, String country, String variant) | |
| 51 | + * </pre> | |
| 52 | + * </blockquote> | |
| 53 | + * The first argument to both constructors is a valid <STRONG>ISO | |
| 54 | + * Language Code.</STRONG> These codes are the lower-case two-letter | |
| 55 | + * codes as defined by ISO-639. | |
| 56 | + * You can find a full list of these codes at a number of sites, such as: | |
| 57 | + * <BR><a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt"> | |
| 58 | + * <code>http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</code></a> | |
| 59 | + * | |
| 60 | + * <P> | |
| 61 | + * The second argument to both constructors is a valid <STRONG>ISO Country | |
| 62 | + * Code.</STRONG> These codes are the upper-case two-letter codes | |
| 63 | + * as defined by ISO-3166. | |
| 64 | + * You can find a full list of these codes at a number of sites, such as: | |
| 65 | + * <BR><a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html"> | |
| 66 | + * <code>http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</code></a> | |
| 67 | + * | |
| 68 | + * <P> | |
| 69 | + * The second constructor requires a third argument--the <STRONG>Variant.</STRONG> | |
| 70 | + * The Variant codes are vendor and browser-specific. | |
| 71 | + * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. | |
| 72 | + * Where there are two variants, separate them with an underscore, and | |
| 73 | + * put the most important one first. For | |
| 74 | + * example, a Traditional Spanish collation might be referenced, with | |
| 75 | + * "ES", "ES", "Traditional_WIN". | |
| 76 | + * | |
| 77 | + * <P> | |
| 78 | + * Because a <code>Locale</code> object is just an identifier for a region, | |
| 79 | + * no validity check is performed when you construct a <code>Locale</code>. | |
| 80 | + * If you want to see whether particular resources are available for the | |
| 81 | + * <code>Locale</code> you construct, you must query those resources. For | |
| 82 | + * example, ask the <code>NumberFormat</code> for the locales it supports | |
| 83 | + * using its <code>getAvailableLocales</code> method. | |
| 84 | + * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular | |
| 85 | + * locale, you get back the best available match, not necessarily | |
| 86 | + * precisely what you asked for. For more information, look at | |
| 87 | + * <a href="java.util.ResourceBundle.html"><code>ResourceBundle</code></a>. | |
| 88 | + * | |
| 89 | + * <P> | |
| 90 | + * The <code>Locale</code> class provides a number of convenient constants | |
| 91 | + * that you can use to create <code>Locale</code> objects for commonly used | |
| 92 | + * locales. For example, the following creates a <code>Locale</code> object | |
| 93 | + * for the United States: | |
| 94 | + * <blockquote> | |
| 95 | + * <pre> | |
| 96 | + * Locale.US | |
| 97 | + * </pre> | |
| 98 | + * </blockquote> | |
| 99 | + * | |
| 100 | + * <P> | |
| 101 | + * Once you've created a <code>Locale</code> you can query it for information about | |
| 102 | + * itself. Use <code>getCountry</code> to get the ISO Country Code and | |
| 103 | + * <code>getLanguage</code> to get the ISO Language Code. You can | |
| 104 | + * use <code>getDisplayCountry</code> to get the | |
| 105 | + * name of the country suitable for displaying to the user. Similarly, | |
| 106 | + * you can use <code>getDisplayLanguage</code> to get the name of | |
| 107 | + * the language suitable for displaying to the user. Interestingly, | |
| 108 | + * the <code>getDisplayXXX</code> methods are themselves locale-sensitive | |
| 109 | + * and have two versions: one that uses the default locale and one | |
| 110 | + * that uses the locale specified as an argument. | |
| 111 | + * | |
| 112 | + * <P> | |
| 113 | + * The JDK provides a number of classes that perform locale-sensitive | |
| 114 | + * operations. For example, the <code>NumberFormat</code> class formats | |
| 115 | + * numbers, currency, or percentages in a locale-sensitive manner. Classes | |
| 116 | + * such as <code>NumberFormat</code> have a number of convenience methods | |
| 117 | + * for creating a default object of that type. For example, the | |
| 118 | + * <code>NumberFormat</code> class provides these three convenience methods | |
| 119 | + * for creating a default <code>NumberFormat</code> object: | |
| 120 | + * <blockquote> | |
| 121 | + * <pre> | |
| 122 | + * NumberFormat.getInstance() | |
| 123 | + * NumberFormat.getCurrencyInstance() | |
| 124 | + * NumberFormat.getPercentInstance() | |
| 125 | + * </pre> | |
| 126 | + * </blockquote> | |
| 127 | + * These methods have two variants; one with an explicit locale | |
| 128 | + * and one without; the latter using the default locale. | |
| 129 | + * <blockquote> | |
| 130 | + * <pre> | |
| 131 | + * NumberFormat.getInstance(myLocale) | |
| 132 | + * NumberFormat.getCurrencyInstance(myLocale) | |
| 133 | + * NumberFormat.getPercentInstance(myLocale) | |
| 134 | + * </pre> | |
| 135 | + * </blockquote> | |
| 136 | + * A <code>Locale</code> is the mechanism for identifying the kind of object | |
| 137 | + * (<code>NumberFormat</code>) that you would like to get. The locale is | |
| 138 | + * <STRONG>just</STRONG> a mechanism for identifying objects, | |
| 139 | + * <STRONG>not</STRONG> a container for the objects themselves. | |
| 140 | + * | |
| 141 | + * <P> | |
| 142 | + * Each class that performs locale-sensitive operations allows you | |
| 143 | + * to get all the available objects of that type. You can sift | |
| 144 | + * through these objects by language, country, or variant, | |
| 145 | + * and use the display names to present a menu to the user. | |
| 146 | + * For example, you can create a menu of all the collation objects | |
| 147 | + * suitable for a given language. Such classes must implement these | |
| 148 | + * three class methods: | |
| 149 | + * <blockquote> | |
| 150 | + * <pre> | |
| 151 | + * public static Locale[] getAvailableLocales() | |
| 152 | + * public static String getDisplayName(Locale objectLocale, | |
| 153 | + * Locale displayLocale) | |
| 154 | + * public static final String getDisplayName(Locale objectLocale) | |
| 155 | + * // getDisplayName will throw MissingResourceException if the locale | |
| 156 | + * // is not one of the available locales. | |
| 157 | + * </pre> | |
| 158 | + * </blockquote> | |
| 159 | + * | |
| 160 | + * @see ResourceBundle | |
| 161 | + * @see java.text.Format | |
| 162 | + * @see java.text.NumberFormat | |
| 163 | + * @see java.text.Collation | |
| 164 | + * @version 1.21 29 Jan 1997 | |
| 165 | + * @author Mark Davis | |
| 166 | + */ | |
| 167 | + | |
| 168 | +public final class Locale implements Cloneable, Serializable { | |
| 169 | + | |
| 170 | + /** Useful constant for language. | |
| 171 | + */ | |
| 172 | + static public final Locale ENGLISH = new Locale("en","",""); | |
| 173 | + | |
| 174 | + /** Useful constant for language. | |
| 175 | + */ | |
| 176 | + static public final Locale FRENCH = new Locale("fr","",""); | |
| 177 | + | |
| 178 | + /** Useful constant for language. | |
| 179 | + */ | |
| 180 | + static public final Locale GERMAN = new Locale("de","",""); | |
| 181 | + | |
| 182 | + /** Useful constant for language. | |
| 183 | + */ | |
| 184 | + static public final Locale ITALIAN = new Locale("it","",""); | |
| 185 | + | |
| 186 | + /** Useful constant for language. | |
| 187 | + */ | |
| 188 | + static public final Locale JAPANESE = new Locale("ja","",""); | |
| 189 | + | |
| 190 | + /** Useful constant for language. | |
| 191 | + */ | |
| 192 | + static public final Locale KOREAN = new Locale("ko","",""); | |
| 193 | + | |
| 194 | + /** Useful constant for language. | |
| 195 | + */ | |
| 196 | + static public final Locale CHINESE = new Locale("zh","",""); | |
| 197 | + | |
| 198 | + /** Useful constant for language. | |
| 199 | + */ | |
| 200 | + static public final Locale SIMPLIFIED_CHINESE = new Locale("zh","CN",""); | |
| 201 | + | |
| 202 | + /** Useful constant for language. | |
| 203 | + */ | |
| 204 | + static public final Locale TRADITIONAL_CHINESE = new Locale("zh","TW",""); | |
| 205 | + | |
| 206 | + /** Useful constant for country. | |
| 207 | + */ | |
| 208 | + static public final Locale FRANCE = new Locale("fr","FR",""); | |
| 209 | + | |
| 210 | + /** Useful constant for country. | |
| 211 | + */ | |
| 212 | + static public final Locale GERMANY = new Locale("de","DE",""); | |
| 213 | + | |
| 214 | + /** Useful constant for country. | |
| 215 | + */ | |
| 216 | + static public final Locale ITALY = new Locale("it","IT",""); | |
| 217 | + | |
| 218 | + /** Useful constant for country. | |
| 219 | + */ | |
| 220 | + static public final Locale JAPAN = new Locale("ja","JP",""); | |
| 221 | + | |
| 222 | + /** Useful constant for country. | |
| 223 | + */ | |
| 224 | + static public final Locale KOREA = new Locale("ko","KR",""); | |
| 225 | + | |
| 226 | + /** Useful constant for country. | |
| 227 | + */ | |
| 228 | + static public final Locale CHINA = new Locale("zh","CN",""); | |
| 229 | + | |
| 230 | + /** Useful constant for country. | |
| 231 | + */ | |
| 232 | + static public final Locale PRC = new Locale("zh","CN",""); | |
| 233 | + | |
| 234 | + /** Useful constant for country. | |
| 235 | + */ | |
| 236 | + static public final Locale TAIWAN = new Locale("zh","TW",""); | |
| 237 | + | |
| 238 | + /** Useful constant for country. | |
| 239 | + */ | |
| 240 | + static public final Locale UK = new Locale("en","GB",""); | |
| 241 | + | |
| 242 | + /** Useful constant for country. | |
| 243 | + */ | |
| 244 | + static public final Locale US = new Locale("en","US",""); | |
| 245 | + | |
| 246 | + /** Useful constant for country. | |
| 247 | + */ | |
| 248 | + static public final Locale CANADA = new Locale("en","CA",""); | |
| 249 | + | |
| 250 | + /** Useful constant for country. | |
| 251 | + */ | |
| 252 | + static public final Locale CANADA_FRENCH = new Locale("fr","CA",""); | |
| 253 | + | |
| 254 | + /** | |
| 255 | + * Construct a locale from language, country, variant. | |
| 256 | + * @param language lowercase two-letter ISO-639 code. | |
| 257 | + * @param country uppercase two-letter ISO-3166 code. | |
| 258 | + * @param variant vendor and browser specific code. See class description. | |
| 259 | + */ | |
| 260 | + public Locale(String language, String country, String variant) { | |
| 261 | + this.language = toLowerCase(language); | |
| 262 | + this.country = toUpperCase(country); | |
| 263 | + this.variant = toUpperCase(variant); | |
| 264 | + } | |
| 265 | + | |
| 266 | + /** | |
| 267 | + * Construct a locale from language, country. | |
| 268 | + * @param language lowercase two-letter ISO-639 code. | |
| 269 | + * @param country uppercase two-letter ISO-3166 code. | |
| 270 | + */ | |
| 271 | + public Locale(String language, String country) { | |
| 272 | + this.language = toLowerCase(language); | |
| 273 | + this.country = toUpperCase(country); | |
| 274 | + this.variant = ""; | |
| 275 | + } | |
| 276 | + | |
| 277 | + /** | |
| 278 | + * Common method of getting the current default Locale. | |
| 279 | + * Used for the presentation: menus, dialogs, etc. | |
| 280 | + * Generally set once when your applet or application is initialized, | |
| 281 | + * then never reset. (If you do reset the default locale, you | |
| 282 | + * probably want to reload your GUI, so that the change is reflected | |
| 283 | + * in your interface.) | |
| 284 | + * <p>More advanced programs will allow users to use different locales | |
| 285 | + * for different fields, e.g. in a spreadsheet. | |
| 286 | + * <BR>Note that the initial setting will match the host system. | |
| 287 | + */ | |
| 288 | + public static synchronized Locale getDefault() { | |
| 289 | + if (defaultLocale == null) { | |
| 290 | + String language = System.getProperty("user.language", "EN"); | |
| 291 | + String region = System.getProperty("user.region", ""); | |
| 292 | + | |
| 293 | + defaultLocale = new Locale(language, region); | |
| 294 | + } | |
| 295 | + return defaultLocale; | |
| 296 | + } | |
| 297 | + | |
| 298 | + /** | |
| 299 | + * Sets the default. | |
| 300 | + * Normally set once at the beginning of applet or application, | |
| 301 | + * then never reset. <code>setDefault</code> does not reset the host locale. | |
| 302 | + * @param newLocale Locale to set to. | |
| 303 | + */ | |
| 304 | + public static synchronized void setDefault(Locale newLocale) { | |
| 305 | + SecurityManager security = System.getSecurityManager(); | |
| 306 | + if (security != null) { | |
| 307 | + security.checkPropertyAccess("user.language"); | |
| 308 | + } | |
| 309 | + defaultLocale = newLocale; | |
| 310 | + } | |
| 311 | + | |
| 312 | + /** | |
| 313 | + * Getter for programmatic name of field, | |
| 314 | + * an lowercased two-letter ISO-639 code. | |
| 315 | + * @see #getDisplayLanguage | |
| 316 | + */ | |
| 317 | + public String getLanguage() { | |
| 318 | + return language; | |
| 319 | + } | |
| 320 | + | |
| 321 | + /** | |
| 322 | + * Getter for programmatic name of field, | |
| 323 | + * an uppercased two-letter ISO-3166 code. | |
| 324 | + * @see #getDisplayCountry | |
| 325 | + */ | |
| 326 | + public String getCountry() { | |
| 327 | + return country; | |
| 328 | + } | |
| 329 | + | |
| 330 | + /** | |
| 331 | + * Getter for programmatic name of field. | |
| 332 | + * @see #getDisplayVariant | |
| 333 | + */ | |
| 334 | + public String getVariant() { | |
| 335 | + return variant; | |
| 336 | + } | |
| 337 | + | |
| 338 | + /** | |
| 339 | + * Getter for the programmatic name of the entire locale, | |
| 340 | + * with the language, country and variant separated by underbars. | |
| 341 | + * If a field is missing, at most one underbar will occur. | |
| 342 | + * Example: "EN", "DE_DE", "EN_US_WIN", "DE_POSIX", "FR_MAC" | |
| 343 | + * @see #getDisplayName | |
| 344 | + */ | |
| 345 | + public final String toString() { | |
| 346 | + StringBuffer result = new StringBuffer(language); | |
| 347 | + if (country.length() != 0) { | |
| 348 | + result.append('_'); | |
| 349 | + result.append(country); | |
| 350 | + if (variant.length() != 0) { | |
| 351 | + result.append('_'); | |
| 352 | + result.append(variant); | |
| 353 | + } | |
| 354 | + } | |
| 355 | + return result.toString(); | |
| 356 | + } | |
| 357 | + | |
| 358 | + /** | |
| 359 | + * Getter for the three-letter ISO language abbreviation | |
| 360 | + * of the locale. | |
| 361 | + * @exception MissingResourceException Throws MissingResourceException if the | |
| 362 | + * three-letter language abbreviation is not available for this locale. | |
| 363 | + */ | |
| 364 | + public String getISO3Language() throws MissingResourceException { | |
| 365 | + ResourceBundle resource | |
| 366 | + = ResourceBundle.getBundle | |
| 367 | + ("java.text.resources.LocaleElements", this); | |
| 368 | + return resource.getString("ShortLanguage"); | |
| 369 | + } | |
| 370 | + | |
| 371 | + /** | |
| 372 | + * Getter for the three-letter ISO country abbreviation | |
| 373 | + * of the locale. | |
| 374 | + * @exception MissingResourceException Throws MissingResourceException if the | |
| 375 | + * three-letter language abbreviation is not available for this locale. | |
| 376 | + */ | |
| 377 | + public String getISO3Country() throws MissingResourceException { | |
| 378 | + ResourceBundle resource = | |
| 379 | + ResourceBundle.getBundle | |
| 380 | + ("java.text.resources.LocaleElements", this); | |
| 381 | + return resource.getString("ShortCountry"); | |
| 382 | + } | |
| 383 | + | |
| 384 | + /** | |
| 385 | + * Getter for the Locale ID, as used in Windows. | |
| 386 | + * @exception MissingResourceException Throws MissingResourceException if there is | |
| 387 | + * no LCID associated with the locale. | |
| 388 | + */ | |
| 389 | + // FIXME this should go away completely! | |
| 390 | + private int getLCID() throws MissingResourceException { | |
| 391 | + ResourceBundle resource = | |
| 392 | + ResourceBundle.getBundle | |
| 393 | + ("java.text.resources.LocaleElements", this); | |
| 394 | + String lcid = resource.getString("LocaleID"); | |
| 395 | + return Integer.parseInt(lcid,16); | |
| 396 | + } | |
| 397 | + | |
| 398 | + /** | |
| 399 | + * Getter for display of field to user. | |
| 400 | + * If the localized name is not found, returns the ISO code. | |
| 401 | + * The desired user language is from the default locale. | |
| 402 | + */ | |
| 403 | + public final String getDisplayLanguage() { | |
| 404 | + return getDisplayLanguage(getDefault()); | |
| 405 | + } | |
| 406 | + | |
| 407 | + /** | |
| 408 | + * Getter for display of field to user. | |
| 409 | + * If the localized name is not found, returns the ISO codes. | |
| 410 | + * Example: "English (UK)", "Deutch", "Germany" | |
| 411 | + * @param inLocale specifies the desired user language. | |
| 412 | + */ | |
| 413 | + public String getDisplayLanguage(Locale inLocale) { | |
| 414 | + try { | |
| 415 | + ResourceBundle resource = | |
| 416 | + ResourceBundle.getBundle | |
| 417 | + ("java.text.resources.LocaleElements", this); | |
| 418 | + return findStringMatch((String[][])resource.getObject("Languages"), | |
| 419 | + inLocale.language, language); | |
| 420 | + } catch (Exception e) { | |
| 421 | + return language; | |
| 422 | + } | |
| 423 | + } | |
| 424 | + | |
| 425 | + /** | |
| 426 | + * Getter for display of field to user. | |
| 427 | + * If the localized name is not found, returns the ISO code. | |
| 428 | + * The default locale is used for the presentation language. | |
| 429 | + */ | |
| 430 | + public final String getDisplayCountry() { | |
| 431 | + return getDisplayCountry(getDefault()); | |
| 432 | + } | |
| 433 | + | |
| 434 | + /** | |
| 435 | + * Getter for display of field to user. | |
| 436 | + * If the localized name is not found, returns the ISO code. | |
| 437 | + * @param inLocale specifies the desired user language. | |
| 438 | + */ | |
| 439 | + public String getDisplayCountry(Locale inLocale) { | |
| 440 | + try { | |
| 441 | + ResourceBundle resource = | |
| 442 | + ResourceBundle.getBundle | |
| 443 | + ("java.text.resources.LocaleElements",this); | |
| 444 | + return findStringMatch((String[][])resource.getObject("Countries"), | |
| 445 | + inLocale.language, language); | |
| 446 | + } catch (Exception e) { | |
| 447 | + return country; | |
| 448 | + } | |
| 449 | + } | |
| 450 | + | |
| 451 | + /** | |
| 452 | + * Getter for display of field to user. | |
| 453 | + * If the localized name is not found, returns the variant code. | |
| 454 | + * The default locale is used for the presentation language. | |
| 455 | + */ | |
| 456 | + public final String getDisplayVariant() { | |
| 457 | + return getDisplayVariant(getDefault()); | |
| 458 | + } | |
| 459 | + | |
| 460 | + /** | |
| 461 | + * Getter for display of field to user | |
| 462 | + * If the localized name is not found, returns the variant code. | |
| 463 | + * @param inLocale specifies the desired user language. | |
| 464 | + */ | |
| 465 | + public String getDisplayVariant(Locale inLocale) { | |
| 466 | + try { | |
| 467 | + ResourceBundle resource = | |
| 468 | + ResourceBundle.getBundle | |
| 469 | + ("java.text.resources.LocaleElements", inLocale); | |
| 470 | + String[][] pairedStrings = (String[][])resource.getObject("Variants"); | |
| 471 | + if (pairedStrings == null) | |
| 472 | + return variant; | |
| 473 | + return findStringMatch(pairedStrings, inLocale.language, language); | |
| 474 | + } catch (Exception e) { | |
| 475 | + return variant; | |
| 476 | + } | |
| 477 | + } | |
| 478 | + | |
| 479 | + /** | |
| 480 | + * Getter for display of the entire locale to user. | |
| 481 | + * If the localized name is not found, uses the ISO codes. | |
| 482 | + * The default locale is used for the presentation language. | |
| 483 | + */ | |
| 484 | + public final String getDisplayName() { | |
| 485 | + return getDisplayName(getDefault()); | |
| 486 | + } | |
| 487 | + | |
| 488 | + /** | |
| 489 | + * Getter for display of the entire locale to user. | |
| 490 | + * If the localized name is not found, uses the ISO codes | |
| 491 | + * @param inLocale specifies the desired user language. | |
| 492 | + */ | |
| 493 | + public String getDisplayName(Locale inLocale) { | |
| 494 | + // TODO: use pattern string from locale data | |
| 495 | + StringBuffer result = new StringBuffer (getDisplayLanguage(inLocale)); | |
| 496 | + String aCountry = getDisplayCountry(inLocale); | |
| 497 | + String aVariant = getDisplayVariant(inLocale); | |
| 498 | + if (aCountry.length() != 0 || aVariant.length() != 0) { | |
| 499 | + result.append(" ("); | |
| 500 | + result.append(getDisplayCountry(inLocale)); | |
| 501 | + if (aCountry.length() != 0 && aVariant.length() != 0) | |
| 502 | + result.append(","); | |
| 503 | + result.append(getDisplayVariant(inLocale)); | |
| 504 | + result.append(")"); | |
| 505 | + } | |
| 506 | + return result.toString(); | |
| 507 | + } | |
| 508 | + | |
| 509 | + /** | |
| 510 | + * Overrides Cloneable | |
| 511 | + */ | |
| 512 | + public Object clone() | |
| 513 | + { | |
| 514 | + try { | |
| 515 | + Locale that = (Locale)super.clone(); | |
| 516 | + return that; | |
| 517 | + } catch (CloneNotSupportedException e) { | |
| 518 | + throw new InternalError(); | |
| 519 | + } | |
| 520 | + } | |
| 521 | + | |
| 522 | + /** | |
| 523 | + * Override hashCode. | |
| 524 | + * Since Locales are often used in hashtables, caches the value | |
| 525 | + * for speed. | |
| 526 | + */ | |
| 527 | + // XXX Depending on performance of synchronized, may want to | |
| 528 | + // XXX just compute in constructor. | |
| 529 | + public synchronized int hashCode() { | |
| 530 | + if (hashcode == -1) { | |
| 531 | + hashcode = | |
| 532 | + language.hashCode() ^ | |
| 533 | + country.hashCode() ^ | |
| 534 | + variant.hashCode(); | |
| 535 | + } | |
| 536 | + return hashcode; | |
| 537 | + } | |
| 538 | + | |
| 539 | + // Overrides | |
| 540 | + | |
| 541 | + public boolean equals(Object obj) { | |
| 542 | + if (this == obj) // quick check | |
| 543 | + return true; | |
| 544 | + if (!(obj instanceof Locale)) // (1) same object? | |
| 545 | + return false; | |
| 546 | + Locale other = (Locale) obj; | |
| 547 | + if (hashCode() != other.hashCode()) return false; // quick check | |
| 548 | + if (!language.equals(other.language)) return false; | |
| 549 | + if (!country.equals(other.country)) return false; | |
| 550 | + if (!variant.equals(other.variant)) return false; | |
| 551 | + return true; // we made it through the guantlet. | |
| 552 | + // (1) We don't check super.equals since it is Object. | |
| 553 | + // Since Locale is final, we don't have to check both directions. | |
| 554 | + } | |
| 555 | + | |
| 556 | + // ================= privates ===================================== | |
| 557 | + | |
| 558 | + // XXX instance and class variables. For now keep these separate, since it is | |
| 559 | + // faster to match. Later, make into single string. | |
| 560 | + | |
| 561 | + private String language = ""; | |
| 562 | + private String country = ""; | |
| 563 | + private String variant = ""; | |
| 564 | + | |
| 565 | + private /*FIXME(83) transient*/ int hashcode = -1; // lazy evaluated | |
| 566 | + | |
| 567 | + private static Locale defaultLocale = null; | |
| 568 | + | |
| 569 | + /* | |
| 570 | + * Locale needs its own, locale insenitive version of toLowerCase to | |
| 571 | + * avoid circularity problems between Locale and String. | |
| 572 | + * The most straightforward algorithm is used. Look at optimizations later. | |
| 573 | + */ | |
| 574 | + private String toLowerCase(String str) { | |
| 575 | + char[] buf = str.toCharArray(); | |
| 576 | + for (int i = 0; i < buf.length; i++) { | |
| 577 | + buf[i] = Character.toLowerCase( buf[i] ); | |
| 578 | + } | |
| 579 | + return new String( buf ); | |
| 580 | + } | |
| 581 | + | |
| 582 | + /* | |
| 583 | + * Locale needs its own, locale insenitive version of toUpperCase to | |
| 584 | + * avoid circularity problems between Locale and String. | |
| 585 | + * The most straightforward algorithm is used. Look at optimizations later. | |
| 586 | + */ | |
| 587 | + private String toUpperCase(String str) { | |
| 588 | + char[] buf = str.toCharArray(); | |
| 589 | + for (int i = 0; i < buf.length; i++) { | |
| 590 | + buf[i] = Character.toUpperCase( buf[i] ); | |
| 591 | + } | |
| 592 | + return new String( buf ); | |
| 593 | + } | |
| 594 | + | |
| 595 | + private String findStringMatch(String[][] languages, | |
| 596 | + String desiredLanguage, String fallbackLanguage) | |
| 597 | + { | |
| 598 | + for (int i = 0; i < languages.length; ++i) | |
| 599 | + if (desiredLanguage.equals(languages[i][0])) | |
| 600 | + return languages[i][1]; | |
| 601 | + if (!fallbackLanguage.equals(desiredLanguage)) | |
| 602 | + for (int i = 0; i < languages.length; ++i) | |
| 603 | + if (fallbackLanguage.equals(languages[i][0])) | |
| 604 | + return languages[i][1]; | |
| 605 | + if (!"EN".equals(desiredLanguage) && "EN".equals(fallbackLanguage)) | |
| 606 | + for (int i = 0; i < languages.length; ++i) | |
| 607 | + if ("EN".equals(languages[i][0])) | |
| 608 | + return languages[i][1]; | |
| 609 | + return ""; | |
| 610 | + } | |
| 611 | + /* | |
| 612 | + * Does an equals check, plus an empty field in this means a wildcard; | |
| 613 | + * matches any other field in other. | |
| 614 | + */ | |
| 615 | + private boolean matches (Locale other) { | |
| 616 | + //System.out.println("language:" + language + "," + other.language); | |
| 617 | + if (language.length() != 0) | |
| 618 | + if (!language.equals(other.language)) | |
| 619 | + return false; | |
| 620 | + //System.out.println("country:" + country + "," + other.country); | |
| 621 | + if (country.length() != 0) | |
| 622 | + if (!country.equals(other.country)) | |
| 623 | + return false; | |
| 624 | + //System.out.println("variant:" + variant + "," + other.variant); | |
| 625 | + if (variant.length() != 0) | |
| 626 | + if (!variant.equals(other.variant)) | |
| 627 | + return false; | |
| 628 | + return true; // whew, we made it through the guantlet. | |
| 629 | + } | |
| 630 | + | |
| 631 | +} | |
| @@ -0,0 +1,73 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)MissingResourceException.java 1.4 97/01/29 | |
| 3 | + * | |
| 4 | + * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved | |
| 5 | + * (C) Copyright IBM Corp. 1996 - All Rights Reserved | |
| 6 | + * | |
| 7 | + * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 8 | + * | |
| 9 | + * The original version of this source code and documentation is copyrighted | |
| 10 | + * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These | |
| 11 | + * materials are provided under terms of a License Agreement between Taligent | |
| 12 | + * and Sun. This technology is protected by multiple US and International | |
| 13 | + * patents. This notice and attribution to Taligent may not be removed. | |
| 14 | + * Taligent is a registered trademark of Taligent, Inc. | |
| 15 | + * | |
| 16 | + * Permission to use, copy, modify, and distribute this software | |
| 17 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 18 | + * fee is hereby granted provided that this copyright notice | |
| 19 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 20 | + * for further important copyright and licensing information. | |
| 21 | + * | |
| 22 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 23 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 24 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 25 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 26 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 27 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | +package java.util; | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * Signals that a resource is missing. | |
| 35 | + * @see java.io.Exception | |
| 36 | + * @see ResourceBundle | |
| 37 | + * @version 1.4, 01/29/97 | |
| 38 | + * @author Mark Davis | |
| 39 | + */ | |
| 40 | +public | |
| 41 | +class MissingResourceException extends RuntimeException { | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * Constructs a MissingResourceException with the specified information. | |
| 45 | + * A detail message is a String that describes this particular exception. | |
| 46 | + * @param s the detail message | |
| 47 | + * @param classname the name of the resource class | |
| 48 | + * @param key the key for the missing resource. | |
| 49 | + */ | |
| 50 | + public MissingResourceException(String s, String className, String key) { | |
| 51 | + super(s); | |
| 52 | + this.className = className; | |
| 53 | + this.key = key; | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Gets parameter passed by constructor. | |
| 58 | + */ | |
| 59 | + public String getClassName() { | |
| 60 | + return className; | |
| 61 | + } | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * Gets parameter passed by constructor. | |
| 65 | + */ | |
| 66 | + public String getKey() { | |
| 67 | + return key; | |
| 68 | + } | |
| 69 | + | |
| 70 | + //============ privates ============ | |
| 71 | + private String className; | |
| 72 | + private String key; | |
| 73 | +} | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,121 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)PropertyResourceBundle.java 1.7 97/01/29 | |
| 3 | + * | |
| 4 | + * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved | |
| 5 | + * (C) Copyright IBM Corp. 1996 - All Rights Reserved | |
| 6 | + * | |
| 7 | + * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 8 | + * | |
| 9 | + * The original version of this source code and documentation is copyrighted | |
| 10 | + * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These | |
| 11 | + * materials are provided under terms of a License Agreement between Taligent | |
| 12 | + * and Sun. This technology is protected by multiple US and International | |
| 13 | + * patents. This notice and attribution to Taligent may not be removed. | |
| 14 | + * Taligent is a registered trademark of Taligent, Inc. | |
| 15 | + * | |
| 16 | + * Permission to use, copy, modify, and distribute this software | |
| 17 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 18 | + * fee is hereby granted provided that this copyright notice | |
| 19 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 20 | + * for further important copyright and licensing information. | |
| 21 | + * | |
| 22 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 23 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 24 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 25 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 26 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 27 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 28 | + * | |
| 29 | + */ | |
| 30 | +package java.util; | |
| 31 | + | |
| 32 | +import java.util.Properties; | |
| 33 | +import java.io.InputStream; | |
| 34 | +import java.io.IOException; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * <code>PropertyResourceBundle</code> is an abstract subclass of | |
| 38 | + * <code>ResourceBundle</code> that manages resources for a locale | |
| 39 | + * using a set of static strings from a property file. See | |
| 40 | + * <code>ResourceBundle</code> for more information about resource | |
| 41 | + * bundles in general. | |
| 42 | + * | |
| 43 | + * <p> | |
| 44 | + * The property file contains the keys that you use in your source code | |
| 45 | + * in calls to <code>ResourceBundle.getString</code> and similar methods, | |
| 46 | + * and their corresponding values, etc. | |
| 47 | + * The name of the property file indicates the resource bundle's family | |
| 48 | + * and locale. | |
| 49 | + * | |
| 50 | + * <p> | |
| 51 | + * In the following example, the keys are of the form "s1"... The actual | |
| 52 | + * keys are entirely up to your choice, so long as they are the same as | |
| 53 | + * the keys you use in your program to retrieve the objects from the bundle. | |
| 54 | + * Keys are case-sensitive. | |
| 55 | + * <blockquote> | |
| 56 | + * <pre> | |
| 57 | + * s1=3 | |
| 58 | + * s2=MeinDisk | |
| 59 | + * s3=3 Mar 96 | |
| 60 | + * s4=Der disk '{1}' a {0} a {2}. | |
| 61 | + * s5=0 | |
| 62 | + * s6=keine Datein | |
| 63 | + * s7=1 | |
| 64 | + * s8=ein Datei | |
| 65 | + * s9=2 | |
| 66 | + * s10={0}|3 Datein | |
| 67 | + * s11=Der Format worf ein Exception: {0} | |
| 68 | + * s12=ERROR | |
| 69 | + * s14=Resulte | |
| 70 | + * s13=Dialogue | |
| 71 | + * s15=Pattern | |
| 72 | + * s16=1,3 | |
| 73 | + * </pre> | |
| 74 | + * </blockquote> | |
| 75 | + * | |
| 76 | + * @see ResourceBundle | |
| 77 | + * @see ListResourceBundle | |
| 78 | + */ | |
| 79 | +public class PropertyResourceBundle extends ResourceBundle { | |
| 80 | + /** | |
| 81 | + * Creates a property resource | |
| 82 | + * @param file property file to read from. | |
| 83 | + */ | |
| 84 | + public PropertyResourceBundle (InputStream stream) throws IOException { | |
| 85 | + lookup.load(stream); | |
| 86 | + } | |
| 87 | + | |
| 88 | + /** | |
| 89 | + * Override of ResourceBundle, same semantics | |
| 90 | + */ | |
| 91 | + public Object handleGetObject(String key) { | |
| 92 | + Object obj = lookup.get(key); | |
| 93 | + return obj; // once serialization is in place, you can do non-strings | |
| 94 | + } | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * Implementation of ResourceBundle.getKeys. | |
| 98 | + */ | |
| 99 | + public Enumeration getKeys() { | |
| 100 | + Enumeration result = null; | |
| 101 | + if (parent != null) { | |
| 102 | + Hashtable temp = new Hashtable(); | |
| 103 | + for (Enumeration parentKeys = parent.getKeys() ; | |
| 104 | + parentKeys.hasMoreElements() ; /* nothing */) { | |
| 105 | + temp.put(parentKeys.nextElement(), this); | |
| 106 | + } | |
| 107 | + for (Enumeration thisKeys = lookup.keys(); | |
| 108 | + thisKeys.hasMoreElements() ; /* nothing */) { | |
| 109 | + temp.put(thisKeys.nextElement(), this); | |
| 110 | + } | |
| 111 | + result = temp.keys(); | |
| 112 | + } else { | |
| 113 | + result = lookup.keys(); | |
| 114 | + } | |
| 115 | + return result; | |
| 116 | + } | |
| 117 | + | |
| 118 | + // ==================privates==================== | |
| 119 | + | |
| 120 | + private Properties lookup = new Properties(); | |
| 121 | +} | |
Empty file added.
| @@ -0,0 +1,536 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)ResourceBundle.java 1.15 97/01/29 | |
| 3 | + * | |
| 4 | + * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved | |
| 5 | + * (C) Copyright IBM Corp. 1996 - All Rights Reserved | |
| 6 | + * | |
| 7 | + * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 8 | + * | |
| 9 | + * The original version of this source code and documentation is copyrighted | |
| 10 | + * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These | |
| 11 | + * materials are provided under terms of a License Agreement between Taligent | |
| 12 | + * and Sun. This technology is protected by multiple US and International | |
| 13 | + * patents. This notice and attribution to Taligent may not be removed. | |
| 14 | + * Taligent is a registered trademark of Taligent, Inc. | |
| 15 | + * | |
| 16 | + * Permission to use, copy, modify, and distribute this software | |
| 17 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 18 | + * fee is hereby granted provided that this copyright notice | |
| 19 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 20 | + * for further important copyright and licensing information. | |
| 21 | + * | |
| 22 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 23 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 24 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 25 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 26 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 27 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 28 | + * | |
| 29 | + */ | |
| 30 | +package java.util; | |
| 31 | + | |
| 32 | +import java.io.InputStream; | |
| 33 | +import java.io.FileInputStream; | |
| 34 | +import java.util.Hashtable; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * | |
| 38 | + * Resource bundles contain locale-specific objects. | |
| 39 | + * When your program needs a locale-specific resource, | |
| 40 | + * a <code>String</code> for example, your program can load it | |
| 41 | + * from the resource bundle that is appropriate for the | |
| 42 | + * current user's locale. In this way, you can write | |
| 43 | + * program code that is largely independent of the user's | |
| 44 | + * locale isolating most, if not all, of the locale-specific | |
| 45 | + * information in resource bundles. | |
| 46 | + * | |
| 47 | + * <p> | |
| 48 | + * This allows you to write programs that can: | |
| 49 | + * <UL type=SQUARE> | |
| 50 | + * <LI> be easily localized, or translated, into different languages | |
| 51 | + * <LI> handle multiple locales at once | |
| 52 | + * <LI> be easily modified later to support even more locales | |
| 53 | + * </UL> | |
| 54 | + * | |
| 55 | + * <P> | |
| 56 | + * One resource bundle is, conceptually, a set of related classes that | |
| 57 | + * inherit from <code>ResourceBundle</code>. Each related subclass of | |
| 58 | + * <code>ResourceBundle</code> has the same base name plus an additional | |
| 59 | + * component that identifies its locale. For example, suppose your resource | |
| 60 | + * bundle is named <code>MyResources</code>. The first class you are likely | |
| 61 | + * to write is the default resource bundle which simply has the same name as | |
| 62 | + * its family--<code>MyResources</code>. You can also provide as | |
| 63 | + * many related locale-specific classes as you need: for example, perhaps | |
| 64 | + * you would provide a German one named <code>MyResources_de</code>. | |
| 65 | + * | |
| 66 | + * <P> | |
| 67 | + * Each related subclass of <code>ResourceBundle</code> contains the same | |
| 68 | + * items, but the items have been translated for the locale represented by that | |
| 69 | + * <code>ResourceBundle</code> subclass. For example, both <code>MyResources</code> | |
| 70 | + * and <code>MyResources_de</code> may have a <code>String</code> that's used | |
| 71 | + * on a button for confirming operations. In <code>MyResources</code> the | |
| 72 | + * <code>String</code> may contain <code>OK</code> and in | |
| 73 | + * <code>MyResources_de</code> it may contain <code>Gut</code>. | |
| 74 | + * | |
| 75 | + * <P> | |
| 76 | + * If there are different resources for different countries, you | |
| 77 | + * can make specializations: for example, <code>MyResources_de_CH</code> | |
| 78 | + * for Switzerland. If you want to only modify some of the resources | |
| 79 | + * in the specialization, you can do so. | |
| 80 | + * | |
| 81 | + * <P> | |
| 82 | + * When your program needs a locale-specific object, it loads | |
| 83 | + * the <code>ResourceBundle</code> class using the <code>getBundle</code> | |
| 84 | + * method: | |
| 85 | + * <blockquote> | |
| 86 | + * <pre> | |
| 87 | + * ResourceBundle myResources = | |
| 88 | + * ResourceBundle.getBundle("MyResources", currentLocale); | |
| 89 | + * </pre> | |
| 90 | + * </blockquote> | |
| 91 | + * The first argument specifies the family name of the resource | |
| 92 | + * bundle that contains the object in question. The second argument | |
| 93 | + * indicates the desired locale. <code>getBundle</code> | |
| 94 | + * uses these two arguments to construct the name of the | |
| 95 | + * <code>ResourceBundle</code> subclass it should load as follows. | |
| 96 | + * | |
| 97 | + * <P> | |
| 98 | + * The resource bundle lookup searches for classes with various suffixes | |
| 99 | + * on the basis of (1) the desired locale and (2) the default locale (baseclass), | |
| 100 | + * in the following order from lower-level (more specific) to parent-level | |
| 101 | + * (less specific): | |
| 102 | + * <p> baseclass + "_" + language1 + "_" + country1 + "_" + variant1 | |
| 103 | + * <BR> baseclass + "_" + language1 + "_" + country1 | |
| 104 | + * <BR> baseclass + "_" + language1 | |
| 105 | + * <BR> baseclass | |
| 106 | + * <BR> baseclass + "_" + language2 + "_" + country2 + "_" + variant2 | |
| 107 | + * <BR> baseclass + "_" + language2 + "_" + country2 | |
| 108 | + * <BR> baseclass + "_" + language2 | |
| 109 | + * | |
| 110 | + * <P> | |
| 111 | + * The result of the lookup is a class, but that class may be | |
| 112 | + * backed by a property file on disk. If a lookup fails, | |
| 113 | + * <code>getBundle()</code> throws a <code>MissingResourceException</code>. | |
| 114 | + * | |
| 115 | + * <P> | |
| 116 | + * The baseclass <strong>must</strong> be fully | |
| 117 | + * qualified (for example, <code>myPackage.MyResources</code>, not just | |
| 118 | + * <code>MyResources</code>). It must | |
| 119 | + * also be accessable by your code; it cannot be a class that is private | |
| 120 | + * to the package where <code>ResourceBundle.getBundle</code> is called. | |
| 121 | + * | |
| 122 | + * <P> | |
| 123 | + * Note: <code>ResourceBundle</code> are used internally in accessing | |
| 124 | + * <code>NumberFormat</code>s, <code>Collation</code>s, and so on. | |
| 125 | + * The lookup strategy is the same. | |
| 126 | + * | |
| 127 | + * <P> | |
| 128 | + * Resource bundles contain key/value pairs. The keys uniquely | |
| 129 | + * identify a locale-specific object in the bundle. Here's an | |
| 130 | + * example of a <code>ListResourceBundle</code> that contains | |
| 131 | + * two key/value pairs: | |
| 132 | + * <blockquote> | |
| 133 | + * <pre> | |
| 134 | + * class MyResource extends ListResourceBundle { | |
| 135 | + * public Object[][] getContents() { | |
| 136 | + * return contents; | |
| 137 | + * } | |
| 138 | + * static final Object[][] contents = { | |
| 139 | + * // LOCALIZE THIS | |
| 140 | + * {"OkKey", "OK"}, | |
| 141 | + * {"CancelKey", "Cancel"}, | |
| 142 | + * // END OF MATERIAL TO LOCALIZE | |
| 143 | + * }; | |
| 144 | + * } | |
| 145 | + * </pre> | |
| 146 | + * </blockquote> | |
| 147 | + * Keys are always <code>String</code>s. | |
| 148 | + * In this example, the keys are <code>OkKey</code> and <code>CancelKey</code>. | |
| 149 | + * In the above example, the values | |
| 150 | + * are also <code>String</code>s--<code>OK</code> and <code>Cancel</code>--but | |
| 151 | + * they don't have to be. The values can be any type of object. | |
| 152 | + * | |
| 153 | + * <P> | |
| 154 | + * You retrieve an object from resource bundle using the appropriate | |
| 155 | + * getter method. Because <code>OkKey</code> and <code>CancelKey</code> | |
| 156 | + * are both strings, you would use <code>getString</code> to retrieve them: | |
| 157 | + * <blockquote> | |
| 158 | + * <pre> | |
| 159 | + * button1 = new Button(myResourceBundle.getString("OkKey")); | |
| 160 | + * button2 = new Button(myResourceBundle.getString("CancelKey")); | |
| 161 | + * </pre> | |
| 162 | + * </blockquote> | |
| 163 | + * The getter methods all require the key as an argument and return | |
| 164 | + * the object if found. If the object is not found, the getter method | |
| 165 | + * throws a <code>MissingResourceException</code>. | |
| 166 | + * | |
| 167 | + * <P> | |
| 168 | + * Besides <code>getString</code>; ResourceBundle supports a number | |
| 169 | + * of other methods for getting different types of objects such as | |
| 170 | + * <code>getStringArray</code>. If you don't have an object that | |
| 171 | + * matches one of these methods, you can use <code>getObject</code> | |
| 172 | + * and cast the result to the appropriate type. For example: | |
| 173 | + * <blockquote> | |
| 174 | + * <pre> | |
| 175 | + * int[] myIntegers = (int[]) myResources.getObject("intList"); | |
| 176 | + * </pre> | |
| 177 | + * </blockquote> | |
| 178 | + * | |
| 179 | + * <P> | |
| 180 | + * <STRONG>NOTE:</STRONG> You should always supply a baseclass with | |
| 181 | + * no suffixes. This will be the class of "last resort", if a locale | |
| 182 | + * is requested that does not exist. For example, below we have a class | |
| 183 | + * <code>MyResources</code>. It happens to contain US strings, | |
| 184 | + * so we don't have to have an explicit <code>MyResource_en</code> or | |
| 185 | + * <code>MyResource_en_US</code>. | |
| 186 | + * | |
| 187 | + * <P> | |
| 188 | + * The JDK provides two subclasses of <code>ResourceBundle</code>, | |
| 189 | + * <code>ListResourceBundle</code> and <code>PropertyResourceBundle</code>, | |
| 190 | + * that provide a fairly simple way to create resources. (Once serialization | |
| 191 | + * is fully integrated, we will provide another | |
| 192 | + * way.) As you saw briefly in a prevous example, <code>ListResourceBundle</code> | |
| 193 | + * manages its resource as a List of key/value pairs. | |
| 194 | + * <code>PropertyResourceBundle</code> uses a properties file to manage | |
| 195 | + * its resources. | |
| 196 | + * | |
| 197 | + * <p> | |
| 198 | + * If <code>ListResourceBundle</code> or <code>PropertyResourceBundle</code> | |
| 199 | + * do not suit your needs, you can write your own <code>ResourceBundle</code> | |
| 200 | + * subclass. Your subclasses must overrde two methods: <code>handleGetObject</code> | |
| 201 | + * and <code>getKeys()</code>. | |
| 202 | + * | |
| 203 | + * <P> | |
| 204 | + * The following is a very simple example of a <code>ResourceBundle</code> subclass | |
| 205 | + * that manages only a few resources (for a larger number of resources | |
| 206 | + * you would probably use a <code>Hashtable</code>). Notice that if the key | |
| 207 | + * is not found, <code>handleGetObject</code> must return null. Notice also | |
| 208 | + * that you don't need to supply a value if a "parent-level" | |
| 209 | + * <code>ResourceBundle</code> handles the same | |
| 210 | + * key with the same value (look at uk below). | |
| 211 | + * <strong><p>Example:</strong> | |
| 212 | + * <blockquote> | |
| 213 | + * <pre> | |
| 214 | + * abstract class MyResources extends ResourceBundle { | |
| 215 | + * public Object handleGetObject(String key) { | |
| 216 | + * if (key.equals("okKey")) return "Ok"; | |
| 217 | + * if (key.equals("cancelKey")) return "Cancel"; | |
| 218 | + * return null; | |
| 219 | + * } | |
| 220 | + * } | |
| 221 | + * | |
| 222 | + * abstract class MyResources_de extends MyResources { | |
| 223 | + * public Object handleGetObject(String key) { | |
| 224 | + * if (key.equals("okKey")) return "Gut"; | |
| 225 | + * if (key.equals("cancelKey")) return "Vernichten"; | |
| 226 | + * return null; | |
| 227 | + * } | |
| 228 | + * } | |
| 229 | + * | |
| 230 | + * abstract class MyResources_uk extends MyResources { | |
| 231 | + * public Object handleGetObject(String key) { | |
| 232 | + * // don't need okKey, since parent level handles it. | |
| 233 | + * if (key.equals("cancelKey")) return "Dispose"; | |
| 234 | + * return null; | |
| 235 | + * } | |
| 236 | + * } | |
| 237 | + * </pre> | |
| 238 | + * </blockquote> | |
| 239 | + * You do not have to restrict yourself to using a single family of | |
| 240 | + * <code>ResourceBundle</code>s. For example, you could have a set of bundles for | |
| 241 | + * exception messages, <code>ExceptionResources</code> | |
| 242 | + * (<code>ExceptionResources_fr</code>, <code>ExceptionResources_de</code>, ...), | |
| 243 | + * and one for widgets, <code>WidgetResource</code> (<code>WidgetResources_fr</code>, | |
| 244 | + * <code>WidgetResources_de</code>, ...); breaking up the resources however you like. | |
| 245 | + * | |
| 246 | + * @see ListResourceBundle | |
| 247 | + * @see PropertyResourceBundle | |
| 248 | + * @see MissingResourceException | |
| 249 | + */ | |
| 250 | +abstract public class ResourceBundle { | |
| 251 | + | |
| 252 | + /** | |
| 253 | + * Get an object from a ResourceBundle. | |
| 254 | + * <BR>Convenience method to save casting. | |
| 255 | + * @param key see class description. | |
| 256 | + */ | |
| 257 | + public final String getString(String key) throws MissingResourceException { | |
| 258 | + return (String) getObject(key); | |
| 259 | + } | |
| 260 | + | |
| 261 | + /** | |
| 262 | + * Get an object from a ResourceBundle. | |
| 263 | + * <BR>Convenience method to save casting. | |
| 264 | + * @param key see class description. | |
| 265 | + */ | |
| 266 | + public final String[] getStringArray(String key) | |
| 267 | + throws MissingResourceException { | |
| 268 | + return (String[]) getObject(key); | |
| 269 | + } | |
| 270 | + | |
| 271 | + /** | |
| 272 | + * Get an object from a ResourceBundle. | |
| 273 | + * @param key see class description. | |
| 274 | + */ | |
| 275 | + public final Object getObject(String key) throws MissingResourceException { | |
| 276 | + Object obj = handleGetObject(key); | |
| 277 | + if (obj == null) { | |
| 278 | + if (parent != null) { | |
| 279 | + obj = parent.getObject(key); | |
| 280 | + } | |
| 281 | + if (obj == null) | |
| 282 | + throw new MissingResourceException("Can't find resource", | |
| 283 | + this.getClass().getName(), | |
| 284 | + key); | |
| 285 | + } | |
| 286 | + return obj; | |
| 287 | + } | |
| 288 | + | |
| 289 | + | |
| 290 | + /** | |
| 291 | + * Get the appropriate ResourceBundle subclass. | |
| 292 | + * @param baseName see class description. | |
| 293 | + */ | |
| 294 | + public static final ResourceBundle getBundle(String baseName) | |
| 295 | + throws MissingResourceException | |
| 296 | + { | |
| 297 | + return getBundle(baseName, Locale.getDefault(), | |
| 298 | + /* must determine loader here, else we break stack invariant */ | |
| 299 | + getLoader()); | |
| 300 | + } | |
| 301 | + | |
| 302 | + | |
| 303 | + /** | |
| 304 | + * Get the appropriate ResourceBundle subclass. | |
| 305 | + * @param baseName see class description. | |
| 306 | + * @param locale see class description. | |
| 307 | + */ | |
| 308 | + public static final ResourceBundle getBundle(String baseName, | |
| 309 | + Locale locale) | |
| 310 | + { | |
| 311 | + return getBundle(baseName, locale, getLoader()); | |
| 312 | + } | |
| 313 | + | |
| 314 | + /* | |
| 315 | + * Automatic determination of the ClassLoader to be used to load | |
| 316 | + * resources on behalf of the client. N.B. The client is getLoader's | |
| 317 | + * caller's caller. | |
| 318 | + */ | |
| 319 | + private static ClassLoader getLoader() { | |
| 320 | + Class[] stack = getClassContext(); | |
| 321 | + /* Magic number 2 identifies our caller's caller */ | |
| 322 | + Class c = stack[2]; | |
| 323 | + ClassLoader cl = (c == null) ? null : c.getClassLoader(); | |
| 324 | + return (cl == null) ? systemClassLoader : cl; | |
| 325 | + } | |
| 326 | + private static native Class[] getClassContext(); | |
| 327 | + private static SystemClassLoader systemClassLoader = | |
| 328 | + new SystemClassLoader(); | |
| 329 | + | |
| 330 | + /** | |
| 331 | + * Get the appropriate ResourceBundle subclass. | |
| 332 | + * @param baseName see class description. | |
| 333 | + * @param locale see class description. | |
| 334 | + */ | |
| 335 | + private static synchronized ResourceBundle | |
| 336 | + getBundle(String baseName, Locale locale, ClassLoader loader) | |
| 337 | + throws MissingResourceException | |
| 338 | + { | |
| 339 | + StringBuffer localeName | |
| 340 | + = new StringBuffer("_").append(locale.toString()); | |
| 341 | + | |
| 342 | + ResourceBundle lookup = findBundle(baseName,localeName,loader,false); | |
| 343 | + if(lookup == null) { | |
| 344 | + localeName.setLength(0); | |
| 345 | + localeName.append("_").append( Locale.getDefault().toString() ); | |
| 346 | + lookup = findBundle(baseName, localeName, loader, true); | |
| 347 | + if( lookup == null ) { | |
| 348 | + throw new MissingResourceException("can't find resource for " | |
| 349 | + + baseName + "_" + locale, | |
| 350 | + baseName + "_" + locale,""); | |
| 351 | + } | |
| 352 | + } | |
| 353 | + | |
| 354 | + // Setup lookup's ancestry. If we find an ancestor whose parent is null, | |
| 355 | + // we set up the ancestor's parent as well. | |
| 356 | + ResourceBundle child = lookup; | |
| 357 | + while( (child != null) && (child.parent == null) ) { | |
| 358 | + // Chop off the last component of the locale name and search for that | |
| 359 | + // as the parent locale. Use it to set the parent of current child. | |
| 360 | + int lastUnderbar = localeName.toString().lastIndexOf('_'); | |
| 361 | + if( lastUnderbar != -1 ) { | |
| 362 | + localeName.setLength(lastUnderbar); | |
| 363 | + debug("Searching for parent " + baseName + localeName); | |
| 364 | + child.setParent( findBundle(baseName,localeName,loader,true) ); | |
| 365 | + } | |
| 366 | + child = child.parent; | |
| 367 | + } | |
| 368 | + | |
| 369 | + return lookup; | |
| 370 | + } | |
| 371 | + | |
| 372 | + | |
| 373 | + /** | |
| 374 | + * Set the parent bundle of this bundle. The parent bundle is | |
| 375 | + * searched by getObject when this bundle does not contain a | |
| 376 | + * particular resource. | |
| 377 | + * @param parent this bundle's parent bundle. | |
| 378 | + */ | |
| 379 | + protected void setParent( ResourceBundle parent ) { | |
| 380 | + this.parent = parent; | |
| 381 | + } | |
| 382 | + | |
| 383 | + | |
| 384 | + /** | |
| 385 | + * The internal routine that does the real work of finding and loading | |
| 386 | + * the right ResourceBundle for a given name and locale. | |
| 387 | + */ | |
| 388 | + private static ResourceBundle findBundle(String baseName, | |
| 389 | + StringBuffer localeName, | |
| 390 | + ClassLoader loader, | |
| 391 | + boolean includeBase) | |
| 392 | + { | |
| 393 | + String localeStr = localeName.toString(); | |
| 394 | + String baseFileName = baseName.replace('.', '/'); | |
| 395 | + Object lookup = null; | |
| 396 | + String searchName; | |
| 397 | + Vector cacheCandidates = new Vector(); | |
| 398 | + int lastUnderbar; | |
| 399 | + InputStream stream; | |
| 400 | + | |
| 401 | + searchLoop: | |
| 402 | + while (true) { | |
| 403 | + searchName = baseName + localeStr; | |
| 404 | + String cacheName = | |
| 405 | + "["+Integer.toString(loader.hashCode())+"]" + searchName; | |
| 406 | + | |
| 407 | + // First, look in the cache. We may either find the bundle we're | |
| 408 | + // looking for or we may find that the bundle was not found by a | |
| 409 | + // previous search. | |
| 410 | + lookup = cacheList.get(cacheName); | |
| 411 | + if( lookup == NOTFOUND ) { | |
| 412 | + debug("Found " + searchName + " in cache as NOTFOUND"); | |
| 413 | + localeName.setLength(0); | |
| 414 | + break searchLoop; | |
| 415 | + } | |
| 416 | + if( lookup != null ) { | |
| 417 | + debug("Found " + searchName + " in cache"); | |
| 418 | + localeName.setLength(0); | |
| 419 | + break searchLoop; | |
| 420 | + } | |
| 421 | + cacheCandidates.addElement( cacheName ); | |
| 422 | + | |
| 423 | + // Next search for a class | |
| 424 | + debug("Searching for " + searchName ); | |
| 425 | + try { | |
| 426 | + lookup = loader.loadClass(searchName).newInstance(); | |
| 427 | + break searchLoop; | |
| 428 | + } catch( Exception e ){} | |
| 429 | + | |
| 430 | + // Next search for a Properties file. | |
| 431 | + searchName = baseFileName + localeStr + ".properties"; | |
| 432 | + debug("Searching for " + searchName ); | |
| 433 | + stream = loader.getResourceAsStream(searchName); | |
| 434 | + if( stream != null ) { | |
| 435 | + // make sure it is buffered | |
| 436 | + stream = new java.io.BufferedInputStream(stream); | |
| 437 | + try { | |
| 438 | + lookup = (Object)new PropertyResourceBundle( stream ); | |
| 439 | + break searchLoop; | |
| 440 | + } catch (Exception e) {} | |
| 441 | + } | |
| 442 | + | |
| 443 | + //Chop off the last part of the locale name string and try again. | |
| 444 | + lastUnderbar = localeStr.lastIndexOf('_'); | |
| 445 | + if( ((lastUnderbar==0)&&(!includeBase)) || (lastUnderbar == -1) ) { | |
| 446 | + break; | |
| 447 | + } | |
| 448 | + localeStr = localeStr.substring(0,lastUnderbar); | |
| 449 | + localeName.setLength(lastUnderbar); | |
| 450 | + } | |
| 451 | + | |
| 452 | + | |
| 453 | + if( lookup != null ) { | |
| 454 | + // Add a positive result to the cache. The result may include | |
| 455 | + // NOTFOUND | |
| 456 | + for( int i=0; i<cacheCandidates.size(); i++ ) { | |
| 457 | + cacheList.put(cacheCandidates.elementAt(i), lookup); | |
| 458 | + debug("Adding " + cacheCandidates.elementAt(i) + " to cache" | |
| 459 | + + ((lookup == NOTFOUND)?" as NOTFOUND.":".")); | |
| 460 | + } | |
| 461 | + } | |
| 462 | + else { | |
| 463 | + // If we searched all the way to the base, then we can add | |
| 464 | + // the NOTFOUND result to the cache. Otherwise we can say | |
| 465 | + // nothing. | |
| 466 | + if( includeBase == true ) { | |
| 467 | + for( int i=0; i<cacheCandidates.size(); i++ ) { | |
| 468 | + cacheList.put(cacheCandidates.elementAt(i), NOTFOUND); | |
| 469 | + debug("Adding " + cacheCandidates.elementAt(i) | |
| 470 | + + " to cache as NOTFOUND."); | |
| 471 | + } | |
| 472 | + } | |
| 473 | + } | |
| 474 | + | |
| 475 | + if( (lookup == NOTFOUND) || (lookup == null) ) | |
| 476 | + return null; | |
| 477 | + else | |
| 478 | + return (ResourceBundle)lookup; | |
| 479 | + } | |
| 480 | + | |
| 481 | + | |
| 482 | + /** Get an object from a ResourceBundle. | |
| 483 | + * <STRONG>NOTE: </STRONG>Subclasses must override. | |
| 484 | + * @param key see class description. | |
| 485 | + */ | |
| 486 | + protected abstract Object handleGetObject(String key) | |
| 487 | + throws MissingResourceException; | |
| 488 | + | |
| 489 | + /** | |
| 490 | + * Return an enumeration of the keys. | |
| 491 | + * <STRONG>NOTE: </STRONG>Subclasses must override. | |
| 492 | + */ | |
| 493 | + public abstract Enumeration getKeys(); | |
| 494 | + | |
| 495 | + /** | |
| 496 | + * For printf debugging. | |
| 497 | + */ | |
| 498 | + private static boolean debugFlag = false; | |
| 499 | + private static void debug(String str) { | |
| 500 | + if( debugFlag ) { | |
| 501 | + System.out.println("ResourceBundle: " + str); | |
| 502 | + } | |
| 503 | + } | |
| 504 | + | |
| 505 | + /** | |
| 506 | + * The parent bundle is consulted by getObject when this bundle | |
| 507 | + * does not contain a particular resource. | |
| 508 | + */ | |
| 509 | + protected ResourceBundle parent = null; | |
| 510 | + | |
| 511 | + private static final Integer NOTFOUND = new Integer(-1); | |
| 512 | + private static Hashtable cacheList = new Hashtable(); | |
| 513 | +} | |
| 514 | + | |
| 515 | + | |
| 516 | +/** | |
| 517 | + * The SystemClassLoader loads system classes (those in your classpath). | |
| 518 | + * This is an attempt to unify the handling of system classes and ClassLoader | |
| 519 | + * classes. | |
| 520 | + */ | |
| 521 | +class SystemClassLoader extends java.lang.ClassLoader { | |
| 522 | + | |
| 523 | + protected Class loadClass( String name, boolean resolve ) | |
| 524 | + throws ClassNotFoundException | |
| 525 | + { | |
| 526 | + return findSystemClass( name ); | |
| 527 | + } | |
| 528 | + | |
| 529 | + public InputStream getResourceAsStream(String name) { | |
| 530 | + return ClassLoader.getSystemResourceAsStream(name); | |
| 531 | + } | |
| 532 | + | |
| 533 | + public java.net.URL getResource(String name) { | |
| 534 | + return ClassLoader.getSystemResource(name); | |
| 535 | + } | |
| 536 | +} | |
| @@ -0,0 +1,48 @@ | ||
| 1 | +implement ResourceBundle_L; | |
| 2 | + | |
| 3 | +# javal v1.3 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +#<< | |
| 28 | + | |
| 29 | +include "ResourceBundle_L.m"; | |
| 30 | + | |
| 31 | +#>> extra post includes here | |
| 32 | + | |
| 33 | +#<< | |
| 34 | + | |
| 35 | +init( jni_p : JNI ) | |
| 36 | +{ | |
| 37 | + # save java native inteface mod instance | |
| 38 | + jni = jni_p; | |
| 39 | + #>>extra initialization here | |
| 40 | + #<< | |
| 41 | +} | |
| 42 | + | |
| 43 | +getClassContext_aClass( ) : JArrayJClass | |
| 44 | +{#>> | |
| 45 | + jni->FatalError( "getClassContext() not implemented" ); | |
| 46 | + return(nil); | |
| 47 | +}#<< | |
| 48 | + | |
| @@ -0,0 +1,14 @@ | ||
| 1 | +# javal v1.3 generated file: edit with care | |
| 2 | + | |
| 3 | +ResourceBundle_L : module | |
| 4 | +{ | |
| 5 | + ResourceBundle_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + parent : cyclic ref ResourceBundle_obj; | |
| 9 | + }; | |
| 10 | + | |
| 11 | + init : fn( jni_p : JNI ); | |
| 12 | + getClassContext_aClass : fn( ) : JArrayJClass; | |
| 13 | + | |
| 14 | +}; | |
| @@ -0,0 +1,246 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)SimpleTimeZone.java 1.12 97/03/05 | |
| 3 | + * | |
| 4 | + * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved | |
| 5 | + * (C) Copyright IBM Corp. 1996 - All Rights Reserved | |
| 6 | + * | |
| 7 | + * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 8 | + * | |
| 9 | + * The original version of this source code and documentation is copyrighted | |
| 10 | + * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These | |
| 11 | + * materials are provided under terms of a License Agreement between Taligent | |
| 12 | + * and Sun. This technology is protected by multiple US and International | |
| 13 | + * patents. This notice and attribution to Taligent may not be removed. | |
| 14 | + * Taligent is a registered trademark of Taligent, Inc. | |
| 15 | + * | |
| 16 | + * Permission to use, copy, modify, and distribute this software | |
| 17 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 18 | + * fee is hereby granted provided that this copyright notice | |
| 19 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 20 | + * for further important copyright and licensing information. | |
| 21 | + * | |
| 22 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 23 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 24 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 25 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 26 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 27 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | +package java.util; | |
| 32 | + | |
| 33 | +import java.io.ObjectInputStream; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * <code>SimpleTimeZone</code> is a concrete subclass of <code>TimeZone</code> | |
| 37 | + * that represents a time zone for use with a Gregorian | |
| 38 | + * calendar. This simple class does not handle historical | |
| 39 | + * changes, and has limited rules. | |
| 40 | + * | |
| 41 | + * <P> | |
| 42 | + * Use a negative value for <code>dayOfWeekInMonth</code> to indicate that | |
| 43 | + * <code>SimpleTimeZone</code> should count from the end of the month backwards. | |
| 44 | + * For example, Daylight Savings Time ends at the last | |
| 45 | + * (dayOfWeekInMonth = -1) Sunday in October, at 2 AM in standard time. | |
| 46 | + * | |
| 47 | + * @see Calendar | |
| 48 | + * @see GregorianCalendar | |
| 49 | + * @see TimeZone | |
| 50 | + * @version 1.12 03/05/97 | |
| 51 | + * @author David Goldsmith, Mark Davis, Chen-Lieh Huang | |
| 52 | + */ | |
| 53 | +public class SimpleTimeZone extends TimeZone { | |
| 54 | + /** | |
| 55 | + * Constructs a SimpleTimeZone with the given base time zone offset | |
| 56 | + * from GMT and time zone ID. Timezone IDs can be obtained from | |
| 57 | + * TimeZone.getAvailableIDs. Normally you should use TimeZone.getDefault | |
| 58 | + * to construct a TimeZone. | |
| 59 | + * @param rawOffset the given base time zone offset to GMT. | |
| 60 | + * @param ID the time zone ID which is obtained from | |
| 61 | + * TimeZone.getAvailableIDs. | |
| 62 | + */ | |
| 63 | + public SimpleTimeZone(int rawOffset, String ID) | |
| 64 | + { | |
| 65 | + throw new NoSuchElementException(); | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Constructs a SimpleTimeZone with the given base time zone offset | |
| 70 | + * from GMT, time zone ID, time to start and end the daylight time. | |
| 71 | + * Timezone IDs can be obtained from TimeZone.getAvailableIDs. | |
| 72 | + * Normally you should use TimeZone.getDefault to create a TimeZone. | |
| 73 | + * For a time zone that does not use daylight saving time, do not | |
| 74 | + * use this constructor; instead you should use | |
| 75 | + * SimpleTimeZone(rawOffset, ID). | |
| 76 | + * @param rawOffset the given base time zone offset to GMT. | |
| 77 | + * @param ID the time zone ID which is obtained from | |
| 78 | + * TimeZone.getAvailableIDs. | |
| 79 | + * @param startMonth the daylight savings starting month. Month is 0-based. | |
| 80 | + * eg, 0 for January. | |
| 81 | + * @param startDayOfWeekInMonth the daylight savings starting | |
| 82 | + * day-of-week-in-month. Please see the member description for an example. | |
| 83 | + * @param startDayOfWeek the daylight savings starting day-of-week. | |
| 84 | + * Please see the member description for an example. | |
| 85 | + * @param startTime the daylight savings starting time. Please see the | |
| 86 | + * member description for an example. | |
| 87 | + * @param endMonth the daylight savings ending month. Month is 0-based. | |
| 88 | + * eg, 0 for January. | |
| 89 | + * @param endDayOfWeekInMonth the daylight savings ending | |
| 90 | + * day-of-week-in-month. Please see the member description for an example. | |
| 91 | + * @param endDayOfWeek the daylight savings ending day-of-week. Please see | |
| 92 | + * the member description for an example. | |
| 93 | + * @param endTime the daylight savings ending time. Please see the member | |
| 94 | + * description for an example. | |
| 95 | + */ | |
| 96 | + public SimpleTimeZone(int rawOffset, String ID, int startMonth, | |
| 97 | + int startDayOfWeekInMonth, int startDayOfWeek, int startTime, | |
| 98 | + int endMonth, int endDayOfWeekInMonth, int endDayOfWeek, int endTime) | |
| 99 | + { | |
| 100 | + throw new NoSuchElementException(); | |
| 101 | + } | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * Sets the daylight savings starting year. | |
| 105 | + * @param year the daylight savings starting year. | |
| 106 | + */ | |
| 107 | + public void setStartYear(int year) | |
| 108 | + { | |
| 109 | + throw new NoSuchElementException(); | |
| 110 | + } | |
| 111 | + | |
| 112 | + /** | |
| 113 | + * Sets the daylight savings starting rule. For example, Daylight Savings | |
| 114 | + * Time starts at the first Sunday in April, at 2 AM in standard time. | |
| 115 | + * Therefore, you can set the start rule by calling: | |
| 116 | + * setStartRule(TimeFields.APRIL, 1, TimeFields.SUNDAY, 2*60*60*1000); | |
| 117 | + * @param month the daylight savings starting month. Month is 0-based. | |
| 118 | + * eg, 0 for January. | |
| 119 | + * @param dayOfWeekInMonth the daylight savings starting | |
| 120 | + * day-of-week-in-month. Please see the member description for an example. | |
| 121 | + * @param dayOfWeek the daylight savings starting day-of-week. Please see | |
| 122 | + * the member description for an example. | |
| 123 | + * @param time the daylight savings starting time. Please see the member | |
| 124 | + * description for an example. | |
| 125 | + */ | |
| 126 | + public void setStartRule(int month, int dayOfWeekInMonth, int dayOfWeek, | |
| 127 | + int time) | |
| 128 | + { | |
| 129 | + throw new NoSuchElementException(); | |
| 130 | + } | |
| 131 | + | |
| 132 | + /** | |
| 133 | + * Sets the daylight savings ending rule. For example, Daylight Savings | |
| 134 | + * Time ends at the last (-1) Sunday in October, at 2 AM in standard time. | |
| 135 | + * Therefore, you can set the end rule by calling: | |
| 136 | + * setEndRule(TimeFields.OCTOBER, -1, TimeFields.SUNDAY, 2*60*60*1000); | |
| 137 | + * @param month the daylight savings ending month. Month is 0-based. | |
| 138 | + * eg, 0 for January. | |
| 139 | + * @param dayOfWeekInMonth the daylight savings ending | |
| 140 | + * day-of-week-in-month. Please see the member description for an example. | |
| 141 | + * @param dayOfWeek the daylight savings ending day-of-week. Please see | |
| 142 | + * the member description for an example. | |
| 143 | + * @param time the daylight savings ending time. Please see the member | |
| 144 | + * description for an example. | |
| 145 | + */ | |
| 146 | + public void setEndRule(int month, int dayOfWeekInMonth, int dayOfWeek, | |
| 147 | + int time) | |
| 148 | + { | |
| 149 | + throw new NoSuchElementException(); | |
| 150 | + } | |
| 151 | + | |
| 152 | + /** | |
| 153 | + * Overrides TimeZone | |
| 154 | + * Gets offset, for current date, modified in case of daylight savings. | |
| 155 | + * This is the offset to add *to* UTC to get local time. | |
| 156 | + * Please see TimeZone.getOffset for descriptions on parameters. | |
| 157 | + */ | |
| 158 | + public int getOffset(int era, int year, int month, int day, int dayOfWeek, | |
| 159 | + int millis) | |
| 160 | + { | |
| 161 | + throw new NoSuchElementException(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + /** | |
| 165 | + * Overrides TimeZone | |
| 166 | + * Gets the GMT offset for this time zone. | |
| 167 | + */ | |
| 168 | + public int getRawOffset() | |
| 169 | + { | |
| 170 | + throw new NoSuchElementException(); | |
| 171 | + } | |
| 172 | + | |
| 173 | + /** | |
| 174 | + * Overrides TimeZone | |
| 175 | + * Sets the base time zone offset to GMT. | |
| 176 | + * This is the offset to add *to* UTC to get local time. | |
| 177 | + * Please see TimeZone.setRawOffset for descriptions on the parameter. | |
| 178 | + */ | |
| 179 | + public void setRawOffset(int offsetMillis) | |
| 180 | + { | |
| 181 | + throw new NoSuchElementException(); | |
| 182 | + } | |
| 183 | + | |
| 184 | + /** | |
| 185 | + * Overrides TimeZone | |
| 186 | + * Queries if this time zone uses Daylight Savings Time. | |
| 187 | + */ | |
| 188 | + public boolean useDaylightTime() | |
| 189 | + { | |
| 190 | + throw new NoSuchElementException(); | |
| 191 | + } | |
| 192 | + | |
| 193 | + /** | |
| 194 | + * Overrides TimeZone | |
| 195 | + * Queries if the given date is in Daylight Savings Time. | |
| 196 | + */ | |
| 197 | + public boolean inDaylightTime(Date date) { | |
| 198 | + throw new NoSuchElementException(); | |
| 199 | + } | |
| 200 | + | |
| 201 | + /** | |
| 202 | + * Overrides Cloneable | |
| 203 | + */ | |
| 204 | + public Object clone() | |
| 205 | + { | |
| 206 | + throw new NoSuchElementException(); | |
| 207 | + } | |
| 208 | + | |
| 209 | + /** | |
| 210 | + * Override hashCode. | |
| 211 | + * Generates the hash code for the SimpleDateFormat object | |
| 212 | + */ | |
| 213 | + public synchronized int hashCode() | |
| 214 | + { | |
| 215 | + throw new NoSuchElementException(); | |
| 216 | + } | |
| 217 | + | |
| 218 | + /** | |
| 219 | + * Compares the equality of two SimpleTimeZone objects. | |
| 220 | + * @param obj the SimpleTimeZone object to be compared with. | |
| 221 | + * @return true if the given obj is the same as this SimpleTimeZone | |
| 222 | + * object; false otherwise. | |
| 223 | + */ | |
| 224 | + public boolean equals(Object obj) | |
| 225 | + { | |
| 226 | + throw new NoSuchElementException(); | |
| 227 | + } | |
| 228 | + | |
| 229 | + // =======================privates=============================== | |
| 230 | + | |
| 231 | + private int startMonth, startDay, startDayOfWeek, startTime; | |
| 232 | + private int endMonth, endDay, endDayOfWeek, endTime; | |
| 233 | + private int startYear; | |
| 234 | + private int rawOffset; | |
| 235 | + private boolean useDaylight=false; // indicate if this time zone uses DST | |
| 236 | + private static final int millisPerHour = 60*60*1000; | |
| 237 | + // WARNING: assumes that no rule is measured from the end of February, | |
| 238 | + // since we don't handle leap years. Could handle assuming always | |
| 239 | + // Gregorian, since we know they didn't have daylight time when | |
| 240 | + // Gregorian calendar started. | |
| 241 | + private final byte monthLength[] = {31,28,31,30,31,30,31,31,30,31,30,31}; | |
| 242 | + | |
| 243 | + private void readObject(ObjectInputStream s) { | |
| 244 | + throw new NoSuchElementException(); | |
| 245 | + } | |
| 246 | +} | |
Empty file added.
Empty file added.
| @@ -0,0 +1,193 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)TimeZone.java 1.17 97/01/29 | |
| 3 | + * | |
| 4 | + * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved | |
| 5 | + * (C) Copyright IBM Corp. 1996 - All Rights Reserved | |
| 6 | + * | |
| 7 | + * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 8 | + * | |
| 9 | + * The original version of this source code and documentation is copyrighted | |
| 10 | + * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These | |
| 11 | + * materials are provided under terms of a License Agreement between Taligent | |
| 12 | + * and Sun. This technology is protected by multiple US and International | |
| 13 | + * patents. This notice and attribution to Taligent may not be removed. | |
| 14 | + * Taligent is a registered trademark of Taligent, Inc. | |
| 15 | + * | |
| 16 | + * Permission to use, copy, modify, and distribute this software | |
| 17 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 18 | + * fee is hereby granted provided that this copyright notice | |
| 19 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 20 | + * for further important copyright and licensing information. | |
| 21 | + * | |
| 22 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 23 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 24 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 25 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 26 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 27 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | +package java.util; | |
| 32 | + | |
| 33 | +import java.io.Serializable; | |
| 34 | +import java.io.ObjectInputStream; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * <code>TimeZone</code> represents a time zone offset, and also figures out daylight | |
| 38 | + * savings. | |
| 39 | + * | |
| 40 | + * <p> | |
| 41 | + * Typically, you get a <code>TimeZone</code> using <code>getDefault</code> | |
| 42 | + * which creates a <code>TimeZone</code> based on the time zone where the program | |
| 43 | + * is running. For example, for a program running in Japan, <code>getDefault</code> | |
| 44 | + * creates a <code>TimeZone</code> object based on Japanese Standard Time. | |
| 45 | + * | |
| 46 | + * <p> | |
| 47 | + * You can also get a <code>TimeZone</code> using <code>getTimeZone</code> along | |
| 48 | + * with a time zone ID. For instance, the time zone ID for the Pacific | |
| 49 | + * Standard Time zone is "PST". So, you can get a PST <code>TimeZone</code> object | |
| 50 | + * with: | |
| 51 | + * <blockquote> | |
| 52 | + * <pre> | |
| 53 | + * TimeZone tz = TimeZone.getTimeZone("PST"); | |
| 54 | + * </pre> | |
| 55 | + * </blockquote> | |
| 56 | + * You can use <code>getAvailableIDs</code> method to iterate through | |
| 57 | + * all the supported time zone IDs. You can then choose a | |
| 58 | + * supported ID to get a favorite <code>TimeZone</code>. | |
| 59 | + * | |
| 60 | + * @see Calendar | |
| 61 | + * @see GregorianCalendar | |
| 62 | + * @see SimpleTimeZone | |
| 63 | + * @version 1.17 01/29/97 | |
| 64 | + * @author Mark Davis, David Goldsmith, Chen-Lieh Huang | |
| 65 | + */ | |
| 66 | +abstract public class TimeZone implements Serializable, Cloneable { | |
| 67 | + | |
| 68 | + public TimeZone() { | |
| 69 | + throw new NoSuchElementException(); | |
| 70 | + } | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * Gets the time zone offset, for current date, modified in case of | |
| 74 | + * daylight savings. This is the offset to add *to* UTC to get local time. | |
| 75 | + * @param era the era of the given date. | |
| 76 | + * @param year the year in the given date. | |
| 77 | + * @param month the month in the given date. | |
| 78 | + * Month is 0-based. e.g., 0 for January. | |
| 79 | + * @param day the day-in-month of the given date. | |
| 80 | + * @param dayOfWeek the day-of-week of the given date. | |
| 81 | + * @param milliseconds the millis in day. | |
| 82 | + * @return the offset to add *to* GMT to get local time. | |
| 83 | + */ | |
| 84 | + abstract public int getOffset(int era, int year, int month, int day, | |
| 85 | + int dayOfWeek, int milliseconds); | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * Sets the base time zone offset to GMT. | |
| 89 | + * This is the offset to add *to* UTC to get local time. | |
| 90 | + * @param offsetMillis the given base time zone offset to GMT. | |
| 91 | + */ | |
| 92 | + abstract public void setRawOffset(int offsetMillis); | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * Gets unmodified offset, NOT modified in case of daylight savings. | |
| 96 | + * This is the offset to add *to* UTC to get local time. | |
| 97 | + * @return the unmodified offset to add *to* UTC to get local time. | |
| 98 | + */ | |
| 99 | + abstract public int getRawOffset(); | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * Gets the ID of this time zone. | |
| 103 | + * @return the ID of this time zone. | |
| 104 | + */ | |
| 105 | + public String getID() | |
| 106 | + { | |
| 107 | + throw new NoSuchElementException(); | |
| 108 | + } | |
| 109 | + | |
| 110 | + /** | |
| 111 | + * Sets the time zone ID. This does not change any other data in | |
| 112 | + * the time zone object. | |
| 113 | + * @param ID the new time zone ID. | |
| 114 | + */ | |
| 115 | + public void setID(String ID) | |
| 116 | + { | |
| 117 | + throw new NoSuchElementException(); | |
| 118 | + } | |
| 119 | + | |
| 120 | + /** | |
| 121 | + * Queries if this time zone uses Daylight Savings Time. | |
| 122 | + * @return true if this time zone uses Daylight Savings Time, | |
| 123 | + * false, otherwise. | |
| 124 | + */ | |
| 125 | + abstract public boolean useDaylightTime(); | |
| 126 | + | |
| 127 | + /** | |
| 128 | + * Queries if the given date is in Daylight Savings Time in | |
| 129 | + * this time zone. | |
| 130 | + * @param date the given Date. | |
| 131 | + * @return true if the given date is in Daylight Savings Time, | |
| 132 | + * false, otherwise. | |
| 133 | + */ | |
| 134 | + abstract public boolean inDaylightTime(Date date); | |
| 135 | + | |
| 136 | + /** | |
| 137 | + * Gets the TimeZone for the given ID. | |
| 138 | + * @param ID the given ID. | |
| 139 | + * @return a TimeZone. | |
| 140 | + */ | |
| 141 | + public static synchronized TimeZone getTimeZone(String ID) | |
| 142 | + { | |
| 143 | + throw new NoSuchElementException(); | |
| 144 | + } | |
| 145 | + | |
| 146 | + /** | |
| 147 | + * Gets the available IDs according to the given time zone offset. | |
| 148 | + * @param rawOffset the given time zone GMT offset. | |
| 149 | + * @return an array of IDs, where the time zone for that ID has | |
| 150 | + * the specified GMT offset. For example, {"Phoenix", "Denver"}, | |
| 151 | + * since both have GMT-07:00, but differ in daylight savings behavior. | |
| 152 | + */ | |
| 153 | + public static synchronized String[] getAvailableIDs(int rawOffset) { | |
| 154 | + throw new NoSuchElementException(); | |
| 155 | + } | |
| 156 | + | |
| 157 | + /** | |
| 158 | + * Gets all the available IDs supported. | |
| 159 | + * @return an array of IDs. | |
| 160 | + */ | |
| 161 | + public static synchronized String[] getAvailableIDs() { | |
| 162 | + throw new NoSuchElementException(); | |
| 163 | + } | |
| 164 | + | |
| 165 | + /** | |
| 166 | + * Gets the default TimeZone for this host. | |
| 167 | + * @return a default TimeZone. | |
| 168 | + */ | |
| 169 | + public static synchronized TimeZone getDefault() { | |
| 170 | + throw new NoSuchElementException(); | |
| 171 | + } | |
| 172 | + | |
| 173 | + /** | |
| 174 | + * Sets time zone to using the given TimeZone. | |
| 175 | + * @param zone the given time zone. | |
| 176 | + */ | |
| 177 | + public static synchronized void setDefault(TimeZone zone) | |
| 178 | + { | |
| 179 | + throw new NoSuchElementException(); | |
| 180 | + } | |
| 181 | + | |
| 182 | + /** | |
| 183 | + * Overrides Cloneable | |
| 184 | + */ | |
| 185 | + public Object clone() | |
| 186 | + { | |
| 187 | + throw new NoSuchElementException(); | |
| 188 | + } | |
| 189 | + | |
| 190 | + private void readObject(ObjectInputStream s) { | |
| 191 | + throw new NoSuchElementException(); | |
| 192 | + } | |
| 193 | +} | |
| @@ -0,0 +1,65 @@ | ||
| 1 | +/* | |
| 2 | + * @(#)TooManyListenersException.java 1.1 96/10/10 | |
| 3 | + * | |
| 4 | + * Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. | |
| 5 | + * | |
| 6 | + * Permission to use, copy, modify, and distribute this software | |
| 7 | + * and its documentation for NON-COMMERCIAL purposes and without | |
| 8 | + * fee is hereby granted provided that this copyright notice | |
| 9 | + * appears in all copies. Please refer to the file "copyright.html" | |
| 10 | + * for further important copyright and licensing information. | |
| 11 | + * | |
| 12 | + * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF | |
| 13 | + * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | |
| 14 | + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 15 | + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR | |
| 16 | + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
| 17 | + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. | |
| 18 | + */ | |
| 19 | + | |
| 20 | +package java.util; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * <p> | |
| 24 | + * The <code> TooManyListenersException </code> Exception is used as part of | |
| 25 | + * the Java Event model to annotate and implement a unicast special case of | |
| 26 | + * a multicast Event Source. | |
| 27 | + * </p> | |
| 28 | + * <p> | |
| 29 | + * The presence of a <code> throws TooManyListenersException </code> clause | |
| 30 | + * on any given concrete implementation of the normally multicast semantic | |
| 31 | + * <italic> void add < EventListenerType > () </italic> event listener | |
| 32 | + * registration pattern is used to annotate that interface as implementing | |
| 33 | + * a unicast Listener special case, that is, that one and only one Listener | |
| 34 | + * may be registered on the particular event listener source concurrently. | |
| 35 | + * </p> | |
| 36 | + * | |
| 37 | + * @see java.util.EventObject | |
| 38 | + * @see java.util.EventListener | |
| 39 | + * | |
| 40 | + * @version 1.1 96/10/10 | |
| 41 | + * @author Laurence P. G. Cable | |
| 42 | + */ | |
| 43 | + | |
| 44 | +public class TooManyListenersException extends Exception { | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Constructs a TooManyListenersException with no detail message. | |
| 48 | + * A detail message is a String that describes this particular exception. | |
| 49 | + */ | |
| 50 | + | |
| 51 | + public TooManyListenersException() { | |
| 52 | + super(); | |
| 53 | + } | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * Constructs a TooManyListenersException with the specified detail message. | |
| 57 | + * A detail message is a String that describes this particular exception. | |
| 58 | + * @param s the detail message | |
| 59 | + */ | |
| 60 | + | |
| 61 | + public TooManyListenersException(String s) { | |
| 62 | + super(s); | |
| 63 | + } | |
| 64 | +} | |
| 65 | + | |
Empty file added.
| @@ -0,0 +1,88 @@ | ||
| 1 | +<../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + zip\ | |
| 5 | + | |
| 6 | +TARG=\ | |
| 7 | + BitSet.dis\ | |
| 8 | + Calendar.dis\ | |
| 9 | + Date.dis\ | |
| 10 | + Dictionary.dis\ | |
| 11 | + EmptyStackException.dis\ | |
| 12 | + Enumeration.dis\ | |
| 13 | + EventListener.dis\ | |
| 14 | + EventObject.dis\ | |
| 15 | + GregorianCalendar.dis\ | |
| 16 | + Hashtable.dis\ | |
| 17 | + HashtableEntry.dis\ | |
| 18 | + HashtableEnumerator.dis\ | |
| 19 | + ListResourceBundle.dis\ | |
| 20 | + Locale.dis\ | |
| 21 | +# for MissingResourceException.dis\ | |
| 22 | + PyLHKaRk2knKuXdPtclNZ.dis\ | |
| 23 | +# for NoSuchElementException.dis\ | |
| 24 | + FgHgFAyr+lOIx-Hx5tg1g.dis\ | |
| 25 | + Observable.dis\ | |
| 26 | + Observer.dis\ | |
| 27 | + Properties.dis\ | |
| 28 | +# for PropertyResourceBundle.dis\ | |
| 29 | + hXReUGvcTPP+3SdqzAFLN.dis\ | |
| 30 | + Random.dis\ | |
| 31 | + ResourceBundle.dis\ | |
| 32 | + SimpleTimeZone.dis\ | |
| 33 | + Stack.dis\ | |
| 34 | + StringTokenizer.dis\ | |
| 35 | + SystemClassLoader.dis\ | |
| 36 | + TimeZone.dis\ | |
| 37 | +# for TooManyListenersException.dis\ | |
| 38 | + ofB3vewCQyrpHPDk+jZyy.dis\ | |
| 39 | + Vector.dis\ | |
| 40 | + VectorEnumerator.dis\ | |
| 41 | +# Limbo code\ | |
| 42 | + Date_L.dis\ | |
| 43 | + ResourceBundle_L.dis\ | |
| 44 | + | |
| 45 | +MODULES=\ | |
| 46 | + $ROOT/java/module/classloader.m\ | |
| 47 | + $ROOT/java/module/jni.m\ | |
| 48 | + $ROOT/java/module/cast.m\ | |
| 49 | + Date_L.m\ | |
| 50 | + ResourceBundle_L.m\ | |
| 51 | + | |
| 52 | +SYSMODULES=\ | |
| 53 | + draw.m\ | |
| 54 | + hash.m\ | |
| 55 | + keyring.m\ | |
| 56 | + loader.m\ | |
| 57 | + math.m\ | |
| 58 | + string.m\ | |
| 59 | + sys.m\ | |
| 60 | + | |
| 61 | +DISBIN=$ROOT/java/dis/java/java/util | |
| 62 | + | |
| 63 | +<$ROOT/mkfiles/mkjava | |
| 64 | +<$ROOT/mkfiles/mksubdirs | |
| 65 | + | |
| 66 | +HashtableEntry.dis: Hashtable.class | |
| 67 | + j2d HashtableEntry.class | |
| 68 | + | |
| 69 | +HashtableEnumerator.dis: Hashtable.class | |
| 70 | + j2d HashtableEnumerator.class | |
| 71 | + | |
| 72 | +VectorEnumerator.dis: Vector.class | |
| 73 | + j2d VectorEnumerator.class | |
| 74 | + | |
| 75 | +PyLHKaRk2knKuXdPtclNZ.dis: MissingResourceException.class | |
| 76 | + j2d MissingResourceException.class | |
| 77 | + | |
| 78 | +FgHgFAyr+lOIx-Hx5tg1g.dis: NoSuchElementException.class | |
| 79 | + j2d NoSuchElementException.class | |
| 80 | + | |
| 81 | +SystemClassLoader.dis: ResourceBundle.class | |
| 82 | + j2d SystemClassLoader.class | |
| 83 | + | |
| 84 | +hXReUGvcTPP+3SdqzAFLN.dis: PropertyResourceBundle.class | |
| 85 | + j2d PropertyResourceBundle.class | |
| 86 | + | |
| 87 | +ofB3vewCQyrpHPDk+jZyy.dis: TooManyListenersException.class | |
| 88 | + j2d TooManyListenersException.class | |
Empty file added.
| @@ -0,0 +1,51 @@ | ||
| 1 | +implement CRC32_L; | |
| 2 | + | |
| 3 | +# javal v1.4 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +#<< | |
| 28 | + | |
| 29 | +include "CRC32_L.m"; | |
| 30 | + | |
| 31 | +#>> extra post includes here | |
| 32 | + | |
| 33 | +#<< | |
| 34 | + | |
| 35 | +init( jni_p : JNI ) | |
| 36 | +{ | |
| 37 | + # save java native inteface mod instance | |
| 38 | + jni = jni_p; | |
| 39 | + #>>extra initialization here | |
| 40 | + #<< | |
| 41 | +} | |
| 42 | + | |
| 43 | +update_aB_I_I_V( this : ref CRC32_obj, p0 : JArrayB,p1 : int,p2 : int) | |
| 44 | +{#>> | |
| 45 | +}#<< | |
| 46 | + | |
| 47 | +update1_I_V( this : ref CRC32_obj, p0 : int) | |
| 48 | +{#>> | |
| 49 | +}#<< | |
| 50 | + | |
| 51 | + | |
| @@ -0,0 +1,15 @@ | ||
| 1 | +# javal v1.4 generated file: edit with care | |
| 2 | + | |
| 3 | +CRC32_L : module | |
| 4 | +{ | |
| 5 | + CRC32_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + crc : int; | |
| 9 | + }; | |
| 10 | + | |
| 11 | + init : fn( jni_p : JNI ); | |
| 12 | + update_aB_I_I_V : fn( this : ref CRC32_obj, p0 : JArrayB,p1 : int,p2 : int); | |
| 13 | + update1_I_V : fn( this : ref CRC32_obj, p0 : int); | |
| 14 | + | |
| 15 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,77 @@ | ||
| 1 | +implement Inflater_L; | |
| 2 | + | |
| 3 | +# javal v1.4 generated file: edit with care | |
| 4 | + | |
| 5 | +include "jni.m"; | |
| 6 | + jni : JNI; | |
| 7 | + ClassModule, | |
| 8 | + JString, | |
| 9 | + JArray, | |
| 10 | + JArrayI, | |
| 11 | + JArrayC, | |
| 12 | + JArrayB, | |
| 13 | + JArrayS, | |
| 14 | + JArrayJ, | |
| 15 | + JArrayF, | |
| 16 | + JArrayD, | |
| 17 | + JArrayZ, | |
| 18 | + JArrayJObject, | |
| 19 | + JArrayJClass, | |
| 20 | + JArrayJString, | |
| 21 | + JClass, | |
| 22 | + JThread, | |
| 23 | + JObject : import jni; | |
| 24 | + | |
| 25 | +#>> extra pre includes here | |
| 26 | + | |
| 27 | +#<< | |
| 28 | + | |
| 29 | +include "Inflater_L.m"; | |
| 30 | + | |
| 31 | +#>> extra post includes here | |
| 32 | + | |
| 33 | +#<< | |
| 34 | + | |
| 35 | +init( jni_p : JNI ) | |
| 36 | +{ | |
| 37 | + # save java native inteface mod instance | |
| 38 | + jni = jni_p; | |
| 39 | + #>>extra initialization here | |
| 40 | + #<< | |
| 41 | +} | |
| 42 | + | |
| 43 | +inflate_aB_I_I_I( this : ref Inflater_obj, p0 : JArrayB,p1 : int,p2 : int) : int | |
| 44 | +{#>> | |
| 45 | + junk1 := (this, p0); | |
| 46 | + junk2 := (p1, p2); | |
| 47 | + return 0; | |
| 48 | +}#<< | |
| 49 | + | |
| 50 | +getTotalIn_I( this : ref Inflater_obj) : int | |
| 51 | +{#>> | |
| 52 | + junk := this; | |
| 53 | + return 0; | |
| 54 | +}#<< | |
| 55 | + | |
| 56 | +getTotalOut_I( this : ref Inflater_obj) : int | |
| 57 | +{#>> | |
| 58 | + junk := this; | |
| 59 | + return 0; | |
| 60 | +}#<< | |
| 61 | + | |
| 62 | +reset_V( this : ref Inflater_obj) | |
| 63 | +{#>> | |
| 64 | + junk := this; | |
| 65 | +}#<< | |
| 66 | + | |
| 67 | +end_V( this : ref Inflater_obj) | |
| 68 | +{#>> | |
| 69 | + junk := this; | |
| 70 | +}#<< | |
| 71 | + | |
| 72 | +init_Z_V( this : ref Inflater_obj, p0 : int) | |
| 73 | +{#>> | |
| 74 | + junk := (this, p0); | |
| 75 | +}#<< | |
| 76 | + | |
| 77 | + | |
| @@ -0,0 +1,24 @@ | ||
| 1 | +# javal v1.6 generated file: edit with care | |
| 2 | + | |
| 3 | +Inflater_L : module | |
| 4 | +{ | |
| 5 | + Inflater_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + strm : int; | |
| 9 | + buf : JArrayB; | |
| 10 | + off : int; | |
| 11 | + len_j : int; | |
| 12 | + finished : byte; | |
| 13 | + needsDictionary : byte; | |
| 14 | + }; | |
| 15 | + | |
| 16 | + init : fn( jni_p : JNI ); | |
| 17 | + inflate_aB_I_I_I : fn( this : ref Inflater_obj, p0 : JArrayB,p1 : int,p2 : int) : int; | |
| 18 | + getTotalIn_I : fn( this : ref Inflater_obj) : int; | |
| 19 | + getTotalOut_I : fn( this : ref Inflater_obj) : int; | |
| 20 | + reset_V : fn( this : ref Inflater_obj); | |
| 21 | + end_V : fn( this : ref Inflater_obj); | |
| 22 | + init_Z_V : fn( this : ref Inflater_obj, p0 : int); | |
| 23 | + | |
| 24 | +}; | |
Empty file added.
Empty file added.
Empty file added.
Empty file added.
| @@ -0,0 +1,38 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + CRC32.dis\ | |
| 5 | + CheckedInputStream.dis\ | |
| 6 | + CheckedOutputStream.dis\ | |
| 7 | + Checksum.dis\ | |
| 8 | + DataFormatException.dis\ | |
| 9 | + GZIPInputStream.dis\ | |
| 10 | + Inflater.dis\ | |
| 11 | + InflaterInputStream.dis\ | |
| 12 | + ZipConstants.dis\ | |
| 13 | + ZipEntry.dis\ | |
| 14 | + ZipException.dis\ | |
| 15 | + ZipInputStream.dis\ | |
| 16 | +# Limbo code\ | |
| 17 | + CRC32_L.dis\ | |
| 18 | + Inflater_L.dis\ | |
| 19 | + | |
| 20 | +MODULES=\ | |
| 21 | + $ROOT/java/module/classloader.m\ | |
| 22 | + $ROOT/java/module/jni.m\ | |
| 23 | + $ROOT/java/module/cast.m\ | |
| 24 | + CRC32_L.m\ | |
| 25 | + Inflater_L.m\ | |
| 26 | + | |
| 27 | +SYSMODULES=\ | |
| 28 | + draw.m\ | |
| 29 | + hash.m\ | |
| 30 | + keyring.m\ | |
| 31 | + loader.m\ | |
| 32 | + math.m\ | |
| 33 | + string.m\ | |
| 34 | + sys.m\ | |
| 35 | + | |
| 36 | +DISBIN=$ROOT/java/dis/java/java/util/zip | |
| 37 | + | |
| 38 | +<$ROOT/mkfiles/mkjava | |