author | cg |
Tue, 27 Jan 1998 21:03:54 +0000 | |
changeset 277 | 511c3bb153b7 |
parent 274 | 0a9193e3f2be |
child 280 | 274951f1502c |
permissions | -rw-r--r-- |
253 | 1 |
Object subclass:#JavaVM |
2 |
instanceVariableNames:'' |
|
3 |
classVariableNames:'UnhandledJavaExceptionSignal JavaExceptionSignal |
|
4 |
UnimplementedInstructionSignal UnimplementedNativeMethodSignal |
|
5 |
BadMessageSignal InternalErrorSignal CallHandlerSignal |
|
6 |
FullExceptionTrace StackTrace TraceHistory LockTable |
|
277 | 7 |
LockTableAccess LibPath SimulatedLibs LoadedLibs |
8 |
SimulatedNativeLibs LoadedNativeLibs WaitTable WaitTableAccess |
|
9 |
JavaWindowGroup KnownWindows DrawOPTrace WindowOPTrace |
|
10 |
WindowCreationTrace EventTrace ThreadTrace MonitorTrace |
|
11 |
ExceptionTrace InsnCount InsnCounts FileOpenTrace |
|
253 | 12 |
FileOpenConfirmation FileIOTrace OpenFileTable |
13 |
CachedNativeMethodTable ExceptionDebug JavaConsoleStream |
|
14 |
StandardThreadGroup EnteredMonitorsPerProcess JavaClasses |
|
261 | 15 |
DUMMY_LONG_HIGHWORD DUMMY_DOUBLE_HIGHWORD NoAudio' |
253 | 16 |
poolDictionaries:'' |
17 |
category:'Java-Support' |
|
18 |
! |
|
19 |
||
261 | 20 |
!JavaVM class methodsFor:'documentation'! |
21 |
||
22 |
nativeMethods |
|
23 |
" |
|
24 |
list of all native methods as in jdk1.1.3: |
|
25 |
||
26 |
X - implemented |
|
27 |
x - implemented with limited functionality |
|
28 |
o - implemented as dummy (no functionality) |
|
29 |
||
30 |
X (Math::double sin (double)) |
|
31 |
X (Math::double cos (double)) |
|
32 |
(Math::double tan (double)) |
|
33 |
(Math::double asin (double)) |
|
34 |
(Math::double acos (double)) |
|
35 |
(Math::double atan (double)) |
|
36 |
(Math::double exp (double)) |
|
37 |
X (Math::double log (double)) |
|
38 |
X (Math::double sqrt (double)) |
|
39 |
(Math::double IEEEremainder (double double)) |
|
40 |
X (Math::double ceil (double)) |
|
41 |
X (Math::double floor (double)) |
|
42 |
(Math::double rint (double)) |
|
43 |
(Math::double atan2 (double double)) |
|
44 |
X (Math::double pow (double double)) |
|
45 |
||
46 |
X (Class::java.lang.Class forName (java.lang.String)) |
|
47 |
X (Class::java.lang.Object newInstance ()) |
|
48 |
(Class::boolean isInstance (java.lang.Object)) |
|
49 |
(Class::boolean isAssignableFrom (java.lang.Class)) |
|
50 |
X (Class::boolean isInterface ()) |
|
51 |
(Class::boolean isArray ()) |
|
52 |
(Class::boolean isPrimitive ()) |
|
53 |
X (Class::java.lang.String getName ()) |
|
54 |
X (Class::java.lang.ClassLoader getClassLoader ()) |
|
55 |
X (Class::java.lang.Class getSuperclass ()) |
|
56 |
(Class::java.lang.Class[] getInterfaces ()) |
|
57 |
(Class::java.lang.Class getComponentType ()) |
|
58 |
(Class::int getModifiers ()) |
|
59 |
(Class::java.lang.Object[] getSigners ()) |
|
60 |
(Class::void setSigners (java.lang.Object[])) |
|
61 |
X (Class::java.lang.Class getPrimitiveClass (java.lang.String)) |
|
62 |
(Class::java.lang.reflect.Field[] getFields0 (int)) |
|
63 |
(Class::java.lang.reflect.Method[] getMethods0 (int)) |
|
64 |
(Class::java.lang.reflect.Constructor[] getConstructors0 (int)) |
|
65 |
(Class::java.lang.reflect.Field getField0 (java.lang.String int)) |
|
66 |
(Class::java.lang.reflect.Method getMethod0 (java.lang.String java.lang.Class[] int)) |
|
67 |
(Class::java.lang.reflect.Constructor getConstructor0 (java.lang.Class[] int)) |
|
68 |
||
69 |
X (InetAddressImpl::java.lang.String getLocalHostName ()) |
|
70 |
X (InetAddressImpl::void makeAnyLocalAddress (java.net.InetAddress)) |
|
71 |
X (InetAddressImpl::byte[][] lookupAllHostAddr (java.lang.String)) |
|
72 |
(InetAddressImpl::java.lang.String getHostByAddr (int)) |
|
73 |
X (InetAddressImpl::int getInetFamily ()) |
|
74 |
||
75 |
X (ResourceBundle::java.lang.Class[] getClassContext ()) |
|
76 |
||
77 |
X (System::void setIn0 (java.io.InputStream)) |
|
78 |
X (System::void setOut0 (java.io.PrintStream)) |
|
79 |
X (System::void setErr0 (java.io.PrintStream)) |
|
80 |
X (System::long currentTimeMillis ()) |
|
81 |
X (System::void arraycopy (java.lang.Object int java.lang.Object int int)) |
|
82 |
(System::int identityHashCode (java.lang.Object)) |
|
83 |
X (System::java.util.Properties initProperties (java.util.Properties)) |
|
84 |
||
85 |
X (Thread::java.lang.Thread currentThread ()) |
|
86 |
X (Thread::void yield ()) |
|
87 |
X (Thread::void sleep (long)) |
|
88 |
X (Thread::void start ()) |
|
89 |
X (Thread::boolean isInterrupted (boolean)) |
|
90 |
X (Thread::boolean isAlive ()) |
|
91 |
(Thread::int countStackFrames ()) |
|
92 |
X (Thread::void setPriority0 (int)) |
|
93 |
X (Thread::void stop0 (java.lang.Object)) |
|
94 |
X (Thread::void suspend0 ()) |
|
95 |
X (Thread::void resume0 ()) |
|
96 |
(Thread::void interrupt0 ()) |
|
97 |
||
98 |
(String::java.lang.String intern ()) |
|
99 |
||
100 |
X (Float::int floatToIntBits (float)) |
|
101 |
X (Float::float intBitsToFloat (int)) |
|
102 |
||
103 |
(ObjectStreamClass::int getClassAccess (java.lang.Class)) |
|
104 |
(ObjectStreamClass::java.lang.String[] getMethodSignatures (java.lang.Class)) |
|
105 |
(ObjectStreamClass::int getMethodAccess (java.lang.Class java.lang.String)) |
|
106 |
(ObjectStreamClass::java.lang.String[] getFieldSignatures (java.lang.Class)) |
|
107 |
(ObjectStreamClass::int getFieldAccess (java.lang.Class java.lang.String)) |
|
108 |
(ObjectStreamClass::java.io.ObjectStreamField[] getFields0 (java.lang.Class)) |
|
109 |
(ObjectStreamClass::long getSerialVersionUID (java.lang.Class)) |
|
110 |
(ObjectStreamClass::boolean hasWriteObject (java.lang.Class)) |
|
111 |
(ObjectInputStream::java.lang.Class loadClass0 (java.lang.Class java.lang.String)) |
|
112 |
(ObjectInputStream::void inputClassFields (java.lang.Object java.lang.Class int[])) |
|
113 |
(ObjectInputStream::java.lang.Object allocateNewObject (java.lang.Class java.lang.Class)) |
|
114 |
(ObjectInputStream::java.lang.Object allocateNewArray (java.lang.Class int)) |
|
115 |
(ObjectInputStream::boolean invokeObjectReader (java.lang.Object java.lang.Class)) |
|
116 |
||
117 |
(SecurityManager::java.lang.Class[] getClassContext ()) |
|
118 |
X (SecurityManager::java.lang.ClassLoader currentClassLoader ()) |
|
119 |
(SecurityManager::int classDepth (java.lang.String)) |
|
120 |
X (SecurityManager::int classLoaderDepth ()) |
|
121 |
(SecurityManager::java.lang.Class currentLoadedClass0 ()) |
|
122 |
||
123 |
X (ClassLoader::void init ()) |
|
124 |
X (ClassLoader::java.lang.Class defineClass0 (java.lang.String byte[] int int)) |
|
125 |
X (ClassLoader::void resolveClass0 (java.lang.Class)) |
|
126 |
X (ClassLoader::java.lang.Class findSystemClass0 (java.lang.String)) |
|
127 |
X (ClassLoader::java.io.InputStream getSystemResourceAsStream0 (java.lang.String)) |
|
128 |
(ClassLoader::java.lang.String getSystemResourceAsName0 (java.lang.String)) |
|
129 |
||
130 |
(FileDescriptor::boolean valid ()) |
|
131 |
(FileDescriptor::void sync ()) |
|
132 |
X (FileDescriptor::java.io.FileDescriptor initSystemFD (java.io.FileDescriptor int)) |
|
133 |
||
134 |
X (Object::java.lang.Class getClass ()) |
|
135 |
X (Object::int hashCode ()) |
|
136 |
X (Object::java.lang.Object clone ()) |
|
137 |
X (Object::void notify ()) |
|
138 |
X (Object::void notifyAll ()) |
|
139 |
X (Object::void wait (long)) |
|
140 |
||
141 |
X (FileOutputStream::void open (java.lang.String)) |
|
142 |
(FileOutputStream::void openAppend (java.lang.String)) |
|
143 |
X (FileOutputStream::void write (int)) |
|
144 |
X (FileOutputStream::void writeBytes (byte[] int int)) |
|
145 |
X (FileOutputStream::void close ()) |
|
146 |
X (FileInputStream::void open (java.lang.String)) |
|
147 |
X (FileInputStream::int read ()) |
|
148 |
X (FileInputStream::int readBytes (byte[] int int)) |
|
149 |
(FileInputStream::long skip (long)) |
|
150 |
X (FileInputStream::int available ()) |
|
151 |
X (FileInputStream::void close ()) |
|
152 |
||
153 |
(VM::int getState ()) |
|
154 |
(VM::boolean threadsSuspended ()) |
|
155 |
(VM::void unsuspendThreads ()) |
|
156 |
(VM::void unsuspendSomeThreads ()) |
|
157 |
||
158 |
X (File::boolean exists0 ()) |
|
159 |
(File::boolean canWrite0 ()) |
|
160 |
X (File::boolean canRead0 ()) |
|
161 |
X (File::boolean isFile0 ()) |
|
162 |
X (File::boolean isDirectory0 ()) |
|
163 |
(File::long lastModified0 ()) |
|
164 |
X (File::long length0 ()) |
|
165 |
(File::boolean mkdir0 ()) |
|
166 |
(File::boolean renameTo0 (java.io.File)) |
|
167 |
(File::boolean delete0 ()) |
|
168 |
(File::boolean rmdir0 ()) |
|
169 |
X (File::java.lang.String[] list0 ()) |
|
170 |
(File::java.lang.String canonPath (java.lang.String)) |
|
171 |
X (File::boolean isAbsolute ()) |
|
172 |
||
173 |
(ObjectOutputStream::void outputClassFields (java.lang.Object java.lang.Class int[])) |
|
174 |
(ObjectOutputStream::boolean invokeObjectWriter (java.lang.Object java.lang.Class)) |
|
175 |
||
176 |
X (Throwable::void printStackTrace0 (java.lang.Object)) |
|
177 |
X (Throwable::java.lang.Throwable fillInStackTrace ()) |
|
178 |
||
179 |
X (Double::long doubleToLongBits (double)) |
|
180 |
X (Double::double longBitsToDouble (long)) |
|
181 |
X (Double::double valueOf0 (java.lang.String)) |
|
182 |
||
183 |
X (Runtime::void exitInternal (int)) |
|
184 |
(Runtime::void runFinalizersOnExit0 (boolean)) |
|
185 |
o (Runtime::java.lang.Process execInternal (java.lang.String[] java.lang.String[])) |
|
186 |
X (Runtime::long freeMemory ()) |
|
187 |
X (Runtime::long totalMemory ()) |
|
188 |
X (Runtime::void gc ()) |
|
189 |
(Runtime::void runFinalization ()) |
|
190 |
(Runtime::void traceInstructions (boolean)) |
|
191 |
(Runtime::void traceMethodCalls (boolean)) |
|
192 |
X (Runtime::java.lang.String initializeLinkerInternal ()) |
|
193 |
X (Runtime::java.lang.String buildLibName (java.lang.String java.lang.String)) |
|
194 |
X (Runtime::int loadFileInternal (java.lang.String)) |
|
195 |
||
196 |
(WDrawingSurfaceInfo::int lock ()) |
|
197 |
(WDrawingSurfaceInfo::void unlock ()) |
|
198 |
(WDrawingSurfaceInfo::int getHWnd ()) |
|
199 |
(WDrawingSurfaceInfo::int getHBitmap ()) |
|
200 |
(WDrawingSurfaceInfo::int getPBits ()) |
|
201 |
(WDrawingSurfaceInfo::int getHDC ()) |
|
202 |
(WDrawingSurfaceInfo::int getDepth ()) |
|
203 |
(WDrawingSurfaceInfo::int getHPalette ()) |
|
204 |
||
205 |
X (WDefaultFontCharset::boolean canConvert (char)) |
|
206 |
||
207 |
(ColorModel::void deletepData ()) |
|
208 |
X (WToolkit::void init (java.lang.Thread)) |
|
209 |
X (WToolkit::void eventLoop ()) |
|
210 |
(WToolkit::java.awt.image.ColorModel makeColorModel ()) |
|
211 |
(WToolkit::int getScreenResolution ()) |
|
212 |
X (WToolkit::int getScreenWidth ()) |
|
213 |
X (WToolkit::int getScreenHeight ()) |
|
214 |
(WToolkit::void sync ()) |
|
215 |
(WToolkit::void beep ()) |
|
216 |
X (WToolkit::void loadSystemColors (int[])) |
|
217 |
||
218 |
(WPrintJob::void end ()) |
|
219 |
||
220 |
X (WDialogPeer::void create (sun.awt.windows.WComponentPeer)) |
|
221 |
X (WDialogPeer::void _show ()) |
|
222 |
X (WDialogPeer::void _hide ()) |
|
223 |
||
224 |
(WWindowPeer::void toFront ()) |
|
225 |
(WWindowPeer::void toBack ()) |
|
226 |
(WWindowPeer::void _setTitle (java.lang.String)) |
|
227 |
(WWindowPeer::void _setResizable (boolean)) |
|
228 |
(WWindowPeer::void create (sun.awt.windows.WComponentPeer)) |
|
229 |
(WWindowPeer::void updateInsets (java.awt.Insets)) |
|
230 |
(WWindowPeer::java.awt.Component getContainerElement (java.awt.Container int)) |
|
231 |
||
232 |
X (WCanvasPeer::void create (sun.awt.windows.WComponentPeer)) |
|
233 |
||
234 |
X (WTextAreaPeer::void create (sun.awt.windows.WComponentPeer)) |
|
235 |
X (WTextAreaPeer::void insertText (java.lang.String int)) |
|
236 |
(WTextAreaPeer::void replaceText (java.lang.String int int)) |
|
237 |
||
238 |
X (WTextComponentPeer::java.lang.String getText ()) |
|
239 |
X (WTextComponentPeer::void setText (java.lang.String)) |
|
240 |
X (WTextComponentPeer::int getSelectionStart ()) |
|
241 |
X (WTextComponentPeer::int getSelectionEnd ()) |
|
242 |
X (WTextComponentPeer::void select (int int)) |
|
243 |
X (WTextComponentPeer::void enableEditing (boolean)) |
|
244 |
||
245 |
X (WComponentPeer::void show ()) |
|
246 |
X (WComponentPeer::void hide ()) |
|
247 |
X (WComponentPeer::void enable ()) |
|
248 |
X (WComponentPeer::void disable ()) |
|
249 |
(WComponentPeer::java.awt.Point getLocationOnScreen ()) |
|
250 |
X (WComponentPeer::void reshape (int int int int)) |
|
251 |
o (WComponentPeer::void handleEvent (java.awt.AWTEvent)) |
|
252 |
o (WComponentPeer::void _dispose ()) |
|
253 |
X (WComponentPeer::void _setForeground (int)) |
|
254 |
X (WComponentPeer::void _setBackground (int)) |
|
255 |
o (WComponentPeer::void setFont (java.awt.Font)) |
|
256 |
o (WComponentPeer::void requestFocus ()) |
|
257 |
o (WComponentPeer::void setCursor (java.awt.Cursor)) |
|
258 |
o (WComponentPeer::void start ()) |
|
259 |
(WComponentPeer::void _beginValidate ()) |
|
260 |
(WComponentPeer::void endValidate ()) |
|
261 |
o (WComponentPeer::void setZOrderPosition (sun.awt.windows.WComponentPeer)) |
|
262 |
||
263 |
X (WFramePeer::void setMenuBar0 (sun.awt.windows.WMenuBarPeer)) |
|
264 |
X (WFramePeer::void create (sun.awt.windows.WComponentPeer)) |
|
265 |
(WFramePeer::void _setIconImage (sun.awt.image.ImageRepresentation)) |
|
266 |
||
267 |
o (WFontMetrics::boolean needsConversion (java.awt.Font sun.awt.FontDescriptor)) |
|
268 |
o (WFontMetrics::int getMFCharSegmentWidth (java.awt.Font sun.awt.FontDescriptor boolean char[] int int byte[] int)) |
|
269 |
(WFontMetrics::int bytesWidth (byte[] int int)) |
|
270 |
(WFontMetrics::void init ()) |
|
271 |
||
272 |
o (WChoicePeer::void select (int)) |
|
273 |
o (WChoicePeer::void remove (int)) |
|
274 |
o (WChoicePeer::void addItem (java.lang.String int)) |
|
275 |
X (WChoicePeer::void reshape (int int int int)) |
|
276 |
X (WChoicePeer::void create (sun.awt.windows.WComponentPeer)) |
|
277 |
||
278 |
X (WLabelPeer::void setText (java.lang.String)) |
|
279 |
o (WLabelPeer::void setAlignment (int)) |
|
280 |
X (WLabelPeer::void create (sun.awt.windows.WComponentPeer)) |
|
281 |
||
282 |
X (WMenuItemPeer::void _setLabel (java.lang.String)) |
|
283 |
X (WMenuItemPeer::void create (sun.awt.windows.WMenuPeer)) |
|
284 |
X (WMenuItemPeer::void enable (boolean)) |
|
285 |
(WMenuItemPeer::void _dispose ()) |
|
286 |
(WMenuPeer::void addSeparator ()) |
|
287 |
(WMenuPeer::void delItem (int)) |
|
288 |
X (WMenuPeer::void createMenu (sun.awt.windows.WMenuBarPeer)) |
|
289 |
(WMenuPeer::void createSubMenu (sun.awt.windows.WMenuPeer)) |
|
290 |
||
291 |
(WPopupMenuPeer::void createMenu (sun.awt.windows.WComponentPeer)) |
|
292 |
(WPopupMenuPeer::void _show (java.awt.Event)) |
|
293 |
(WMenuBarPeer::void addMenu (java.awt.Menu)) |
|
294 |
(WMenuBarPeer::void delMenu (int)) |
|
295 |
X (WMenuBarPeer::void create (sun.awt.windows.WFramePeer)) |
|
296 |
||
297 |
(WCheckboxMenuItemPeer::void setState (boolean)) |
|
298 |
||
299 |
X (WFileDialogPeer::void show ()) |
|
300 |
||
301 |
X (WCheckboxPeer::void setState (boolean)) |
|
302 |
X (WCheckboxPeer::void setCheckboxGroup (java.awt.CheckboxGroup)) |
|
303 |
(WCheckboxPeer::void setLabel (java.lang.String)) |
|
304 |
X (WCheckboxPeer::void create (sun.awt.windows.WComponentPeer)) |
|
305 |
||
306 |
X (WClipboard::void init ()) |
|
307 |
(WClipboard::void setClipboardText (java.awt.datatransfer.StringSelection)) |
|
308 |
(WClipboard::java.lang.String getClipboardText ()) |
|
309 |
||
310 |
(WListPeer::void addItem (java.lang.String int)) |
|
311 |
(WListPeer::void delItems (int int)) |
|
312 |
(WListPeer::void select (int)) |
|
313 |
(WListPeer::void deselect (int)) |
|
314 |
(WListPeer::void makeVisible (int)) |
|
315 |
(WListPeer::void setMultipleSelections (boolean)) |
|
316 |
(WListPeer::void create (sun.awt.windows.WComponentPeer)) |
|
317 |
(WListPeer::boolean isSelected (int)) |
|
318 |
||
319 |
o (WScrollbarPeer::void _setValues (int int int int)) |
|
320 |
(WScrollbarPeer::void setLineIncrement (int)) |
|
321 |
(WScrollbarPeer::void setPageIncrement (int)) |
|
322 |
o (WScrollbarPeer::void create (sun.awt.windows.WComponentPeer)) |
|
323 |
||
324 |
o (ImageRepresentation::void offscreenInit (java.awt.Color)) |
|
325 |
x (ImageRepresentation::boolean setBytePixels (int int int int java.awt.image.ColorModel byte[] int int)) |
|
326 |
(ImageRepresentation::boolean setIntPixels (int int int int java.awt.image.ColorModel int[] int int)) |
|
327 |
x (ImageRepresentation::boolean finish (boolean)) |
|
328 |
X (ImageRepresentation::void imageDraw (java.awt.Graphics int int java.awt.Color)) |
|
329 |
x (ImageRepresentation::void imageStretch (java.awt.Graphics int int int int int int int int java.awt.Color)) |
|
330 |
x (ImageRepresentation::void disposeImage ()) |
|
331 |
||
332 |
X (WTextFieldPeer::void create (sun.awt.windows.WComponentPeer)) |
|
333 |
(WTextFieldPeer::void setEchoCharacter (char)) |
|
334 |
||
335 |
(WScrollPanePeer::void create (sun.awt.windows.WComponentPeer)) |
|
336 |
(WScrollPanePeer::int getOffset (int)) |
|
337 |
(WScrollPanePeer::void setInsets ()) |
|
338 |
(WScrollPanePeer::void setScrollPosition (int int)) |
|
339 |
(WScrollPanePeer::int _getHScrollbarHeight ()) |
|
340 |
(WScrollPanePeer::int _getVScrollbarWidth ()) |
|
341 |
(WScrollPanePeer::void setSpans (int int int int)) |
|
342 |
(WScrollPanePeer::java.awt.Component getScrollChild ()) |
|
343 |
||
344 |
(WEmbeddedFramePeer::void create (sun.awt.windows.WComponentPeer)) |
|
345 |
(WButtonPeer::void setLabel (java.lang.String)) |
|
346 |
X (WButtonPeer::void create (sun.awt.windows.WComponentPeer)) |
|
347 |
||
348 |
x (WColor::java.awt.Color getDefaultColor (int)) |
|
349 |
||
350 |
x (GifImageDecoder::boolean parseImage (int int int int boolean int byte[] byte[] java.awt.image.IndexColorModel)) |
|
351 |
||
352 |
x (WGraphics::void createFromComponent (sun.awt.windows.WComponentPeer)) |
|
353 |
x (WGraphics::void createFromGraphics (sun.awt.windows.WGraphics)) |
|
354 |
(WGraphics::void createFromPrintJob (sun.awt.windows.WPrintJob)) |
|
355 |
(WGraphics::void createFromHDC (int)) |
|
356 |
x (WGraphics::void imageCreate (sun.awt.image.ImageRepresentation)) |
|
357 |
x (WGraphics::void pSetFont (java.awt.Font)) |
|
358 |
X (WGraphics::void pSetForeground (int)) |
|
359 |
(WGraphics::void _dispose ()) |
|
360 |
x (WGraphics::void dispose ()) |
|
361 |
x (WGraphics::void setPaintMode ()) |
|
362 |
(WGraphics::void setXORMode (java.awt.Color)) |
|
363 |
o (WGraphics::java.awt.Rectangle getClipBounds ()) |
|
364 |
o (WGraphics::void changeClip (int int int int boolean)) |
|
365 |
(WGraphics::void removeClip ()) |
|
366 |
X (WGraphics::void clearRect (int int int int)) |
|
367 |
X (WGraphics::void fillRect (int int int int)) |
|
368 |
X (WGraphics::void drawRect (int int int int)) |
|
369 |
(WGraphics::void drawSFChars (char[] int int int int)) |
|
370 |
x (WGraphics::int drawMFCharsSegment (java.awt.Font sun.awt.FontDescriptor char[] int int int int)) |
|
371 |
(WGraphics::int drawMFCharsConvertedSegment (java.awt.Font sun.awt.FontDescriptor byte[] int int int)) |
|
372 |
(WGraphics::void drawBytes (byte[] int int int int)) |
|
373 |
X (WGraphics::void drawLine (int int int int)) |
|
374 |
(WGraphics::void copyArea (int int int int int int)) |
|
375 |
o (WGraphics::void drawRoundRect (int int int int int int)) |
|
376 |
o (WGraphics::void fillRoundRect (int int int int int int)) |
|
377 |
X (WGraphics::void drawPolygon (int[] int[] int)) |
|
378 |
(WGraphics::void drawPolyline (int[] int[] int)) |
|
379 |
X (WGraphics::void fillPolygon (int[] int[] int)) |
|
380 |
x (WGraphics::void drawOval (int int int int)) |
|
381 |
x (WGraphics::void fillOval (int int int int)) |
|
382 |
x (WGraphics::void drawArc (int int int int int int)) |
|
383 |
x (WGraphics::void fillArc (int int int int int int)) |
|
384 |
(WGraphics::void print (sun.awt.windows.WComponentPeer)) |
|
385 |
(WGraphics::void close (sun.awt.windows.WPrintJob)) |
|
386 |
(JPEGImageDecoder::void readImage (java.io.InputStream byte[])) |
|
387 |
(OffScreenImageSource::void sendPixels ()) |
|
388 |
" |
|
389 |
||
390 |
! ! |
|
253 | 391 |
|
392 |
!JavaVM class methodsFor:'initialization'! |
|
393 |
||
394 |
deinitialize |
|
395 |
|table| |
|
396 |
||
397 |
StandardThreadGroup := nil. |
|
398 |
self releaseAllMonitors. |
|
399 |
||
400 |
LockTable := nil. |
|
401 |
WaitTable := nil. |
|
402 |
WaitTableAccess := nil. |
|
403 |
JavaWindowGroup := nil. |
|
404 |
KnownWindows := nil. |
|
405 |
OpenFileTable := nil. |
|
406 |
EnteredMonitorsPerProcess := nil. |
|
407 |
JavaClasses := nil. |
|
408 |
||
409 |
" |
|
410 |
JavaVM deinitialize |
|
411 |
" |
|
412 |
||
413 |
"Modified: / 3.1.1998 / 21:25:27 / cg" |
|
414 |
"Created: / 3.1.1998 / 21:28:14 / cg" |
|
415 |
! |
|
416 |
||
417 |
initialize |
|
418 |
|table| |
|
419 |
||
420 |
DUMMY_LONG_HIGHWORD := 1. |
|
421 |
DUMMY_DOUBLE_HIGHWORD := 2. |
|
422 |
||
423 |
StandardThreadGroup := nil. |
|
261 | 424 |
NoAudio := true. |
262 | 425 |
"/ NoAudio := false. |
253 | 426 |
|
427 |
JavaConsoleStream := Transcript. |
|
428 |
||
429 |
FullExceptionTrace := StackTrace := false. |
|
430 |
WindowOPTrace := DrawOPTrace := EventTrace := ThreadTrace := false. |
|
431 |
MonitorTrace := ExceptionTrace := FileOpenTrace := FileIOTrace := false. |
|
432 |
ExceptionDebug := false. |
|
433 |
WindowCreationTrace := false. |
|
434 |
||
435 |
FileOpenConfirmation := true. |
|
436 |
||
255 | 437 |
"/ WindowOPTrace := true. |
438 |
"/ MonitorTrace := true. |
|
439 |
"/ ThreadTrace := true. |
|
253 | 440 |
|
441 |
UnhandledJavaExceptionSignal := (Signal new) mayProceed:false. |
|
442 |
UnhandledJavaExceptionSignal nameClass:self message:#unhandledJavaExceptionSignal. |
|
443 |
UnhandledJavaExceptionSignal notifierString:'unhandled java exception'. |
|
444 |
||
445 |
JavaExceptionSignal := (Signal new) mayProceed:false. |
|
446 |
JavaExceptionSignal nameClass:self message:#javaExceptionSignal. |
|
447 |
JavaExceptionSignal notifierString:'java exception'. |
|
448 |
||
449 |
UnimplementedInstructionSignal := (Signal new) mayProceed:false. |
|
450 |
UnimplementedInstructionSignal nameClass:self message:#unimplementedInstructionSignal. |
|
451 |
UnimplementedInstructionSignal notifierString:'unimplemented instruction'. |
|
452 |
||
453 |
UnimplementedNativeMethodSignal := (Signal new) mayProceed:false. |
|
454 |
UnimplementedNativeMethodSignal nameClass:self message:#unimplementedNativeMethodSignal. |
|
455 |
UnimplementedNativeMethodSignal notifierString:'unimplemented native method'. |
|
456 |
||
457 |
BadMessageSignal := (Signal new) mayProceed:false. |
|
458 |
BadMessageSignal nameClass:self message:#badMessageSignal. |
|
459 |
BadMessageSignal notifierString:'invalid message to JAVA object'. |
|
460 |
||
461 |
InternalErrorSignal := (Signal new) mayProceed:false. |
|
462 |
InternalErrorSignal nameClass:self message:#internalErrorSignal. |
|
463 |
InternalErrorSignal notifierString:'internal error'. |
|
464 |
||
465 |
CallHandlerSignal := (Signal new) mayProceed:false. |
|
466 |
CallHandlerSignal nameClass:self message:#callHandlerSignal. |
|
467 |
CallHandlerSignal notifierString:'internal signal'. |
|
468 |
||
469 |
" |
|
470 |
JavaVM initialize |
|
471 |
" |
|
472 |
||
473 |
"Created: / 2.1.1998 / 18:02:34 / cg" |
|
262 | 474 |
"Modified: / 17.1.1998 / 13:21:41 / cg" |
253 | 475 |
! |
476 |
||
477 |
initializeBaseClasses |
|
478 |
"load req'd base classes" |
|
479 |
||
480 |
Java classForName:'java.lang.Object'. |
|
481 |
Java classForName:'java.lang.Class'. |
|
482 |
Java classForName:'java.lang.String'. |
|
483 |
Java classForName:'java.lang.System'. |
|
484 |
||
485 |
" |
|
486 |
self initializeBaseClasses |
|
487 |
" |
|
488 |
||
489 |
"Created: / 3.1.1998 / 21:13:28 / cg" |
|
490 |
! |
|
491 |
||
492 |
initializeOpenFileTable |
|
493 |
OpenFileTable := OrderedCollection |
|
261 | 494 |
with:Stdin |
495 |
with:(JavaConsoleStream ? Stdout) |
|
496 |
with:(JavaConsoleStream ? Stderr). |
|
253 | 497 |
|
498 |
" |
|
499 |
JavaVM initializeOpenFileTable |
|
500 |
" |
|
501 |
||
502 |
"Modified: / 6.8.1997 / 00:40:19 / cg" |
|
503 |
"Created: / 2.1.1998 / 18:04:32 / cg" |
|
504 |
! |
|
505 |
||
506 |
initializePrimitiveClasses |
|
507 |
JavaClasses isNil ifTrue:[ |
|
261 | 508 |
JavaClasses := Dictionary new. |
253 | 509 |
]. |
510 |
||
511 |
#( |
|
261 | 512 |
('byte' 'B' 1) |
513 |
('short' 'S' 2) |
|
514 |
('int' 'I' 4) |
|
515 |
('long' 'J' 8) |
|
516 |
('boolean' 'Z' 1) |
|
517 |
('char' 'C' 2) |
|
518 |
('float' 'F' 4) |
|
519 |
('double' 'D' 8) |
|
520 |
('void' 'V' 0) |
|
253 | 521 |
) triplesDo:[:nm :sig :len | |
261 | 522 |
|stClass jClass| |
523 |
||
524 |
"/ |
|
525 |
"/ create a javaClass for it. |
|
526 |
"/ |
|
527 |
jClass := (Java at:'java.lang.Class') new. |
|
253 | 528 |
"/ stClass := Class new. |
529 |
"/ stClass setName:('JavaBase_' , nm) asSymbol. |
|
530 |
"/ JavaClasses at:stClass put:jClass. |
|
531 |
"/ JavaClasses at:jClass put:stClass. |
|
532 |
||
261 | 533 |
JavaClasses at:nm put:jClass |
253 | 534 |
]. |
535 |
||
536 |
" |
|
537 |
self initializePrimitiveClasses |
|
538 |
" |
|
539 |
||
540 |
"Modified: / 4.1.1998 / 00:56:05 / cg" |
|
541 |
! |
|
542 |
||
543 |
initializeSimulatedLibs |
|
277 | 544 |
"return a collection of native libs which are considered |
545 |
being already loaded. (used with jdk < 1.2)" |
|
546 |
||
253 | 547 |
LibPath := #('__builtIn__' '/usr/local/lib' '/usr/local/lib/java'). |
548 |
SimulatedLibs := #('__builtIn__/net' |
|
277 | 549 |
'__builtIn__/awt' |
550 |
'__builtIn__/tawt' |
|
551 |
'__builtIn__/winawt' |
|
552 |
'__builtIn__/jpeg' |
|
553 |
'__builtIn__/mmedia' |
|
554 |
'__builtIn__/zip' |
|
555 |
'__builtIn__/math' |
|
556 |
). |
|
253 | 557 |
|
558 |
"Created: / 4.1.1998 / 19:05:03 / cg" |
|
277 | 559 |
"Modified: / 27.1.1998 / 18:43:03 / cg" |
560 |
! |
|
561 |
||
562 |
initializeSimulatedNativeLibs |
|
563 |
"return a collection of native libs which are considered |
|
564 |
being already loaded (used with jdk >= 1.2)" |
|
565 |
||
566 |
SimulatedNativeLibs := #( |
|
567 |
'/libawt.so' |
|
568 |
). |
|
569 |
||
570 |
" |
|
571 |
self initializeSimulatedNativeLibs |
|
572 |
" |
|
573 |
||
574 |
"Modified: / 27.1.1998 / 18:43:10 / cg" |
|
253 | 575 |
! |
576 |
||
577 |
initializeSystemPropertiesInto:props |
|
578 |
|cpu os| |
|
579 |
||
580 |
"/ use JAVA compatible cpu-name |
|
581 |
cpu := OperatingSystem getCPUType. |
|
582 |
cpu = 'i386' ifTrue:[ |
|
261 | 583 |
cpu := 'ix86' |
253 | 584 |
]. |
585 |
os := OperatingSystem getOSType. |
|
586 |
os := os asUppercaseFirst. |
|
587 |
||
588 |
props at:'java.version' put:'1'. |
|
589 |
props at:'java.vendor' put:'eXept Software AG'. |
|
590 |
props at:'java.vendor.url' put:'http:://exept.de'. |
|
591 |
props at:'java.home' put:(self defaultJAVAHome). |
|
592 |
props at:'java.class.version' put:'1'. |
|
593 |
props at:'java.class.path' put:(self defaultCLASSPATH). |
|
594 |
props at:'os.name' put:os. |
|
595 |
props at:'os.arch' put:cpu. |
|
596 |
props at:'os.version' put:'1'. |
|
597 |
props at:'file.separator' put:(Filename separator asString). |
|
598 |
props at:'path.separator' put:':'. |
|
599 |
props at:'line.separator' put:(Character cr asString). |
|
600 |
props at:'user.name' put:(OperatingSystem getLoginName). |
|
601 |
props at:'user.home' put:(OperatingSystem getHomeDirectory). |
|
602 |
props at:'user.dir' put:(Filename currentDirectory pathName). |
|
603 |
||
604 |
props at:'awt.toolkit' put:(self defaultWindowingToolKit). |
|
605 |
||
606 |
props at:'jws.home' put:(self defaultJWSHome). |
|
607 |
props at:'hotjava.home' put:(self defaultHotJavaHome). |
|
608 |
||
609 |
"/ undocumented ? |
|
255 | 610 |
props at:'file.encoding.pkg' put:'sun.io'. |
253 | 611 |
|
612 |
"/ suppress copyright view in appletViewer ... |
|
613 |
props at:'appletviewer.version' put:'1.1'. |
|
614 |
||
615 |
^ props |
|
616 |
||
617 |
"Created: / 3.1.1998 / 14:26:39 / cg" |
|
255 | 618 |
"Modified: / 9.1.1998 / 03:06:46 / cg" |
253 | 619 |
! |
620 |
||
621 |
initializeVM |
|
255 | 622 |
KnownWindows := nil. |
623 |
JavaWindowGroup := nil. |
|
624 |
||
261 | 625 |
JavaConsoleStream := Transcript. |
626 |
||
255 | 627 |
self terminateAllThreads. |
628 |
||
629 |
Java initAllStaticFields. |
|
630 |
Java markAllClassesUninitialized. |
|
631 |
||
253 | 632 |
self releaseAllMonitors. |
261 | 633 |
self releaseAllWindows. |
634 |
self releaseAllStreams. |
|
253 | 635 |
|
277 | 636 |
self initializeSimulatedLibs. "/ < jdk 1.2 |
637 |
self initializeSimulatedNativeLibs. "/ >= jdk 1.2 |
|
253 | 638 |
self initializeOpenFileTable. |
639 |
||
640 |
self initializeBaseClasses. |
|
641 |
self initializePrimitiveClasses. |
|
642 |
||
643 |
(Java classForName:'java.lang.System') classInit. |
|
644 |
Java initSystemClass. |
|
645 |
||
255 | 646 |
ObjectMemory addDependent:self. |
647 |
||
253 | 648 |
" |
277 | 649 |
JavaVM initialize |
253 | 650 |
JavaVM initializeVM |
651 |
" |
|
652 |
||
653 |
"Created: / 3.1.1998 / 21:29:09 / cg" |
|
277 | 654 |
"Modified: / 27.1.1998 / 21:52:29 / cg" |
261 | 655 |
! |
656 |
||
657 |
initializeVMIfNoEventThreadRunning |
|
658 |
(JavaEventThread isNil or:[JavaEventThread isDead]) ifTrue:[ |
|
270 | 659 |
self initializeVM |
261 | 660 |
]. |
661 |
||
662 |
" |
|
663 |
JavaVM initializeVMIfNoEventThreadRunning |
|
664 |
" |
|
665 |
||
666 |
"Modified: / 15.1.1998 / 17:29:34 / cg" |
|
667 |
"Created: / 15.1.1998 / 17:32:27 / cg" |
|
255 | 668 |
! |
669 |
||
670 |
releaseAllJavaResources |
|
671 |
self releaseAllMonitors. |
|
672 |
Java terminateAllThreads. |
|
673 |
self releaseAllWindows. |
|
674 |
self releaseAllStreams. |
|
675 |
||
676 |
JavaWindowGroup := nil. |
|
677 |
LoadedLibs := nil. "/ gc will reclaim them ... |
|
262 | 678 |
ImageStretchCache := nil. |
255 | 679 |
|
680 |
" |
|
681 |
JavaVM releaseAllJavaResources |
|
682 |
" |
|
683 |
||
684 |
"Created: / 7.1.1998 / 22:49:42 / cg" |
|
262 | 685 |
"Modified: / 17.1.1998 / 13:27:13 / cg" |
253 | 686 |
! |
687 |
||
688 |
releaseAllMonitors |
|
689 |
LockTable := WeakIdentityDictionary new. |
|
690 |
LockTableAccess := Semaphore forMutualExclusion. |
|
691 |
WaitTable := IdentityDictionary new. |
|
692 |
WaitTableAccess := Semaphore forMutualExclusion. |
|
693 |
||
694 |
EnteredMonitorsPerProcess := IdentityDictionary new. |
|
695 |
||
696 |
" |
|
697 |
JavaVM releaseAllMonitors |
|
698 |
" |
|
699 |
||
700 |
"Created: / 2.1.1998 / 18:04:05 / cg" |
|
255 | 701 |
"Modified: / 7.1.1998 / 22:58:10 / cg" |
702 |
! |
|
703 |
||
704 |
releaseAllStreams |
|
705 |
self initializeOpenFileTable. |
|
706 |
||
707 |
" |
|
261 | 708 |
JavaVM releaseAllStreams |
255 | 709 |
" |
710 |
||
711 |
"Modified: / 6.8.1997 / 00:40:55 / cg" |
|
712 |
"Created: / 7.1.1998 / 22:57:04 / cg" |
|
713 |
! |
|
714 |
||
715 |
releaseAllWindows |
|
716 |
KnownWindows notNil ifTrue:[ |
|
261 | 717 |
KnownWindows do:[:aView | |
718 |
aView destroy |
|
719 |
]. |
|
720 |
KnownWindows := nil. |
|
255 | 721 |
] |
722 |
||
723 |
" |
|
724 |
self releaseAllWindows |
|
725 |
" |
|
726 |
||
727 |
"Created: / 7.1.1998 / 22:58:32 / cg" |
|
728 |
! |
|
729 |
||
730 |
releaseLeftOverMonitors |
|
731 |
"release monitors held by dead processes" |
|
732 |
||
733 |
|deadProcesses| |
|
734 |
||
735 |
deadProcesses := IdentitySet new. |
|
736 |
||
737 |
EnteredMonitorsPerProcess keysAndValuesDo:[:p :monitors | |
|
261 | 738 |
p isDead ifTrue:[ |
739 |
monitors do:[:mon | |
|
740 |
Transcript showCR:'release leftover monitor ...'. |
|
741 |
mon release |
|
742 |
]. |
|
743 |
deadProcesses add:p. |
|
744 |
] |
|
255 | 745 |
]. |
746 |
deadProcesses do:[:p | |
|
261 | 747 |
EnteredMonitorsPerProcess removeKey:p |
255 | 748 |
]. |
749 |
||
750 |
" |
|
751 |
JavaVM releaseLeftOverMonitors |
|
752 |
" |
|
753 |
||
754 |
"Created: / 8.1.1998 / 17:29:26 / cg" |
|
755 |
"Modified: / 8.1.1998 / 17:38:33 / cg" |
|
253 | 756 |
! |
757 |
||
758 |
systemProperties |
|
759 |
|props| |
|
760 |
||
761 |
props := Dictionary new. |
|
762 |
self initializeSystemPropertiesInto:props. |
|
763 |
^ props |
|
764 |
||
765 |
"Created: / 3.1.1998 / 14:25:58 / cg" |
|
766 |
"Modified: / 3.1.1998 / 14:32:38 / cg" |
|
255 | 767 |
! |
768 |
||
769 |
terminateAllThreads |
|
261 | 770 |
Java terminateAllThreads. |
771 |
JavaEventThread := nil. |
|
255 | 772 |
|
773 |
"Created: / 8.1.1998 / 17:43:54 / cg" |
|
261 | 774 |
"Modified: / 15.1.1998 / 17:29:00 / cg" |
255 | 775 |
! |
776 |
||
777 |
update:something with:aParameter from:changedObject |
|
778 |
something == #returnFromSnapshot ifTrue:[ |
|
261 | 779 |
self initializeVM |
255 | 780 |
]. |
781 |
||
782 |
" |
|
783 |
JavaVM initializeVM |
|
784 |
" |
|
785 |
||
786 |
"Modified: / 8.1.1998 / 17:44:16 / cg" |
|
787 |
"Created: / 9.1.1998 / 10:30:13 / cg" |
|
253 | 788 |
! ! |
789 |
||
790 |
!JavaVM class methodsFor:'Signal constants'! |
|
791 |
||
792 |
badMessageSignal |
|
793 |
^ BadMessageSignal |
|
794 |
||
795 |
"Created: / 2.1.1998 / 18:06:52 / cg" |
|
796 |
! |
|
797 |
||
798 |
callHandlerSignal |
|
799 |
^ CallHandlerSignal |
|
800 |
||
801 |
"Created: / 2.1.1998 / 18:07:16 / cg" |
|
802 |
! |
|
803 |
||
804 |
internalErrorSignal |
|
805 |
^ InternalErrorSignal |
|
806 |
||
807 |
"Created: / 2.1.1998 / 18:07:05 / cg" |
|
808 |
! |
|
809 |
||
810 |
javaExceptionSignal |
|
811 |
^ JavaExceptionSignal |
|
812 |
||
813 |
"Created: / 2.1.1998 / 18:05:58 / cg" |
|
814 |
! |
|
815 |
||
816 |
unhandledJavaExceptionSignal |
|
817 |
^ UnhandledJavaExceptionSignal |
|
818 |
||
819 |
"Created: / 2.1.1998 / 18:05:19 / cg" |
|
820 |
! |
|
821 |
||
822 |
unimplementedInstructionSignal |
|
823 |
^ UnimplementedInstructionSignal |
|
824 |
||
825 |
"Created: / 2.1.1998 / 18:06:15 / cg" |
|
826 |
! |
|
827 |
||
828 |
unimplementedNativeMethodSignal |
|
829 |
^ UnimplementedNativeMethodSignal |
|
830 |
||
831 |
"Created: / 2.1.1998 / 18:06:40 / cg" |
|
832 |
! ! |
|
833 |
||
834 |
!JavaVM class methodsFor:'defaults'! |
|
835 |
||
836 |
defaultCLASSPATH |
|
837 |
|s| |
|
838 |
||
839 |
s := '' writeStream. |
|
840 |
Java classPath do:[:p | |
|
261 | 841 |
s size == 0 ifFalse:[ |
842 |
s nextPut:$: |
|
843 |
]. |
|
844 |
s nextPutAll:p. |
|
253 | 845 |
]. |
846 |
||
847 |
^ s contents |
|
848 |
||
849 |
" |
|
850 |
self defaultCLASSPATH |
|
851 |
" |
|
852 |
||
853 |
"Modified: / 6.8.1997 / 00:51:17 / cg" |
|
854 |
"Created: / 3.1.1998 / 14:27:21 / cg" |
|
855 |
! |
|
856 |
||
857 |
defaultHotJavaHome |
|
858 |
^ '/usr/local/java/hotjava'. |
|
859 |
||
860 |
"Modified: / 5.8.1997 / 04:13:36 / cg" |
|
861 |
"Created: / 3.1.1998 / 14:27:34 / cg" |
|
862 |
! |
|
863 |
||
864 |
defaultJAVAHome |
|
865 |
^ Java javaHome |
|
866 |
||
867 |
"Modified: / 6.8.1997 / 00:54:44 / cg" |
|
868 |
"Created: / 3.1.1998 / 14:27:01 / cg" |
|
869 |
! |
|
870 |
||
871 |
defaultJWSHome |
|
872 |
^ '/usr/local/java/JWS'. |
|
873 |
||
874 |
"Modified: / 5.8.1997 / 04:14:34 / cg" |
|
875 |
"Created: / 3.1.1998 / 14:27:42 / cg" |
|
876 |
! |
|
877 |
||
878 |
defaultWindowingToolKit |
|
879 |
"/ prefer the windows toolkit ... |
|
880 |
||
881 |
(Java classForName:'sun.awt.windows.WToolkit') notNil ifTrue:[ |
|
277 | 882 |
^ 'sun.awt.windows.WToolkit'. |
883 |
]. |
|
884 |
(Java classForName:'sun.awt.motif.MToolkit') notNil ifTrue:[ |
|
885 |
^ 'sun.awt.motif.MToolkit'. |
|
886 |
]. |
|
253 | 887 |
|
888 |
^ 'sun.awt.tiny.TinyToolkit'. |
|
889 |
||
890 |
||
891 |
"/ ^ 'sun.awt.win32.MToolkit'. |
|
892 |
"/ ^ 'sun.awt.motif.MToolkit'. |
|
893 |
||
277 | 894 |
" |
895 |
self defaultWindowingToolKit |
|
896 |
" |
|
897 |
||
253 | 898 |
"Created: / 3.1.1998 / 14:27:49 / cg" |
277 | 899 |
"Modified: / 27.1.1998 / 21:52:52 / cg" |
253 | 900 |
! |
901 |
||
902 |
javaConsole:aStream |
|
903 |
JavaConsoleStream := aStream |
|
904 |
||
905 |
" |
|
261 | 906 |
JavaVM javaConsole:Transcript |
253 | 907 |
" |
908 |
||
909 |
"Modified: / 6.8.1997 / 00:34:13 / cg" |
|
910 |
"Created: / 3.1.1998 / 14:27:58 / cg" |
|
911 |
! |
|
912 |
||
913 |
javaConsoleStream |
|
914 |
^ JavaConsoleStream |
|
915 |
||
916 |
"Created: / 3.1.1998 / 14:32:16 / cg" |
|
917 |
! ! |
|
918 |
||
919 |
!JavaVM class methodsFor:'fileIO'! |
|
920 |
||
921 |
addOpenFile:aStream |
|
922 |
OpenFileTable add:aStream. |
|
923 |
^ OpenFileTable size - 1. |
|
924 |
||
925 |
"Created: / 2.1.1998 / 18:32:59 / cg" |
|
926 |
! |
|
927 |
||
928 |
getOpenFileAt:idx |
|
929 |
^ OpenFileTable at:idx+1 ifAbsent:nil. |
|
930 |
||
931 |
"Created: / 2.1.1998 / 18:28:01 / cg" |
|
932 |
"Modified: / 2.1.1998 / 18:33:06 / cg" |
|
933 |
! |
|
934 |
||
935 |
setOpenFile:aStream at:idx |
|
936 |
OpenFileTable size < (idx+1) ifTrue:[ |
|
261 | 937 |
OpenFileTable grow:idx+1. |
253 | 938 |
]. |
939 |
OpenFileTable at:idx+1 put:aStream. |
|
940 |
||
941 |
"Modified: / 2.1.1998 / 18:33:21 / cg" |
|
942 |
! ! |
|
943 |
||
944 |
!JavaVM class methodsFor:'helpers'! |
|
945 |
||
268
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
946 |
classForJavaClassObject:aJavaClassObject |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
947 |
"given java.lang.class instance, return the real class for it." |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
948 |
|
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
949 |
^ JavaClasses at:aJavaClassObject ifAbsent:nil. |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
950 |
|
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
951 |
"Created: / 23.1.1998 / 17:44:09 / cg" |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
952 |
! |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
953 |
|
253 | 954 |
enteredMonitors |
955 |
|p monitors| |
|
956 |
||
957 |
p := Processor activeProcess. |
|
958 |
monitors := EnteredMonitorsPerProcess at:p ifAbsent:nil. |
|
959 |
monitors isNil ifTrue:[ |
|
261 | 960 |
monitors := OrderedCollection new. |
961 |
EnteredMonitorsPerProcess at:p put:monitors. |
|
253 | 962 |
]. |
963 |
^ monitors |
|
964 |
||
965 |
"Created: / 2.1.1998 / 21:26:19 / cg" |
|
966 |
! |
|
967 |
||
268
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
968 |
javaClassObjectForClass:aClass |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
969 |
"given a real class, return the corresponding java.lang.class |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
970 |
instance for it." |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
971 |
|
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
972 |
|jClass| |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
973 |
|
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
974 |
jClass := JavaClasses at:aClass ifAbsent:nil. |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
975 |
jClass isNil ifTrue:[ |
270 | 976 |
"/ class must be initialized (with all of its superclasses ?). |
977 |
aClass classInit. |
|
978 |
||
979 |
JavaClasses at:aClass put:(jClass := (Java at:'java.lang.Class') new). |
|
980 |
JavaClasses at:jClass put:aClass. |
|
268
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
981 |
]. |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
982 |
^ jClass |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
983 |
|
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
984 |
"Created: / 23.1.1998 / 17:43:38 / cg" |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
985 |
"Modified: / 23.1.1998 / 17:46:51 / cg" |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
986 |
! |
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
987 |
|
253 | 988 |
javaThreadForSTProcess:stProcess |
989 |
|t| |
|
990 |
||
991 |
t := Java threads keyAtValue:stProcess ifAbsent:nil. |
|
992 |
t == 0 ifTrue:[ |
|
261 | 993 |
^ nil |
253 | 994 |
]. |
995 |
^ t |
|
996 |
||
997 |
"Modified: / 26.8.1997 / 19:56:31 / cg" |
|
998 |
"Created: / 3.1.1998 / 01:53:41 / cg" |
|
999 |
! |
|
1000 |
||
1001 |
newThread:name |
|
274 | 1002 |
|thread threadClass i| |
253 | 1003 |
|
1004 |
threadClass := Java at:'java.lang.Thread'. |
|
1005 |
||
1006 |
thread := (Java at:'java.lang.Thread') basicNew. |
|
1007 |
thread instVarNamed:'name' put:(Java as_String:name). |
|
1008 |
thread instVarNamed:'priority' put:(threadClass instVarNamed:'NORM_PRIORITY'). |
|
1009 |
thread instVarNamed:'single_step' put:0. |
|
1010 |
thread instVarNamed:'daemon' put:0. |
|
1011 |
thread instVarNamed:'stillborn' put:0. |
|
1012 |
thread instVarNamed:'target' put:nil. |
|
274 | 1013 |
"/ |
1014 |
"/ that on was only temporarily present in JDK1.1.3 (sigh) |
|
1015 |
"/ |
|
1016 |
(i := thread class instVarOffsetOf:'initial_stack_memory') notNil ifTrue:[ |
|
1017 |
thread instVarAt:i put:0. |
|
1018 |
]. |
|
253 | 1019 |
thread instVarNamed:'group' put:(self standardThreadGroup). |
1020 |
^ thread |
|
1021 |
||
1022 |
"Created: / 3.1.1998 / 01:47:30 / cg" |
|
274 | 1023 |
"Modified: / 27.1.1998 / 00:54:33 / cg" |
253 | 1024 |
! |
1025 |
||
1026 |
stProcessForJavaThread:jThread |
|
1027 |
|p| |
|
1028 |
||
1029 |
p := Java threads at:jThread ifAbsent:nil. |
|
1030 |
p == 0 ifTrue:[ |
|
261 | 1031 |
^ nil |
253 | 1032 |
]. |
1033 |
^ p |
|
1034 |
||
1035 |
"Created: / 2.1.1998 / 21:48:27 / cg" |
|
1036 |
"Modified: / 3.1.1998 / 01:53:55 / cg" |
|
1037 |
! |
|
1038 |
||
1039 |
standardThreadGroup |
|
1040 |
|standardGroup threadClass| |
|
1041 |
||
1042 |
StandardThreadGroup isNil ifTrue:[ |
|
261 | 1043 |
threadClass := Java at:'java.lang.Thread'. |
1044 |
||
1045 |
standardGroup := (Java at:'java.lang.ThreadGroup') new. |
|
1046 |
standardGroup instVarNamed:'parent' put:nil. |
|
1047 |
standardGroup instVarNamed:'name' put:(Java as_String:'main'). |
|
1048 |
standardGroup instVarNamed:'maxPriority' put:(threadClass instVarNamed:'MAX_PRIORITY'). |
|
1049 |
standardGroup instVarNamed:'destroyed' put:0. |
|
1050 |
standardGroup instVarNamed:'daemon' put:nil. |
|
1051 |
standardGroup instVarNamed:'vmAllowSuspension' put:0. |
|
1052 |
standardGroup instVarNamed:'nthreads' put:0. |
|
1053 |
standardGroup instVarNamed:'ngroups' put:0. |
|
1054 |
standardGroup instVarNamed:'groups' put:nil. |
|
1055 |
StandardThreadGroup := standardGroup. |
|
253 | 1056 |
]. |
1057 |
^ StandardThreadGroup |
|
1058 |
||
1059 |
"Created: / 3.1.1998 / 01:41:54 / cg" |
|
1060 |
! |
|
1061 |
||
1062 |
wakeup:anObject |
|
1063 |
JavaVM releaseAndSignalSemaphoreFor:anObject. |
|
1064 |
||
1065 |
"Created: / 3.1.1998 / 02:29:27 / cg" |
|
1066 |
"Modified: / 3.1.1998 / 03:08:05 / cg" |
|
1067 |
! |
|
1068 |
||
1069 |
wakeupAll:anObject |
|
1070 |
JavaVM releaseAndSignalForAllSemaphoreFor:anObject. |
|
1071 |
||
1072 |
"Created: / 3.1.1998 / 03:07:48 / cg" |
|
1073 |
"Modified: / 3.1.1998 / 03:08:15 / cg" |
|
1074 |
! ! |
|
1075 |
||
1076 |
!JavaVM class methodsFor:'helpers - awt'! |
|
1077 |
||
1078 |
commonReshapeComponent:nativeContext |
|
277 | 1079 |
|view x y width height ext menu| |
1080 |
||
1081 |
view := self viewForWPeer:nativeContext. |
|
253 | 1082 |
|
1083 |
x := nativeContext argAt:1. |
|
1084 |
y := nativeContext argAt:2. |
|
1085 |
width := nativeContext argAt:3. |
|
1086 |
height := nativeContext argAt:4. |
|
261 | 1087 |
ext := width@height. |
253 | 1088 |
|
1089 |
"/ 'pReshape ' print. view print. |
|
1090 |
"/ ' ' print. x print. '/' print. y print. |
|
261 | 1091 |
"/ ' extent: ' print. ext printNL. |
253 | 1092 |
|
1093 |
(view isTopView |
|
1094 |
or:[view isMemberOf:JavaEmbeddedFrameView]) ifTrue:[ |
|
1095 |
"/ |
|
1096 |
"/ dont allow setting the origin |
|
1097 |
"/ |
|
1098 |
menu := self topViewsMenu:view. |
|
1099 |
menu notNil ifTrue:[ |
|
1100 |
"/ must add the menus height |
|
261 | 1101 |
height := height + menu height. |
1102 |
ext := width@height. |
|
253 | 1103 |
]. |
261 | 1104 |
|
1105 |
"/ to prevent a view from not being visible/closable |
|
1106 |
"/ in case Java goes mad .. |
|
1107 |
||
1108 |
(width < 30 |
|
1109 |
or:[height < 10]) ifTrue:[ |
|
1110 |
"/ self halt. |
|
1111 |
width := 30. |
|
1112 |
height := 20. |
|
1113 |
ext := width@height. |
|
1114 |
]. |
|
1115 |
||
1116 |
view extent:ext. |
|
270 | 1117 |
(view isKindOf:ModalBox) ifTrue:[ |
1118 |
view preferredExtent:ext |
|
1119 |
]. |
|
261 | 1120 |
|
1121 |
"/ adjust non-resizable views min/max |
|
1122 |
||
1123 |
view isTopView ifTrue:[ |
|
1124 |
view minExtent notNil ifTrue:[ |
|
1125 |
view minExtent:ext. |
|
1126 |
view maxExtent:ext |
|
1127 |
]. |
|
1128 |
] |
|
253 | 1129 |
] ifFalse:[ |
1130 |
(view superView notNil |
|
1131 |
and:[view superView isTopView]) ifTrue:[ |
|
1132 |
menu := self topViewsMenu:view superView. |
|
1133 |
menu notNil ifTrue:[ |
|
1134 |
"/ must add menus height to yPos |
|
1135 |
y := y + menu height. |
|
1136 |
] |
|
261 | 1137 |
] ifFalse:[ |
1138 |
"/ post a configuration event |
|
1139 |
'need event' printCR. |
|
253 | 1140 |
]. |
261 | 1141 |
view origin:x@y extent:ext. |
253 | 1142 |
]. |
1143 |
||
1144 |
^ nil |
|
1145 |
||
1146 |
"Created: / 4.1.1998 / 18:00:52 / cg" |
|
277 | 1147 |
"Modified: / 27.1.1998 / 21:38:48 / cg" |
253 | 1148 |
! |
1149 |
||
1150 |
createdWindowsView:aView for:aJavaPeer |
|
1151 |
"this is only sent with the sun.awt.windows toolkit" |
|
1152 |
||
1153 |
aJavaPeer instVarNamed:'pData' put:aView. |
|
1154 |
||
1155 |
JavaWindowGroup isNil ifTrue:[ |
|
270 | 1156 |
JavaWindowGroup := WindowGroup new. |
1157 |
JavaWindowGroup isForModalSubview:true. |
|
253 | 1158 |
]. |
1159 |
aView windowGroup:JavaWindowGroup. |
|
1160 |
JavaWindowGroup addView:aView. |
|
1161 |
||
1162 |
KnownWindows isNil ifTrue:[ |
|
270 | 1163 |
KnownWindows := IdentityDictionary new. |
253 | 1164 |
]. |
1165 |
KnownWindows at:aJavaPeer put:aView. |
|
1166 |
||
261 | 1167 |
"/'*** ' print. aJavaPeer print. ' -> ' print. aView printCR. |
1168 |
"/(aView isKindOf:ModalBox) ifTrue:[ |
|
1169 |
"/ self halt. |
|
1170 |
"/]. |
|
1171 |
||
253 | 1172 |
"Created: / 4.1.1998 / 17:57:16 / cg" |
261 | 1173 |
"Modified: / 15.1.1998 / 15:32:49 / cg" |
253 | 1174 |
! |
1175 |
||
255 | 1176 |
gcForWGraphics:nativeContext |
270 | 1177 |
|jGraphics gc orgX orgY trans| |
255 | 1178 |
|
1179 |
jGraphics := nativeContext receiver. |
|
1180 |
gc := jGraphics instVarNamed:'pData'. |
|
270 | 1181 |
|
1182 |
trans := gc translation. |
|
1183 |
orgX := jGraphics instVarNamed:'originX'. |
|
1184 |
orgY := jGraphics instVarNamed:'originY'. |
|
1185 |
((orgX ~~ trans x) or:[orgY ~~ trans y]) ifTrue:[ |
|
1186 |
gc translation:orgX@orgY |
|
1187 |
]. |
|
255 | 1188 |
^ gc |
1189 |
||
1190 |
"Created: / 8.1.1998 / 00:16:38 / cg" |
|
270 | 1191 |
"Modified: / 25.1.1998 / 11:11:42 / cg" |
255 | 1192 |
! |
1193 |
||
261 | 1194 |
jPeerForView:aView |
1195 |
^ KnownWindows keyAtValue:aView ifAbsent:nil |
|
1196 |
||
1197 |
"Created: / 15.1.1998 / 13:48:01 / cg" |
|
1198 |
"Modified: / 15.1.1998 / 13:48:43 / cg" |
|
1199 |
! |
|
1200 |
||
255 | 1201 |
pReshape:nativeContext |
1202 |
|jFramePeer view x y width height menu| |
|
1203 |
||
1204 |
jFramePeer := nativeContext receiver. |
|
1205 |
view := jFramePeer instVarNamed:'pData'. |
|
1206 |
||
1207 |
x := nativeContext argAt:1. |
|
1208 |
y := nativeContext argAt:2. |
|
1209 |
width := nativeContext argAt:3. |
|
1210 |
height := nativeContext argAt:4. |
|
1211 |
||
1212 |
"/ 'pReshape ' print. view print. |
|
1213 |
"/ ' ' print. x print. '/' print. y print. |
|
1214 |
"/ ' extent: ' print. width print. '/' print. height printNL. |
|
1215 |
||
1216 |
(view isTopView |
|
1217 |
or:[view isMemberOf:JavaEmbeddedFrameView]) ifTrue:[ |
|
261 | 1218 |
"/ |
1219 |
"/ dont allow setting the origin |
|
1220 |
"/ |
|
1221 |
menu := self topViewsMenu:view. |
|
1222 |
menu notNil ifTrue:[ |
|
1223 |
"/ must add the menus height |
|
1224 |
height := height + menu height |
|
1225 |
]. |
|
1226 |
view extent:width@height. |
|
255 | 1227 |
] ifFalse:[ |
261 | 1228 |
(view superView notNil |
1229 |
and:[view superView isTopView]) ifTrue:[ |
|
1230 |
menu := self topViewsMenu:view superView. |
|
1231 |
menu notNil ifTrue:[ |
|
1232 |
"/ must add menus height to yPos |
|
1233 |
y := y + menu height. |
|
1234 |
] |
|
1235 |
]. |
|
1236 |
view origin:x@y extent:width@height. |
|
255 | 1237 |
]. |
1238 |
||
1239 |
^ nil |
|
1240 |
||
1241 |
"Modified: / 21.8.1997 / 19:34:16 / cg" |
|
1242 |
"Created: / 7.1.1998 / 21:47:11 / cg" |
|
1243 |
! |
|
1244 |
||
253 | 1245 |
topViewsMenu:view |
1246 |
|idx| |
|
1247 |
||
1248 |
view isTopView ifTrue:[ |
|
261 | 1249 |
view subViews size > 0 ifTrue:[ |
1250 |
(idx := view subViews findFirst:[:v | v isMemberOf:MenuPanel]) ~~ 0 ifTrue:[ |
|
1251 |
"/ must add the menus height |
|
1252 |
^ view subViews at:idx |
|
1253 |
] |
|
1254 |
]. |
|
253 | 1255 |
]. |
1256 |
^ nil |
|
1257 |
||
1258 |
"Modified: / 4.8.1997 / 01:23:06 / cg" |
|
1259 |
"Created: / 4.1.1998 / 18:01:42 / cg" |
|
255 | 1260 |
! |
1261 |
||
1262 |
viewForWPeer:nativeContext |
|
277 | 1263 |
|jPeer view pDataIdx| |
255 | 1264 |
|
1265 |
jPeer := nativeContext receiver. |
|
277 | 1266 |
|
1267 |
"/ sigh; pData was renamed to pNativeWidget in jdk1.2 ... |
|
1268 |
pDataIdx := jPeer class instVarOffsetOf:'pNativeWidget'. |
|
1269 |
pDataIdx isNil ifTrue:[ |
|
1270 |
"/ ok, we are < 1.2 |
|
1271 |
pDataIdx := jPeer class instVarOffsetOf:'pData'. |
|
1272 |
]. |
|
1273 |
||
1274 |
view := jPeer instVarAt:pDataIdx. |
|
255 | 1275 |
^ view |
1276 |
||
1277 |
"Created: / 8.1.1998 / 17:31:25 / cg" |
|
277 | 1278 |
"Modified: / 27.1.1998 / 21:37:43 / cg" |
253 | 1279 |
! ! |
1280 |
||
1281 |
!JavaVM class methodsFor:'helpers - exceptions'! |
|
1282 |
||
1283 |
findJavaHandlerFor:aJavaException |
|
1284 |
|con method pc hPC| |
|
1285 |
||
1286 |
con := thisContext sender. |
|
1287 |
[con notNil] whileTrue:[ |
|
261 | 1288 |
(con isMemberOf:JavaContext) ifTrue:[ |
1289 |
method := con method. |
|
1290 |
pc := con pc. |
|
1291 |
(hPC := method handlerFor:aJavaException at:pc) notNil ifTrue:[ |
|
1292 |
con setPC:hPC. |
|
1293 |
^ con |
|
1294 |
]. |
|
1295 |
]. |
|
1296 |
con := con sender. |
|
253 | 1297 |
]. |
1298 |
^ nil |
|
1299 |
||
1300 |
"Modified: / 5.1.1998 / 00:16:52 / cg" |
|
1301 |
! |
|
1302 |
||
261 | 1303 |
throwArrayIndexOutOfBoundsException:badIndex |
1304 |
|exClass ex| |
|
1305 |
||
1306 |
"/ self |
|
1307 |
"/ throwExceptionClassName:'java.lang.ArrayIndexOutOfBoundsException' |
|
1308 |
"/ withMessage:'bad array index: ' , badIndex printString |
|
1309 |
||
1310 |
exClass := Java classForName:'java.lang.ArrayIndexOutOfBoundsException'. |
|
1311 |
ex := exClass newCleared. |
|
1312 |
ex perform:#'<init>(I)V' with:badIndex. |
|
1313 |
||
1314 |
self throwException:ex |
|
1315 |
||
1316 |
"Created: / 14.1.1998 / 21:36:05 / cg" |
|
1317 |
"Modified: / 14.1.1998 / 23:32:52 / cg" |
|
1318 |
! |
|
1319 |
||
253 | 1320 |
throwClassNotFoundException |
255 | 1321 |
self |
261 | 1322 |
throwExceptionClassName:'java.lang.ClassNotFoundException' |
1323 |
withMessage:'no such class' |
|
255 | 1324 |
|
253 | 1325 |
"Created: / 4.1.1998 / 22:25:26 / cg" |
255 | 1326 |
"Modified: / 7.1.1998 / 15:25:35 / cg" |
253 | 1327 |
! |
1328 |
||
1329 |
throwClassNotFoundException:className |
|
255 | 1330 |
self |
261 | 1331 |
throwExceptionClassName:'java.lang.ClassNotFoundException' |
1332 |
withMessage:'no such class: ' , className |
|
255 | 1333 |
|
253 | 1334 |
"Created: / 4.1.1998 / 22:26:09 / cg" |
255 | 1335 |
"Modified: / 7.1.1998 / 15:25:58 / cg" |
1336 |
! |
|
1337 |
||
1338 |
throwException:aJavaException |
|
262 | 1339 |
|con jMsg msg exClass| |
255 | 1340 |
|
1341 |
ExceptionTrace ifTrue:[ |
|
270 | 1342 |
'JAVA: exception: ' print. aJavaException class fullName printCR. |
255 | 1343 |
]. |
1344 |
ExceptionDebug ifTrue:[ |
|
270 | 1345 |
self halt:('JAVA: exception: ' , aJavaException class fullName). |
1346 |
self internalError:('JAVA: exception: ' , aJavaException class fullName). |
|
255 | 1347 |
]. |
1348 |
||
1349 |
con := self findJavaHandlerFor:aJavaException. |
|
1350 |
con isNil ifTrue:[ |
|
270 | 1351 |
exClass := aJavaException class. |
1352 |
jMsg := aJavaException instVarNamed:'detailMessage'. |
|
1353 |
jMsg notNil ifTrue:[ |
|
1354 |
msg := Java as_ST_String:jMsg. |
|
1355 |
msg := 'Java ' , exClass name , ': ' , msg. |
|
1356 |
] ifFalse:[ |
|
1357 |
msg := 'Java ' , exClass name |
|
1358 |
]. |
|
1359 |
||
1360 |
"/ for our convenience: skip ST contexts |
|
1361 |
con := thisContext sender. |
|
1362 |
[con isNil or:[con isMemberOf:JavaContext]] whileFalse:[ |
|
1363 |
con := con sender |
|
1364 |
]. |
|
1365 |
con isNil ifTrue:[con := thisContext sender]. |
|
1366 |
||
1367 |
"/ |
|
1368 |
"/ no JavaHandler ... let smalltalk handle it |
|
1369 |
"/ |
|
1370 |
JavaVM javaExceptionSignal |
|
1371 |
raiseWith:aJavaException |
|
1372 |
errorString:msg |
|
1373 |
in:con. |
|
1374 |
Processor activeProcess terminate. |
|
255 | 1375 |
]. |
261 | 1376 |
|
1377 |
"/ |
|
1378 |
"/ found a java exceptionHandler |
|
1379 |
"/ |
|
255 | 1380 |
con exceptionArg:aJavaException. |
1381 |
con markForException. |
|
1382 |
con unwindAndRestart. |
|
1383 |
||
1384 |
self halt:'should not be reached'. |
|
1385 |
Processor activeProcess terminate. |
|
1386 |
||
1387 |
"Created: / 7.1.1998 / 15:28:22 / cg" |
|
262 | 1388 |
"Modified: / 17.1.1998 / 13:09:54 / cg" |
255 | 1389 |
! |
1390 |
||
1391 |
throwExceptionClassName:aJavaExceptionClassName withMessage:someMessage |
|
261 | 1392 |
|exClass ex| |
1393 |
||
1394 |
exClass := Java classForName:aJavaExceptionClassName. |
|
1395 |
ex := exClass newCleared. |
|
1396 |
ex perform:#'<init>(Ljava/lang/String;)V' with:(Java as_String:someMessage). |
|
1397 |
||
1398 |
"/ ex := exClass new. |
|
1399 |
"/ ex instVarNamed:'detailMessage' put:(Java as_String:someMessage). |
|
255 | 1400 |
|
1401 |
self throwException:ex |
|
1402 |
||
1403 |
"Created: / 7.1.1998 / 15:25:09 / cg" |
|
261 | 1404 |
"Modified: / 14.1.1998 / 23:38:30 / cg" |
255 | 1405 |
! |
1406 |
||
1407 |
throwIOExceptionWithMessage:message |
|
1408 |
self |
|
261 | 1409 |
throwExceptionClassName:'java.io.IOException' |
1410 |
withMessage:message |
|
255 | 1411 |
|
1412 |
"Created: / 7.1.1998 / 10:34:24 / cg" |
|
1413 |
"Modified: / 7.1.1998 / 15:26:25 / cg" |
|
1414 |
! |
|
1415 |
||
261 | 1416 |
throwIllegalAccessException |
1417 |
self |
|
270 | 1418 |
throwExceptionClassName:'java.lang.IllegalAccessException' |
1419 |
withMessage:'illegal access' |
|
261 | 1420 |
|
1421 |
"Modified: / 7.1.1998 / 15:25:35 / cg" |
|
1422 |
"Created: / 14.1.1998 / 23:13:44 / cg" |
|
1423 |
! |
|
1424 |
||
1425 |
throwInstantiationException |
|
1426 |
self |
|
270 | 1427 |
throwExceptionClassName:'java.lang.InstantiationException' |
1428 |
withMessage:'cannot instantiate' |
|
261 | 1429 |
|
1430 |
"Modified: / 7.1.1998 / 15:25:35 / cg" |
|
1431 |
"Created: / 14.1.1998 / 23:15:01 / cg" |
|
1432 |
! |
|
1433 |
||
1434 |
throwInstantiationExceptionFor:aJavaClass |
|
1435 |
self |
|
270 | 1436 |
throwExceptionClassName:'java.lang.InstantiationException' |
1437 |
withMessage:('cannot instantiate ' , aJavaClass fullName) |
|
261 | 1438 |
|
1439 |
"Modified: / 7.1.1998 / 15:25:35 / cg" |
|
1440 |
"Created: / 14.1.1998 / 23:17:02 / cg" |
|
1441 |
! |
|
1442 |
||
255 | 1443 |
throwNullPointerException |
1444 |
self |
|
261 | 1445 |
throwExceptionClassName:'java.lang.NullPointerException' |
1446 |
withMessage:'null pointer' |
|
255 | 1447 |
|
1448 |
"Modified: / 7.1.1998 / 15:25:35 / cg" |
|
1449 |
"Created: / 9.1.1998 / 02:26:08 / cg" |
|
1450 |
! |
|
1451 |
||
1452 |
throwNumberFormatException |
|
1453 |
self |
|
261 | 1454 |
throwExceptionClassName:'java.lang.NumberFormatException' |
1455 |
withMessage:'bad number format' |
|
255 | 1456 |
|
1457 |
"Modified: / 7.1.1998 / 15:25:35 / cg" |
|
1458 |
"Created: / 11.1.1998 / 16:08:22 / cg" |
|
253 | 1459 |
! ! |
1460 |
||
1461 |
!JavaVM class methodsFor:'helpers - io'! |
|
1462 |
||
1463 |
anyFileStream_close:javaStream |
|
1464 |
|fileNo file| |
|
1465 |
||
1466 |
fileNo := self validateFileNo:javaStream. |
|
261 | 1467 |
fileNo == 0 ifTrue:[ |
1468 |
'JAVA: file is already closed' errorPrintCR. |
|
1469 |
^ self "/ already closed |
|
1470 |
]. |
|
253 | 1471 |
file := self getOpenFileAt:fileNo. |
1472 |
file isNil ifTrue:[ |
|
261 | 1473 |
self halt:'invalid fileNo in close'. |
1474 |
self internalError:'invalid fileNo in close'. |
|
1475 |
^ self |
|
253 | 1476 |
]. |
1477 |
||
1478 |
"/ should always be bytes |
|
1479 |
||
1480 |
(file ~~ Stdin |
|
1481 |
and:[file ~~ Stdout |
|
1482 |
and:[file ~~ Stderr]]) ifTrue:[ |
|
261 | 1483 |
file close. |
253 | 1484 |
]. |
1485 |
self setOpenFile:nil at:fileNo. |
|
1486 |
||
261 | 1487 |
fileNo := javaStream instVarNamed:'fd'. |
1488 |
fileNo isInteger ifFalse:[ |
|
1489 |
"/ JDK 1.1.3 |
|
1490 |
fileNo instVarNamed:'fd' put:0. |
|
1491 |
] ifTrue:[ |
|
1492 |
"/ JDK 1.0 |
|
1493 |
javaStream instVarNamed:'fd' put:0 |
|
1494 |
]. |
|
1495 |
||
253 | 1496 |
"Created: / 4.1.1998 / 17:47:03 / cg" |
261 | 1497 |
"Modified: / 13.1.1998 / 14:09:12 / cg" |
1498 |
! |
|
1499 |
||
1500 |
fileStreamForReading:name |
|
1501 |
|fn stream tryAlongClassPath| |
|
1502 |
||
1503 |
fn := name asFilename. |
|
1504 |
stream := fn readStream. |
|
1505 |
stream notNil ifTrue:[^ stream]. |
|
1506 |
||
1507 |
fn isAbsolute ifFalse:[ |
|
270 | 1508 |
"/ if not absolute, try along classPath |
1509 |
"/ This allows classes to open local files (JEdit) |
|
1510 |
"/ even if they have NOT been loaded by a Java classLoader. |
|
1511 |
"/ Only do this for image files |
|
1512 |
"/ (and maybe some other config files in the future), |
|
1513 |
"/ to avoid security holes. |
|
1514 |
||
1515 |
tryAlongClassPath := false. |
|
1516 |
(fn hasSuffix:'gif') ifTrue:[ |
|
1517 |
tryAlongClassPath := true. |
|
1518 |
]. |
|
1519 |
(fn hasSuffix:'jpg') ifTrue:[ |
|
1520 |
tryAlongClassPath := true. |
|
1521 |
]. |
|
1522 |
||
1523 |
tryAlongClassPath ifTrue:[ |
|
1524 |
Java classPath do:[:dirName | |
|
1525 |
|fn| |
|
1526 |
||
1527 |
(fn := dirName asFilename construct:name) exists ifTrue:[ |
|
1528 |
stream := fn readStream. |
|
1529 |
stream notNil ifTrue:[^ stream]. |
|
1530 |
] |
|
1531 |
] |
|
1532 |
] |
|
261 | 1533 |
]. |
1534 |
^ nil. |
|
1535 |
||
1536 |
"Modified: / 15.1.1998 / 13:01:34 / cg" |
|
253 | 1537 |
! |
1538 |
||
1539 |
validateFile:javaStream |
|
1540 |
|fileNo file descriptor| |
|
1541 |
||
1542 |
fileNo := self validateFileNo:javaStream. |
|
1543 |
fileNo isNil ifTrue:[ |
|
1544 |
"/ self halt:'invalid fileNo in read'. |
|
1545 |
"/ self internalError:'invalid fileNo in read'. |
|
261 | 1546 |
self throwIOExceptionWithMessage:'invalid fileNo in read'. |
1547 |
^ nil |
|
253 | 1548 |
]. |
1549 |
||
1550 |
file := self getOpenFileAt:fileNo. |
|
1551 |
||
1552 |
file isNil ifTrue:[ |
|
1553 |
"/ self halt:'invalid fileNo in read'. |
|
1554 |
"/ self internalError:'invalid fileNo in read'. |
|
261 | 1555 |
self throwIOExceptionWithMessage:'invalid fileNo in read'. |
1556 |
^ nil |
|
253 | 1557 |
]. |
1558 |
||
1559 |
^ file |
|
1560 |
||
1561 |
"Created: / 4.1.1998 / 16:50:38 / cg" |
|
1562 |
"Modified: / 4.1.1998 / 17:50:00 / cg" |
|
1563 |
! |
|
1564 |
||
1565 |
validateFileNo:javaStream |
|
1566 |
|fileNo file descriptor| |
|
1567 |
||
261 | 1568 |
"/ JDK 1.1.3 has fileDescriptor wrapped |
1569 |
"/ JDK 1.0 has it directly as integer |
|
1570 |
||
253 | 1571 |
fileNo := javaStream instVarNamed:'fd'. |
1572 |
fileNo isInteger ifFalse:[ |
|
261 | 1573 |
descriptor := fileNo. |
1574 |
fileNo := descriptor instVarNamed:'fd'. |
|
253 | 1575 |
]. |
1576 |
||
1577 |
fileNo isInteger ifFalse:[ |
|
1578 |
"/ self halt:'invalid fileNo in read'. |
|
1579 |
"/ self internalError:'invalid fileNo in read'. |
|
261 | 1580 |
self throwIOExceptionWithMessage:'invalid fileNo in read'. |
1581 |
^ nil |
|
253 | 1582 |
]. |
1583 |
||
1584 |
^ fileNo. |
|
1585 |
||
1586 |
"Created: / 4.1.1998 / 17:49:08 / cg" |
|
261 | 1587 |
"Modified: / 13.1.1998 / 14:07:47 / cg" |
253 | 1588 |
! ! |
1589 |
||
1590 |
!JavaVM class methodsFor:'native - awt.windows'! |
|
1591 |
||
1592 |
_WButtonPeer_create:nativeContext |
|
1593 |
|jButtonPeer jButton jFrame frame button |
|
1594 |
lbl| |
|
1595 |
||
1596 |
jButtonPeer := nativeContext receiver. |
|
1597 |
jButton := jButtonPeer instVarNamed:'target'. |
|
1598 |
||
1599 |
jFrame := nativeContext argAt:1. |
|
1600 |
frame := jFrame instVarNamed:'pData'. |
|
1601 |
||
1602 |
button := Button in:frame. |
|
255 | 1603 |
button action:[ |
261 | 1604 |
jButtonPeer invoke:#handleAction. |
1605 |
]. |
|
253 | 1606 |
|
1607 |
lbl := jButton instVarNamed:'label'. |
|
1608 |
lbl notNil ifTrue:[ |
|
261 | 1609 |
lbl := Java as_ST_String:lbl. |
1610 |
button label:lbl |
|
253 | 1611 |
]. |
1612 |
self createdWindowsView:button for:jButtonPeer. |
|
1613 |
||
1614 |
WindowCreationTrace == true ifTrue:[ |
|
261 | 1615 |
'WButtonPeer_create: ' print. frame print. ' -> ' print. button printNL. |
1616 |
]. |
|
253 | 1617 |
|
1618 |
"Created: / 5.1.1998 / 01:53:30 / cg" |
|
261 | 1619 |
"Modified: / 13.1.1998 / 22:09:15 / cg" |
253 | 1620 |
! |
1621 |
||
1622 |
_WCanvasPeer_create:nativeContext |
|
1623 |
|jCanvasPeer jFrame frame subView| |
|
1624 |
||
1625 |
jCanvasPeer := nativeContext receiver. |
|
1626 |
||
1627 |
jFrame := nativeContext argAt:1. |
|
1628 |
jFrame isNil ifTrue:[ |
|
270 | 1629 |
self halt:'no frame in canvasPeer create'. |
1630 |
self internalError:'no frame in canvasPeer create'. |
|
1631 |
^ self. |
|
253 | 1632 |
]. |
1633 |
frame := jFrame instVarNamed:'pData'. |
|
1634 |
||
1635 |
subView := JavaView in:frame. |
|
1636 |
subView delegate:self. |
|
261 | 1637 |
subView javaPeer:jCanvasPeer. |
253 | 1638 |
|
1639 |
self createdWindowsView:subView for:jCanvasPeer. |
|
1640 |
||
1641 |
WindowCreationTrace == true ifTrue:[ |
|
270 | 1642 |
'WCanvasPeer_create: ' print. frame print. ' -> ' print. subView printNL. |
253 | 1643 |
]. |
1644 |
||
1645 |
"Created: / 5.1.1998 / 00:59:19 / cg" |
|
261 | 1646 |
"Modified: / 16.1.1998 / 13:40:00 / cg" |
253 | 1647 |
! |
1648 |
||
255 | 1649 |
_WCheckboxPeer_create:nativeContext |
1650 |
|jCheckboxPeer jCheckbox jFrame frame checkBox lbl| |
|
1651 |
||
1652 |
jCheckboxPeer := nativeContext receiver. |
|
1653 |
jCheckbox := jCheckboxPeer instVarNamed:'target'. |
|
1654 |
||
1655 |
jFrame := nativeContext argAt:1. |
|
1656 |
frame := jFrame instVarNamed:'pData'. |
|
1657 |
||
1658 |
checkBox := CheckBox in:frame. |
|
261 | 1659 |
checkBox action:[ |
270 | 1660 |
jCheckboxPeer |
1661 |
perform:#'handleAction(Z)V' |
|
1662 |
with:(checkBox isOn ifTrue:[1] ifFalse:[0]) |
|
1663 |
]. |
|
255 | 1664 |
|
1665 |
lbl := jCheckbox instVarNamed:'label'. |
|
1666 |
lbl notNil ifTrue:[ |
|
270 | 1667 |
lbl := Java as_ST_String:lbl. |
1668 |
checkBox label:lbl |
|
255 | 1669 |
]. |
1670 |
||
1671 |
self createdWindowsView:checkBox for:jCheckboxPeer. |
|
1672 |
||
1673 |
WindowCreationTrace == true ifTrue:[ |
|
270 | 1674 |
'WCheckboxPeer_create: ' print. frame print. ' -> ' print. checkBox printNL. |
255 | 1675 |
]. |
1676 |
||
1677 |
"Created: / 7.1.1998 / 21:48:03 / cg" |
|
261 | 1678 |
"Modified: / 15.1.1998 / 12:27:04 / cg" |
255 | 1679 |
! |
1680 |
||
1681 |
_WCheckboxPeer_setCheckboxGroup:nativeContext |
|
270 | 1682 |
|checkBox jGroup| |
1683 |
||
1684 |
checkBox := self viewForWPeer:nativeContext. |
|
255 | 1685 |
|
1686 |
jGroup := nativeContext argAt:1. |
|
1687 |
||
1688 |
"Created: / 7.1.1998 / 21:48:47 / cg" |
|
270 | 1689 |
"Modified: / 25.1.1998 / 01:20:42 / cg" |
255 | 1690 |
! |
1691 |
||
1692 |
_WCheckboxPeer_setState:nativeContext |
|
270 | 1693 |
|checkBox state| |
1694 |
||
1695 |
checkBox := self viewForWPeer:nativeContext. |
|
255 | 1696 |
|
1697 |
state := nativeContext argAt:1. |
|
270 | 1698 |
state ~~ 0 ifTrue:[ |
1699 |
checkBox turnOn |
|
1700 |
] ifFalse:[ |
|
1701 |
checkBox turnOff |
|
1702 |
]. |
|
1703 |
||
255 | 1704 |
"Created: / 7.1.1998 / 21:49:13 / cg" |
270 | 1705 |
"Modified: / 25.1.1998 / 01:26:18 / cg" |
255 | 1706 |
! |
1707 |
||
1708 |
_WChoicePeer_addItem:nativeContext |
|
270 | 1709 |
|jString index comboBox| |
1710 |
||
1711 |
comboBox := self viewForWPeer:nativeContext. |
|
255 | 1712 |
|
1713 |
jString := nativeContext argAt:1. |
|
1714 |
index := nativeContext argAt:2. |
|
1715 |
||
270 | 1716 |
comboBox model list addLast:(Java as_ST_String:jString). |
1717 |
comboBox model changed:#list. |
|
1718 |
||
255 | 1719 |
"Created: / 7.1.1998 / 21:45:12 / cg" |
270 | 1720 |
"Modified: / 24.1.1998 / 18:51:32 / cg" |
255 | 1721 |
! |
1722 |
||
1723 |
_WChoicePeer_create:nativeContext |
|
1724 |
|jChoicePeer jChoice jFrame frame comboBox| |
|
1725 |
||
1726 |
jChoicePeer := nativeContext receiver. |
|
1727 |
jChoice := jChoicePeer instVarNamed:'target'. |
|
1728 |
||
1729 |
jFrame := nativeContext argAt:1. |
|
1730 |
frame := jFrame instVarNamed:'pData'. |
|
1731 |
||
270 | 1732 |
comboBox := ComboListView in:frame. |
1733 |
comboBox action:[:index | jChoicePeer perform:#'handleAction(I)V' with:(index - 1)]. |
|
1734 |
comboBox model:(SelectionInList new list:(OrderedCollection new)). |
|
1735 |
comboBox useIndex:true. |
|
255 | 1736 |
|
1737 |
self createdWindowsView:comboBox for:jChoicePeer. |
|
1738 |
||
1739 |
WindowCreationTrace == true ifTrue:[ |
|
270 | 1740 |
'WChoicePeer_create: ' print. frame print. ' -> ' print. comboBox printNL. |
261 | 1741 |
]. |
1742 |
||
255 | 1743 |
"Created: / 7.1.1998 / 21:44:31 / cg" |
270 | 1744 |
"Modified: / 24.1.1998 / 19:02:14 / cg" |
255 | 1745 |
! |
1746 |
||
1747 |
_WChoicePeer_reshape:nativeContext |
|
1748 |
self pReshape:nativeContext. |
|
1749 |
^ self. |
|
1750 |
||
1751 |
"Modified: / 15.8.1997 / 15:36:29 / cg" |
|
1752 |
"Created: / 7.1.1998 / 21:46:18 / cg" |
|
1753 |
! |
|
1754 |
||
1755 |
_WChoicePeer_select:nativeContext |
|
270 | 1756 |
|comboBox index| |
1757 |
||
1758 |
comboBox := self viewForWPeer:nativeContext. |
|
255 | 1759 |
|
1760 |
index := nativeContext argAt:1. |
|
270 | 1761 |
comboBox model selectionIndex:(index + 1). "/ JAVA indexing starts at 0 |
1762 |
||
255 | 1763 |
"Created: / 7.1.1998 / 21:45:43 / cg" |
270 | 1764 |
"Modified: / 25.1.1998 / 09:55:05 / cg" |
255 | 1765 |
! |
1766 |
||
253 | 1767 |
_WClipboard_init:nativeContext |
1768 |
"/ self halt. |
|
1769 |
||
1770 |
"Modified: / 18.3.1997 / 18:43:18 / cg" |
|
1771 |
"Created: / 4.1.1998 / 19:03:59 / cg" |
|
1772 |
! |
|
1773 |
||
1774 |
_WColor_getDefaultColor:nativeContext |
|
1775 |
|clrIndex jClr clr | |
|
1776 |
||
1777 |
clrIndex := nativeContext argAt:1. |
|
1778 |
"/ windows defaults: |
|
1779 |
"/ 1: view background |
|
1780 |
||
1781 |
clrIndex == 1 ifTrue:[ |
|
261 | 1782 |
clr := View defaultViewBackgroundColor. |
1783 |
clr isColor ifFalse:[ |
|
1784 |
clr := Color gray:50. |
|
1785 |
]. |
|
253 | 1786 |
]. |
1787 |
clrIndex == 2 ifTrue:[ |
|
261 | 1788 |
clr := Color black. |
253 | 1789 |
]. |
1790 |
clr isNil ifTrue:[ |
|
261 | 1791 |
self halt. |
1792 |
self internalError:'breakpoint'. |
|
1793 |
^ nil. |
|
253 | 1794 |
]. |
1795 |
||
1796 |
clr := clr on:(Screen current). |
|
1797 |
||
1798 |
jClr := (Java classForName:'java.awt.Color') new. |
|
1799 |
||
1800 |
jClr instVarNamed:'pData' put:clr. |
|
1801 |
jClr instVarNamed:'value' put:(clr rgbValue). |
|
1802 |
"/ self halt. |
|
1803 |
^ jClr. |
|
1804 |
||
1805 |
"Created: / 15.8.1997 / 15:38:10 / cg" |
|
1806 |
"Modified: / 4.1.1998 / 18:06:51 / cg" |
|
1807 |
! |
|
1808 |
||
255 | 1809 |
_WComponentPeer__dispose:nativeContext |
271 | 1810 |
|view jPeer| |
255 | 1811 |
|
1812 |
view := self viewForWPeer:nativeContext. |
|
1813 |
||
261 | 1814 |
Object errorSignal catch:[ |
271 | 1815 |
view destroy. |
261 | 1816 |
]. |
1817 |
JavaWindowGroup removeView:view. |
|
255 | 1818 |
|
271 | 1819 |
jPeer := nativeContext receiver. |
1820 |
jPeer instVarNamed:'pData' put:0. |
|
1821 |
||
255 | 1822 |
"Created: / 7.1.1998 / 22:36:25 / cg" |
271 | 1823 |
"Modified: / 25.1.1998 / 16:43:06 / cg" |
255 | 1824 |
! |
1825 |
||
253 | 1826 |
_WComponentPeer__setBackground:nativeContext |
255 | 1827 |
|rgb clr view| |
1828 |
||
1829 |
view := self viewForWPeer:nativeContext. |
|
253 | 1830 |
|
1831 |
rgb := nativeContext argAt:1. |
|
1832 |
clr := Color rgbValue:rgb. |
|
1833 |
||
1834 |
"/ self halt. |
|
1835 |
"/ self internalError:'breakPoint'. |
|
1836 |
||
1837 |
clr := clr on:(view device). |
|
1838 |
||
1839 |
"/ (view superView isMemberOf:JavaEmbeddedFrameView) ifTrue:[ |
|
1840 |
"/ view viewBackground:(view superView viewBackground). |
|
1841 |
"/ view backgroundPaint:(view superView viewBackground). |
|
1842 |
"/ ] ifFalse:[ |
|
1843 |
"/ (view isMemberOf:JavaView) ifTrue:[ |
|
1844 |
"/ view viewBackground:clr. |
|
1845 |
"/ view backgroundPaint:clr. |
|
1846 |
"/ ] |
|
1847 |
"/ ]. |
|
1848 |
||
261 | 1849 |
(view isKindOf:ScrollableView) ifTrue:[ |
270 | 1850 |
view := view scrolledView |
261 | 1851 |
]. |
253 | 1852 |
view viewBackground:clr. |
1853 |
view backgroundPaint:clr. |
|
1854 |
||
1855 |
"Created: / 4.1.1998 / 18:07:39 / cg" |
|
261 | 1856 |
"Modified: / 15.1.1998 / 13:06:44 / cg" |
253 | 1857 |
! |
1858 |
||
1859 |
_WComponentPeer__setForeground:nativeContext |
|
255 | 1860 |
|rgb clr view| |
1861 |
||
1862 |
view := self viewForWPeer:nativeContext. |
|
253 | 1863 |
|
1864 |
rgb := nativeContext argAt:1. |
|
1865 |
clr := Color rgbValue:rgb. |
|
1866 |
||
1867 |
"/ self halt. |
|
1868 |
"/ self internalError:'breakPoint'. |
|
1869 |
||
1870 |
clr := clr on:(view device). |
|
1871 |
||
1872 |
view paint:clr. |
|
1873 |
||
1874 |
"Created: / 4.1.1998 / 18:08:13 / cg" |
|
255 | 1875 |
"Modified: / 8.1.1998 / 17:32:45 / cg" |
1876 |
! |
|
1877 |
||
1878 |
_WComponentPeer_disable:nativeContext |
|
1879 |
|view| |
|
1880 |
||
1881 |
view := self viewForWPeer:nativeContext. |
|
1882 |
||
1883 |
Object errorSignal handle:[:ex | |
|
1884 |
] do:[ |
|
261 | 1885 |
view disable |
255 | 1886 |
] |
1887 |
||
1888 |
"Created: / 6.1.1998 / 18:26:36 / cg" |
|
1889 |
"Modified: / 8.1.1998 / 17:32:53 / cg" |
|
1890 |
! |
|
1891 |
||
261 | 1892 |
_WComponentPeer_enable:nativeContext |
1893 |
|view| |
|
1894 |
||
1895 |
view := self viewForWPeer:nativeContext. |
|
1896 |
||
1897 |
Object errorSignal handle:[:ex | |
|
1898 |
] do:[ |
|
1899 |
view enable |
|
1900 |
] |
|
1901 |
||
1902 |
"Modified: / 8.1.1998 / 17:32:53 / cg" |
|
1903 |
"Created: / 13.1.1998 / 23:08:05 / cg" |
|
1904 |
! |
|
1905 |
||
255 | 1906 |
_WComponentPeer_handleEvent:nativeContext |
261 | 1907 |
"this is invoked by java, to let a widget handle any event which |
1908 |
was not consumed (eaten) by java. |
|
1909 |
If the view in question is some ST-widget, forward it. |
|
1910 |
Ignore for JavaViews." |
|
1911 |
||
1912 |
|view jEv stEv| |
|
1913 |
||
1914 |
view := self viewForWPeer:nativeContext. |
|
1915 |
view notNil ifTrue:[ |
|
270 | 1916 |
(view isKindOf:JavaView) ifFalse:[ |
1917 |
jEv := nativeContext argAt:1. |
|
1918 |
stEv := jEv instVarNamed:'data'. |
|
1919 |
(stEv notNil and:[stEv ~~ 0]) ifTrue:[ |
|
261 | 1920 |
('JAVA: WComponent - handleEvent: ' , stEv type , ' for ' , view printString) infoPrintCR. |
270 | 1921 |
stEv sendEventWithFocusOn:nil. |
1922 |
^ self. |
|
1923 |
] |
|
1924 |
] |
|
261 | 1925 |
]. |
1926 |
('JAVA: WComponent - handleEvent ignored') infoPrintCR. |
|
1927 |
||
255 | 1928 |
"Created: / 6.1.1998 / 21:10:17 / cg" |
261 | 1929 |
"Modified: / 16.1.1998 / 14:35:33 / cg" |
255 | 1930 |
! |
1931 |
||
1932 |
_WComponentPeer_hide:nativeContext |
|
1933 |
|view| |
|
1934 |
||
1935 |
view := self viewForWPeer:nativeContext. |
|
1936 |
||
1937 |
Object errorSignal handle:[:ex | |
|
1938 |
] do:[ |
|
261 | 1939 |
view beInvisible |
255 | 1940 |
] |
1941 |
||
1942 |
"Created: / 7.1.1998 / 22:35:32 / cg" |
|
1943 |
"Modified: / 8.1.1998 / 17:33:08 / cg" |
|
1944 |
! |
|
1945 |
||
1946 |
_WComponentPeer_requestFocus:nativeContext |
|
1947 |
|view| |
|
1948 |
||
1949 |
view := self viewForWPeer:nativeContext. |
|
261 | 1950 |
'getFocus - ' print. view displayString printCR. |
255 | 1951 |
|
1952 |
view getKeyboardFocus |
|
1953 |
||
1954 |
"Created: / 7.1.1998 / 22:30:03 / cg" |
|
261 | 1955 |
"Modified: / 16.1.1998 / 14:42:32 / cg" |
253 | 1956 |
! |
1957 |
||
1958 |
_WComponentPeer_reshape:nativeContext |
|
1959 |
self commonReshapeComponent:nativeContext |
|
1960 |
||
1961 |
"Modified: / 18.3.1997 / 19:30:21 / cg" |
|
1962 |
"Created: / 4.1.1998 / 18:01:11 / cg" |
|
1963 |
! |
|
1964 |
||
1965 |
_WComponentPeer_setCursor:nativeContext |
|
270 | 1966 |
|view| |
1967 |
||
1968 |
view := self viewForWPeer:nativeContext. |
|
253 | 1969 |
"/ self halt. |
1970 |
||
1971 |
"Created: / 5.1.1998 / 01:52:30 / cg" |
|
270 | 1972 |
"Modified: / 25.1.1998 / 01:21:52 / cg" |
253 | 1973 |
! |
1974 |
||
1975 |
_WComponentPeer_setFont:nativeContext |
|
270 | 1976 |
|view| |
1977 |
||
1978 |
view := self viewForWPeer:nativeContext. |
|
253 | 1979 |
"/ self halt. |
1980 |
||
1981 |
"Created: / 5.1.1998 / 00:55:17 / cg" |
|
270 | 1982 |
"Modified: / 25.1.1998 / 01:22:19 / cg" |
253 | 1983 |
! |
1984 |
||
1985 |
_WComponentPeer_setZOrderPosition:nativeContext |
|
270 | 1986 |
|view| |
1987 |
||
1988 |
view := self viewForWPeer:nativeContext. |
|
253 | 1989 |
"/ self unimplementedNativeMethod. |
1990 |
"/ self halt. |
|
1991 |
"/ self internalError:'breakPoint' |
|
1992 |
||
1993 |
"Created: / 4.1.1998 / 17:59:26 / cg" |
|
270 | 1994 |
"Modified: / 25.1.1998 / 01:22:32 / cg" |
253 | 1995 |
! |
1996 |
||
1997 |
_WComponentPeer_show:nativeContext |
|
255 | 1998 |
|view| |
1999 |
||
2000 |
view := self viewForWPeer:nativeContext. |
|
2001 |
||
253 | 2002 |
"/ frame views are under my browsers own control |
2003 |
(view isMemberOf:JavaEmbeddedFrameView) ifFalse:[ |
|
270 | 2004 |
view beVisible. |
253 | 2005 |
view realize. |
2006 |
]. |
|
2007 |
||
2008 |
"/ view windowGroup notNil ifTrue:[ |
|
2009 |
"/ windowServer addGroup:(view windowGroup) |
|
2010 |
"/ ]. |
|
2011 |
||
2012 |
^ nil |
|
2013 |
||
2014 |
"/ self halt. |
|
2015 |
||
2016 |
"Created: / 5.1.1998 / 01:26:22 / cg" |
|
270 | 2017 |
"Modified: / 25.1.1998 / 09:54:07 / cg" |
253 | 2018 |
! |
2019 |
||
2020 |
_WComponentPeer_start:nativeContext |
|
2021 |
"/ self halt. |
|
2022 |
||
2023 |
"Modified: / 18.3.1997 / 18:43:18 / cg" |
|
2024 |
"Created: / 5.1.1998 / 00:58:40 / cg" |
|
2025 |
! |
|
2026 |
||
2027 |
_WDefaultFontCharset_canConvert:nativeContext |
|
2028 |
^ 1 |
|
2029 |
||
2030 |
"Modified: / 21.8.1997 / 15:56:57 / cg" |
|
2031 |
"Created: / 5.1.1998 / 01:55:47 / cg" |
|
2032 |
! |
|
2033 |
||
255 | 2034 |
_WDialogPeer__hide:nativeContext |
2035 |
|dialog| |
|
2036 |
||
2037 |
dialog := self viewForWPeer:nativeContext. |
|
2038 |
||
2039 |
dialog hide. |
|
2040 |
||
2041 |
"Created: / 7.1.1998 / 22:34:10 / cg" |
|
2042 |
"Modified: / 8.1.1998 / 17:34:10 / cg" |
|
2043 |
! |
|
2044 |
||
2045 |
_WDialogPeer__show:nativeContext |
|
2046 |
|dialog| |
|
2047 |
||
2048 |
dialog := self viewForWPeer:nativeContext. |
|
261 | 2049 |
"/ |
2050 |
"/ show does not work (yet); must setup windowgroup |
|
2051 |
"/ for it to get events ... |
|
2052 |
"/ dialog show. |
|
255 | 2053 |
dialog realize. |
2054 |
||
2055 |
"Created: / 7.1.1998 / 21:52:15 / cg" |
|
261 | 2056 |
"Modified: / 15.1.1998 / 15:57:03 / cg" |
255 | 2057 |
! |
2058 |
||
2059 |
_WDialogPeer_create:nativeContext |
|
2060 |
|jDialogPeer dialog| |
|
2061 |
||
2062 |
jDialogPeer := nativeContext receiver. |
|
2063 |
||
2064 |
dialog := ModalBox new. |
|
2065 |
jDialogPeer instVarNamed:'pData' put:dialog. |
|
2066 |
||
261 | 2067 |
self createdWindowsView:dialog for:jDialogPeer. |
2068 |
dialog windowGroup:JavaWindowGroup. |
|
2069 |
JavaWindowGroup addTopView:dialog. |
|
2070 |
||
255 | 2071 |
WindowCreationTrace == true ifTrue:[ |
270 | 2072 |
'WDialogPeer_create: ' print. dialog printNL. |
255 | 2073 |
]. |
2074 |
||
2075 |
"Created: / 7.1.1998 / 21:51:00 / cg" |
|
261 | 2076 |
"Modified: / 15.1.1998 / 16:12:44 / cg" |
255 | 2077 |
! |
2078 |
||
2079 |
_WFileDialogPeer_show:nativeContext |
|
261 | 2080 |
|jDialogPeer jDialog dialogView stDialog |
2081 |
title dir pattern f| |
|
255 | 2082 |
|
2083 |
jDialogPeer := nativeContext receiver. |
|
261 | 2084 |
jDialog := jDialogPeer instVarNamed:'target'. |
255 | 2085 |
dialogView := jDialogPeer instVarNamed:'pData'. |
2086 |
||
2087 |
stDialog := FileSelectionBox new. |
|
261 | 2088 |
|
2089 |
dir := jDialog instVarNamed:'dir'. |
|
2090 |
dir notNil ifTrue:[ |
|
270 | 2091 |
stDialog directory:(Java as_ST_String:dir). |
261 | 2092 |
]. |
2093 |
pattern := jDialog instVarNamed:'file'. |
|
2094 |
pattern notNil ifTrue:[ |
|
270 | 2095 |
stDialog pattern:(Java as_ST_String:pattern). |
261 | 2096 |
]. |
2097 |
title := jDialog instVarNamed:'title'. |
|
2098 |
title notNil ifTrue:[ |
|
270 | 2099 |
stDialog title:(Java as_ST_String:title). |
2100 |
stDialog label:(Java as_ST_String:title). |
|
261 | 2101 |
]. |
2102 |
||
255 | 2103 |
stDialog show. |
2104 |
||
2105 |
stDialog accepted ifTrue:[ |
|
270 | 2106 |
f := stDialog pathName. |
2107 |
||
2108 |
"/ cannot use the one below - it has a builtIn fileSeparator if '\' (sigh) |
|
2109 |
"/ jDialogPeer perform:#'handleSelected(Ljava/lang/String;)V' with:(Java as_String:f). |
|
2110 |
||
2111 |
jDialog |
|
2112 |
perform:#'setFile(Ljava/lang/String;)V' |
|
2113 |
with:(Java as_String:(f asFilename baseName)). |
|
2114 |
jDialog |
|
2115 |
perform:#'setDirectory(Ljava/lang/String;)V' |
|
2116 |
with:(Java as_String:(f asFilename directoryName , Filename separator asString)). |
|
2117 |
jDialog |
|
2118 |
perform:#'setVisible(Z)V' |
|
2119 |
with:0. |
|
255 | 2120 |
] ifFalse:[ |
270 | 2121 |
jDialogPeer |
2122 |
perform:#'handleCancel()V' |
|
255 | 2123 |
]. |
2124 |
"/ self halt. |
|
2125 |
||
2126 |
"Created: / 7.1.1998 / 22:38:45 / cg" |
|
261 | 2127 |
"Modified: / 15.1.1998 / 13:04:05 / cg" |
255 | 2128 |
! |
2129 |
||
253 | 2130 |
_WFontMetrics_getMFCharSegmentWidth:nativeContext |
2131 |
"get multi-font string-segment width. |
|
2132 |
Not yet supported - use standard strings width" |
|
2133 |
||
2134 |
|jMetrics jFont jFontDescr stFont w |
|
261 | 2135 |
bool1 cp offs lenght bp int1| |
253 | 2136 |
|
2137 |
jMetrics := nativeContext receiver. |
|
2138 |
jFont := nativeContext argAt:1. |
|
2139 |
jFontDescr := nativeContext argAt:2. |
|
2140 |
bool1 := nativeContext argAt:3. |
|
2141 |
cp := nativeContext argAt:4. |
|
261 | 2142 |
offs := nativeContext argAt:5. |
2143 |
lenght := nativeContext argAt:6. |
|
253 | 2144 |
bp := nativeContext argAt:7. |
2145 |
int1 := nativeContext argAt:8. |
|
2146 |
||
2147 |
stFont := jFont instVarNamed:'pData'. |
|
261 | 2148 |
(stFont isNil or:[stFont == 0]) ifTrue:[ |
2149 |
self halt |
|
2150 |
]. |
|
2151 |
||
253 | 2152 |
stFont device isNil ifTrue:[ |
261 | 2153 |
stFont := stFont on:Display. |
2154 |
jFont instVarNamed:'pData' put:stFont. |
|
2155 |
]. |
|
2156 |
w := stFont widthOf:cp from:offs+1 to:offs+lenght. |
|
253 | 2157 |
^ w. |
2158 |
||
2159 |
"Created: / 5.1.1998 / 01:57:45 / cg" |
|
261 | 2160 |
"Modified: / 13.1.1998 / 23:44:03 / cg" |
253 | 2161 |
! |
2162 |
||
2163 |
_WFontMetrics_init:nativeContext |
|
2164 |
|jMetrics jFont stFont widths family name style size| |
|
2165 |
||
2166 |
jMetrics := nativeContext receiver. |
|
2167 |
jFont := jMetrics instVarNamed:'font'. |
|
2168 |
||
2169 |
family := jFont instVarNamed:'family'. |
|
2170 |
family := Java as_ST_String:family. |
|
2171 |
||
2172 |
name := jFont instVarNamed:'name'. |
|
2173 |
name := Java as_ST_String:name. |
|
2174 |
||
2175 |
style := jFont instVarNamed:'style'. |
|
2176 |
size := jFont instVarNamed:'size'. |
|
2177 |
||
2178 |
stFont := Font family:family size:size. |
|
2179 |
stFont isNil ifTrue:[ |
|
261 | 2180 |
stFont := Font family:'helvetica' size:size. |
253 | 2181 |
]. |
2182 |
stFont := stFont on:Display. |
|
2183 |
||
2184 |
"/ stFont := jFont instVarNamed:'pData'. |
|
2185 |
"/ stFont isNil ifTrue:[ |
|
2186 |
"/ self halt |
|
2187 |
"/ ]. |
|
2188 |
||
2189 |
stFont := stFont on:Display. |
|
2190 |
jFont instVarNamed:'pData' put:stFont. |
|
2191 |
||
2192 |
jMetrics instVarNamed:'ascent' put:stFont ascent. |
|
2193 |
jMetrics instVarNamed:'descent' put:stFont descent. |
|
2194 |
jMetrics instVarNamed:'leading' put:0. |
|
2195 |
jMetrics instVarNamed:'height' put:stFont height. |
|
2196 |
jMetrics instVarNamed:'maxAscent' put:stFont maxAscent. |
|
2197 |
jMetrics instVarNamed:'maxDescent' put:stFont maxDescent. |
|
2198 |
jMetrics instVarNamed:'maxHeight' put:stFont maxHeight. |
|
2199 |
jMetrics instVarNamed:'maxAdvance' put:stFont maxWidth. |
|
2200 |
||
2201 |
widths := Array new:256. |
|
2202 |
0 to:255 do:[:i | |
|
261 | 2203 |
widths at:(i+1) put:(stFont widthOf:(Character value:i)) |
253 | 2204 |
]. |
2205 |
jMetrics instVarNamed:'widths' put:widths. |
|
2206 |
"/ self halt. |
|
2207 |
||
2208 |
"Modified: / 8.8.1997 / 12:06:53 / cg" |
|
2209 |
"Created: / 5.1.1998 / 01:54:29 / cg" |
|
2210 |
! |
|
2211 |
||
2212 |
_WFontMetrics_needsConversion:nativeContext |
|
2213 |
|jFont jFontDescr stFont| |
|
2214 |
||
2215 |
jFont := nativeContext argAt:1. |
|
2216 |
jFontDescr := nativeContext argAt:2. |
|
2217 |
||
2218 |
stFont := jFont instVarNamed:'pData'. |
|
2219 |
"/ stFont isNil ifTrue:[ |
|
2220 |
"/ self halt |
|
2221 |
"/ ]. |
|
2222 |
"/ stFont device isNil ifTrue:[ |
|
2223 |
"/ stFont := stFont on:Display. |
|
2224 |
"/ jFont instVarNamed:'pData' put:stFont. |
|
2225 |
"/ ]. |
|
2226 |
"/ |
|
2227 |
||
2228 |
^ 0 |
|
2229 |
||
2230 |
"Modified: / 17.8.1997 / 17:16:29 / cg" |
|
2231 |
"Created: / 5.1.1998 / 01:56:42 / cg" |
|
2232 |
! |
|
2233 |
||
2234 |
_WFramePeer_create:nativeContext |
|
277 | 2235 |
|jFramePeer jFrame frame pDataIdx| |
253 | 2236 |
|
2237 |
jFramePeer := nativeContext receiver. |
|
2238 |
||
2239 |
"/ for now: a kludge to create an embedded frame for |
|
2240 |
"/ mozillaFrames |
|
2241 |
||
2242 |
jFrame := jFramePeer instVarNamed:'target'. |
|
2243 |
(jFrame notNil |
|
277 | 2244 |
and:[(pDataIdx := jFrame class instVarOffsetOf:'pData') notNil]) |
253 | 2245 |
ifTrue:[ |
277 | 2246 |
((frame := jFrame instVarAt:pDataIdx) notNil |
2247 |
and:[frame ~~ 0]) ifTrue:[ |
|
2248 |
'JAVA: targetFrame view already created: ' infoPrintCR. |
|
2249 |
"/ sigh; pData was renamed to pNativeWidget in jdk1.2 ... |
|
2250 |
pDataIdx := jFramePeer class instVarOffsetOf:'pNativeWidget'. |
|
2251 |
pDataIdx isNil ifTrue:[ |
|
2252 |
"/ ok, we are < 1.2 |
|
2253 |
pDataIdx := jFramePeer class instVarOffsetOf:'pData'. |
|
2254 |
]. |
|
2255 |
jFramePeer instVarAt:pDataIdx put:frame. |
|
2256 |
] |
|
253 | 2257 |
] ifFalse:[ |
277 | 2258 |
frame := jFramePeer instVarNamed:'pData' |
253 | 2259 |
]. |
2260 |
||
2261 |
(frame notNil and:[frame ~~ 0]) ifTrue:[ |
|
277 | 2262 |
'JAVA: frame view already created: ' infoPrint. |
2263 |
jFramePeer class name infoPrintCR. |
|
253 | 2264 |
] ifFalse:[ |
277 | 2265 |
frame := StandardSystemView new. |
2266 |
self createdWindowsView:frame for:jFramePeer. |
|
2267 |
JavaWindowGroup addTopView:frame. |
|
253 | 2268 |
]. |
2269 |
||
2270 |
WindowCreationTrace == true ifTrue:[ |
|
277 | 2271 |
'JAVA: WFramePeer_create: ' print. jFramePeer displayString print. |
2272 |
' frame: ' print. frame printNL. |
|
253 | 2273 |
]. |
2274 |
||
2275 |
"Created: / 4.1.1998 / 17:56:39 / cg" |
|
277 | 2276 |
"Modified: / 27.1.1998 / 21:35:15 / cg" |
253 | 2277 |
! |
2278 |
||
255 | 2279 |
_WFramePeer_setMenuBar0:nativeContext |
2280 |
|frame jMenuBarPeer menuPanel| |
|
2281 |
||
2282 |
frame := self viewForWPeer:nativeContext. |
|
2283 |
||
2284 |
jMenuBarPeer := nativeContext argAt:1. |
|
2285 |
jMenuBarPeer isNil ifTrue:[ |
|
261 | 2286 |
"/ mhmh - JAVA wants to remove the frames menuPanel. |
2287 |
"/ but I have no handle on it (for destroy). |
|
2288 |
"/ search it in subViews of the frame. |
|
2289 |
frame subViews copy do:[:v | |
|
2290 |
(v isKindOf:MenuPanel) ifTrue:[ |
|
2291 |
v destroy |
|
2292 |
] |
|
2293 |
] |
|
255 | 2294 |
] ifFalse:[ |
261 | 2295 |
menuPanel := jMenuBarPeer instVarNamed:'pData'. |
2296 |
||
2297 |
menuPanel origin:0.0@0.0 corner:1.0@(menuPanel preferredExtent y). |
|
2298 |
frame addSubView:menuPanel. |
|
255 | 2299 |
]. |
2300 |
^ nil |
|
2301 |
||
2302 |
"Created: / 7.1.1998 / 21:41:35 / cg" |
|
2303 |
"Modified: / 8.1.1998 / 17:35:04 / cg" |
|
2304 |
! |
|
2305 |
||
2306 |
_WGraphics_changeClip:nativeContext |
|
262 | 2307 |
|gc x y w h bool| |
255 | 2308 |
|
2309 |
gc := self gcForWGraphics:nativeContext. |
|
262 | 2310 |
|
2311 |
"/ ignored for now; |
|
2312 |
"/ Clock does incorrect repaints if enabled. |
|
2313 |
"/ TODO: fix that ... |
|
2314 |
||
270 | 2315 |
x := nativeContext argAt:1. |
2316 |
y := nativeContext argAt:2. |
|
2317 |
w := nativeContext argAt:3. |
|
2318 |
h := nativeContext argAt:4. |
|
2319 |
bool := (nativeContext argAt:5) ~~ 0. |
|
2320 |
||
262 | 2321 |
"/ gc clipRect:(Rectangle left:x top:y width:w height:h). |
255 | 2322 |
|
2323 |
"Created: / 6.1.1998 / 20:57:21 / cg" |
|
270 | 2324 |
"Modified: / 25.1.1998 / 12:51:55 / cg" |
255 | 2325 |
! |
2326 |
||
2327 |
_WGraphics_clearRect:nativeContext |
|
2328 |
|gc x y w h| |
|
2329 |
||
2330 |
gc := self gcForWGraphics:nativeContext. |
|
2331 |
"/ gc isNil ifTrue:[^ self]. |
|
2332 |
||
2333 |
gc realized ifFalse:[ |
|
261 | 2334 |
'JAVA: drawing on unrealized gc - ignored' infoPrintCR. |
2335 |
^ self |
|
255 | 2336 |
]. |
2337 |
||
2338 |
x := nativeContext argAt:1. |
|
2339 |
y := nativeContext argAt:2. |
|
2340 |
w := nativeContext argAt:3. |
|
2341 |
h := nativeContext argAt:4. |
|
2342 |
||
2343 |
"/ self halt. |
|
2344 |
"/ self internalError:'breakPoint'. |
|
2345 |
||
2346 |
gc clearRectangleX:x y:y width:w height:h. |
|
2347 |
||
2348 |
"Created: / 8.1.1998 / 00:16:00 / cg" |
|
2349 |
"Modified: / 8.1.1998 / 00:21:09 / cg" |
|
2350 |
! |
|
2351 |
||
2352 |
_WGraphics_createFromComponent:nativeContext |
|
261 | 2353 |
|jGraphics jWin view| |
255 | 2354 |
|
2355 |
jGraphics := nativeContext receiver. |
|
261 | 2356 |
jWin := nativeContext argAt:1. |
2357 |
||
2358 |
view := KnownWindows at:jWin ifAbsent:nil. |
|
255 | 2359 |
view isNil ifTrue:[ |
270 | 2360 |
self halt. |
2361 |
^ self |
|
255 | 2362 |
]. |
2363 |
||
2364 |
"/ "/ just a consistency check ... |
|
261 | 2365 |
"/ (jWin instVarNamed:'xid') ~~ view ifTrue:[ |
255 | 2366 |
"/ self halt:'consistency check' |
2367 |
"/ ]. |
|
2368 |
||
2369 |
jGraphics instVarNamed:'pData' put:view. |
|
2370 |
||
2371 |
"Created: / 6.1.1998 / 20:55:18 / cg" |
|
261 | 2372 |
"Modified: / 15.1.1998 / 13:49:56 / cg" |
255 | 2373 |
! |
2374 |
||
2375 |
_WGraphics_createFromGraphics:nativeContext |
|
2376 |
|jGraphics graphics gc| |
|
2377 |
||
2378 |
jGraphics := nativeContext receiver. |
|
2379 |
graphics := nativeContext argAt:1. |
|
2380 |
gc := graphics instVarNamed:'pData'. |
|
2381 |
||
2382 |
jGraphics instVarNamed:'pData' put:gc. |
|
2383 |
||
2384 |
"Created: / 8.1.1998 / 00:47:39 / cg" |
|
270 | 2385 |
"Modified: / 25.1.1998 / 10:57:25 / cg" |
255 | 2386 |
! |
2387 |
||
2388 |
_WGraphics_dispose:nativeContext |
|
2389 |
|gc| |
|
2390 |
||
2391 |
gc := self gcForWGraphics:nativeContext. |
|
2392 |
gc isNil ifTrue:[^ self]. |
|
2393 |
||
2394 |
"Created: / 6.1.1998 / 20:58:38 / cg" |
|
2395 |
"Modified: / 8.1.1998 / 00:19:09 / cg" |
|
2396 |
! |
|
2397 |
||
2398 |
_WGraphics_drawArc:nativeContext |
|
2399 |
|gc x y w h startAngle endAngle| |
|
2400 |
||
2401 |
gc := self gcForWGraphics:nativeContext. |
|
2402 |
"/ gc isNil ifTrue:[^ self]. |
|
2403 |
gc realized ifFalse:[^ self]. |
|
2404 |
||
2405 |
x := nativeContext argAt:1. |
|
2406 |
y := nativeContext argAt:2. |
|
2407 |
w := nativeContext argAt:3. |
|
2408 |
h := nativeContext argAt:4. |
|
2409 |
startAngle := nativeContext argAt:5. |
|
2410 |
endAngle := nativeContext argAt:6. |
|
2411 |
||
2412 |
DrawOPTrace ifTrue:[ |
|
261 | 2413 |
'drawArc x/y= ' print. x print. '@' print. y print. |
2414 |
' w/h= ' print. w print. '@' print. h print. |
|
2415 |
' startAngle= ' print. startAngle print. ' endAngle= ' print. endAngle printCR. |
|
255 | 2416 |
]. |
2417 |
gc displayArcX:x y:y width:w height:h from:startAngle angle:(endAngle - startAngle) |
|
2418 |
||
2419 |
"Created: / 6.1.1998 / 21:00:15 / cg" |
|
2420 |
"Modified: / 8.1.1998 / 00:20:56 / cg" |
|
2421 |
! |
|
2422 |
||
2423 |
_WGraphics_drawLine:nativeContext |
|
2424 |
|gc x y x2 y2| |
|
2425 |
||
2426 |
gc := self gcForWGraphics:nativeContext. |
|
2427 |
"/ gc isNil ifTrue:[^ self]. |
|
2428 |
gc realized ifFalse:[^ self]. |
|
2429 |
||
2430 |
x := nativeContext argAt:1. |
|
2431 |
y := nativeContext argAt:2. |
|
2432 |
x2 := nativeContext argAt:3. |
|
2433 |
y2 := nativeContext argAt:4. |
|
2434 |
||
2435 |
DrawOPTrace ifTrue:[ |
|
261 | 2436 |
'drawLine x/y= ' print. x print. '@' print. y print. ' x2/y2= ' print. x2 print. '@' print. y2 printCR. |
255 | 2437 |
]. |
2438 |
gc displayLineFromX:x y:y toX:x2 y:y2 |
|
2439 |
||
2440 |
"Created: / 6.1.1998 / 20:59:27 / cg" |
|
2441 |
"Modified: / 8.1.1998 / 00:34:23 / cg" |
|
2442 |
! |
|
2443 |
||
2444 |
_WGraphics_drawMFCharsSegment:nativeContext |
|
2445 |
|jFont jFontDescr s gc x y offs len| |
|
2446 |
||
2447 |
gc := self gcForWGraphics:nativeContext. |
|
2448 |
gc realized ifFalse:[^ self]. |
|
2449 |
||
2450 |
jFont := nativeContext argAt:1. |
|
2451 |
jFontDescr := nativeContext argAt:2. |
|
2452 |
s := nativeContext argAt:3. |
|
2453 |
offs := nativeContext argAt:4. |
|
2454 |
len := nativeContext argAt:5. |
|
2455 |
x := nativeContext argAt:6. |
|
2456 |
y := nativeContext argAt:7. |
|
2457 |
||
2458 |
DrawOPTrace ifTrue:[ |
|
272 | 2459 |
'drawMFCharsSegment x/y= ' print. x print. '@' print. y print. ' s= ' print. s printCR. |
255 | 2460 |
]. |
2461 |
gc displayString:s from:offs+1 to:offs+len x:x y:y. |
|
272 | 2462 |
^ (gc font onDevice:(gc graphicsDevice)) widthOf:s. |
255 | 2463 |
|
2464 |
"Created: / 6.1.1998 / 21:01:07 / cg" |
|
272 | 2465 |
"Modified: / 25.1.1998 / 20:45:55 / cg" |
255 | 2466 |
! |
2467 |
||
2468 |
_WGraphics_drawOval:nativeContext |
|
2469 |
|gc x y w h| |
|
2470 |
||
2471 |
gc := self gcForWGraphics:nativeContext. |
|
2472 |
"/ gc isNil ifTrue:[^ self]. |
|
2473 |
gc realized ifFalse:[^ self]. |
|
2474 |
||
2475 |
x := nativeContext argAt:1. |
|
2476 |
y := nativeContext argAt:2. |
|
2477 |
w := nativeContext argAt:3. |
|
2478 |
h := nativeContext argAt:4. |
|
2479 |
||
2480 |
DrawOPTrace ifTrue:[ |
|
261 | 2481 |
'drawOval x/y= ' print. x print. '@' print. y print. |
2482 |
' w/h= ' print. w print. '@' print. h printCR. |
|
255 | 2483 |
]. |
2484 |
gc displayArcX:x y:y width:w height:h from:0 angle:360 |
|
2485 |
||
2486 |
"Created: / 8.1.1998 / 00:44:31 / cg" |
|
2487 |
"Modified: / 8.1.1998 / 00:44:55 / cg" |
|
2488 |
! |
|
2489 |
||
2490 |
_WGraphics_drawPolygon:nativeContext |
|
2491 |
|gc xVector yVector count points| |
|
2492 |
||
2493 |
gc := self gcForWGraphics:nativeContext. |
|
2494 |
"/ gc isNil ifTrue:[^ self]. |
|
2495 |
gc realized ifFalse:[^ self]. |
|
2496 |
||
2497 |
xVector := nativeContext argAt:1. |
|
2498 |
yVector := nativeContext argAt:2. |
|
2499 |
count := nativeContext argAt:3. |
|
2500 |
||
2501 |
DrawOPTrace ifTrue:[ |
|
261 | 2502 |
'drawPolgon' printCR. |
255 | 2503 |
]. |
2504 |
||
2505 |
points := (1 to:count) collect:[:i | (xVector at:i) @ (yVector at:i)]. |
|
2506 |
gc displayPolygon:points |
|
2507 |
||
2508 |
"Created: / 8.1.1998 / 00:57:28 / cg" |
|
2509 |
"Modified: / 8.1.1998 / 00:57:49 / cg" |
|
2510 |
! |
|
2511 |
||
2512 |
_WGraphics_drawRect:nativeContext |
|
2513 |
|gc x y w h| |
|
2514 |
||
2515 |
gc := self gcForWGraphics:nativeContext. |
|
2516 |
"/ gc isNil ifTrue:[^ self]. |
|
2517 |
gc realized ifFalse:[^ self]. |
|
2518 |
||
2519 |
x := nativeContext argAt:1. |
|
2520 |
y := nativeContext argAt:2. |
|
2521 |
w := nativeContext argAt:3. |
|
2522 |
h := nativeContext argAt:4. |
|
2523 |
||
2524 |
"/ self halt. |
|
2525 |
"/ self internalError:'breakPoint'. |
|
2526 |
||
2527 |
gc displayRectangleX:x y:y width:w height:h. |
|
2528 |
||
2529 |
"Modified: / 8.1.1998 / 00:34:33 / cg" |
|
2530 |
"Created: / 8.1.1998 / 00:59:05 / cg" |
|
2531 |
! |
|
2532 |
||
2533 |
_WGraphics_drawRoundRect:nativeContext |
|
2534 |
|gc x y w h| |
|
2535 |
||
2536 |
gc := self gcForWGraphics:nativeContext. |
|
2537 |
"/ gc isNil ifTrue:[^ self]. |
|
2538 |
gc realized ifFalse:[^ self]. |
|
2539 |
||
2540 |
x := nativeContext argAt:1. |
|
2541 |
y := nativeContext argAt:2. |
|
2542 |
w := nativeContext argAt:3. |
|
2543 |
h := nativeContext argAt:4. |
|
2544 |
||
2545 |
"/ self halt. |
|
2546 |
"/ self internalError:'breakPoint'. |
|
2547 |
||
2548 |
gc displayRectangleX:x y:y width:w height:h. |
|
2549 |
||
2550 |
"Modified: / 8.1.1998 / 00:34:33 / cg" |
|
2551 |
"Created: / 8.1.1998 / 00:59:26 / cg" |
|
2552 |
! |
|
2553 |
||
2554 |
_WGraphics_fillArc:nativeContext |
|
2555 |
|gc x y w h startAngle endAngle| |
|
2556 |
||
2557 |
gc := self gcForWGraphics:nativeContext. |
|
2558 |
"/ gc isNil ifTrue:[^ self]. |
|
2559 |
gc realized ifFalse:[^ self]. |
|
2560 |
||
2561 |
x := nativeContext argAt:1. |
|
2562 |
y := nativeContext argAt:2. |
|
2563 |
w := nativeContext argAt:3. |
|
2564 |
h := nativeContext argAt:4. |
|
2565 |
startAngle := nativeContext argAt:5. |
|
2566 |
endAngle := nativeContext argAt:6. |
|
2567 |
||
2568 |
DrawOPTrace ifTrue:[ |
|
261 | 2569 |
'fillArc x/y= ' print. x print. '@' print. y print. |
2570 |
' w/h= ' print. w print. '@' print. h print. |
|
2571 |
' startAngle= ' print. startAngle print. ' endAngle= ' print. endAngle printCR. |
|
255 | 2572 |
]. |
2573 |
gc fillArcX:x y:y width:w height:h from:startAngle angle:(endAngle - startAngle) |
|
2574 |
||
2575 |
"Created: / 6.1.1998 / 21:11:31 / cg" |
|
2576 |
"Modified: / 8.1.1998 / 00:33:59 / cg" |
|
2577 |
! |
|
2578 |
||
2579 |
_WGraphics_fillOval:nativeContext |
|
2580 |
|gc x y w h| |
|
2581 |
||
2582 |
gc := self gcForWGraphics:nativeContext. |
|
2583 |
"/ gc isNil ifTrue:[^ self]. |
|
2584 |
gc realized ifFalse:[^ self]. |
|
2585 |
||
2586 |
x := nativeContext argAt:1. |
|
2587 |
y := nativeContext argAt:2. |
|
2588 |
w := nativeContext argAt:3. |
|
2589 |
h := nativeContext argAt:4. |
|
2590 |
||
2591 |
DrawOPTrace ifTrue:[ |
|
261 | 2592 |
'drawOval x/y= ' print. x print. '@' print. y print. |
2593 |
' w/h= ' print. w print. '@' print. h printCR. |
|
255 | 2594 |
]. |
2595 |
gc fillArcX:x y:y width:w height:h from:0 angle:360 |
|
2596 |
||
2597 |
"Created: / 8.1.1998 / 00:46:00 / cg" |
|
2598 |
"Modified: / 8.1.1998 / 00:46:20 / cg" |
|
2599 |
! |
|
2600 |
||
2601 |
_WGraphics_fillPolygon:nativeContext |
|
2602 |
|gc xVector yVector count points| |
|
2603 |
||
2604 |
gc := self gcForWGraphics:nativeContext. |
|
2605 |
"/ gc isNil ifTrue:[^ self]. |
|
2606 |
gc realized ifFalse:[^ self]. |
|
2607 |
||
2608 |
xVector := nativeContext argAt:1. |
|
2609 |
yVector := nativeContext argAt:2. |
|
2610 |
count := nativeContext argAt:3. |
|
2611 |
||
2612 |
DrawOPTrace ifTrue:[ |
|
270 | 2613 |
'fillPolgon' printCR. |
2614 |
]. |
|
2615 |
||
2616 |
points := (1 to:count-1) collect:[:i | (xVector at:i) @ (yVector at:i)]. |
|
255 | 2617 |
gc fillPolygon:points |
2618 |
||
2619 |
"Created: / 8.1.1998 / 00:58:09 / cg" |
|
270 | 2620 |
"Modified: / 25.1.1998 / 11:03:19 / cg" |
255 | 2621 |
! |
2622 |
||
2623 |
_WGraphics_fillRect:nativeContext |
|
2624 |
|gc x y w h| |
|
2625 |
||
2626 |
gc := self gcForWGraphics:nativeContext. |
|
2627 |
"/ gc isNil ifTrue:[^ self]. |
|
2628 |
gc realized ifFalse:[^ self]. |
|
2629 |
||
2630 |
x := nativeContext argAt:1. |
|
2631 |
y := nativeContext argAt:2. |
|
2632 |
w := nativeContext argAt:3. |
|
2633 |
h := nativeContext argAt:4. |
|
2634 |
||
2635 |
"/ self halt. |
|
2636 |
"/ self internalError:'breakPoint'. |
|
2637 |
||
2638 |
gc fillRectangleX:x y:y width:w height:h. |
|
2639 |
||
2640 |
"Created: / 15.8.1997 / 15:43:10 / cg" |
|
2641 |
"Modified: / 8.1.1998 / 00:34:33 / cg" |
|
2642 |
! |
|
2643 |
||
2644 |
_WGraphics_fillRoundRect:nativeContext |
|
2645 |
|gc x y w h| |
|
2646 |
||
2647 |
gc := self gcForWGraphics:nativeContext. |
|
2648 |
"/ gc isNil ifTrue:[^ self]. |
|
2649 |
gc realized ifFalse:[^ self]. |
|
2650 |
||
2651 |
x := nativeContext argAt:1. |
|
2652 |
y := nativeContext argAt:2. |
|
2653 |
w := nativeContext argAt:3. |
|
2654 |
h := nativeContext argAt:4. |
|
2655 |
||
2656 |
"/ self halt. |
|
2657 |
"/ self internalError:'breakPoint'. |
|
2658 |
||
2659 |
gc displayRectangleX:x y:y width:w height:h. |
|
2660 |
||
2661 |
"Modified: / 8.1.1998 / 00:34:33 / cg" |
|
2662 |
"Created: / 8.1.1998 / 00:59:36 / cg" |
|
2663 |
! |
|
2664 |
||
2665 |
_WGraphics_getClipBounds:nativeContext |
|
262 | 2666 |
|gc rect r x y w h| |
255 | 2667 |
|
2668 |
gc := self gcForWGraphics:nativeContext. |
|
2669 |
"/ gc isNil ifTrue:[^ self]. |
|
2670 |
||
2671 |
rect := (Java classForName:'java.awt.Rectangle') basicNew. |
|
2672 |
||
2673 |
(gc isMemberOf:JavaView) ifTrue:[ |
|
270 | 2674 |
r := gc getNextUpdateRectangle. |
2675 |
r isNil ifTrue:[ |
|
2676 |
x := y := 0. |
|
2677 |
w := (gc width). |
|
2678 |
h := (gc height). |
|
2679 |
] ifFalse:[ |
|
2680 |
x := (r left). |
|
2681 |
y := (r top). |
|
2682 |
w := (r width). |
|
2683 |
h := (r height). |
|
2684 |
] |
|
255 | 2685 |
] ifFalse:[ |
270 | 2686 |
x := y := 0. |
262 | 2687 |
"/ w := h := 9999. |
270 | 2688 |
w := (gc width). |
2689 |
h := (gc height). |
|
262 | 2690 |
]. |
2691 |
rect instVarNamed:'x' put:x. |
|
2692 |
rect instVarNamed:'y' put:y. |
|
2693 |
rect instVarNamed:'width' put:w. |
|
2694 |
rect instVarNamed:'height' put:h. |
|
255 | 2695 |
|
2696 |
"/ 'JAVA: getClipBounds' infoPrintCR. |
|
2697 |
"/ self halt. |
|
2698 |
||
2699 |
^ rect |
|
2700 |
||
2701 |
"Created: / 6.1.1998 / 20:58:07 / cg" |
|
262 | 2702 |
"Modified: / 17.1.1998 / 12:08:48 / cg" |
255 | 2703 |
! |
2704 |
||
2705 |
_WGraphics_imageCreate:nativeContext |
|
262 | 2706 |
|jGraphics imgRep| |
2707 |
||
2708 |
jGraphics := nativeContext receiver. |
|
255 | 2709 |
imgRep := nativeContext argAt:1. |
2710 |
||
262 | 2711 |
jGraphics instVarNamed:'pData' put:(imgRep instVarNamed:'pData'). |
2712 |
"/ self halt. |
|
2713 |
||
255 | 2714 |
"Created: / 11.1.1998 / 16:34:30 / cg" |
262 | 2715 |
"Modified: / 17.1.1998 / 12:37:18 / cg" |
255 | 2716 |
! |
2717 |
||
2718 |
_WGraphics_pSetFont:nativeContext |
|
261 | 2719 |
|gc jFont stFont| |
255 | 2720 |
|
2721 |
gc := self gcForWGraphics:nativeContext. |
|
261 | 2722 |
jFont := nativeContext argAt:1. |
2723 |
||
2724 |
stFont := jFont instVarNamed:'pData'. |
|
2725 |
(stFont isNil or:[stFont == 0]) ifTrue:[ |
|
255 | 2726 |
"/ self halt. |
261 | 2727 |
] ifFalse:[ |
270 | 2728 |
gc font:stFont |
261 | 2729 |
]. |
255 | 2730 |
|
2731 |
"Created: / 6.1.1998 / 20:56:47 / cg" |
|
261 | 2732 |
"Modified: / 15.1.1998 / 12:31:20 / cg" |
255 | 2733 |
! |
2734 |
||
2735 |
_WGraphics_pSetForeground:nativeContext |
|
2736 |
|gc rgb clr| |
|
2737 |
||
2738 |
gc := self gcForWGraphics:nativeContext. |
|
2739 |
||
2740 |
rgb := nativeContext argAt:1. |
|
2741 |
||
2742 |
clr := Color rgbValue:rgb. |
|
2743 |
gc paint:clr. |
|
2744 |
||
2745 |
"/ self halt. |
|
2746 |
"/ self internalError:'breakPoint'. |
|
2747 |
||
2748 |
"Created: / 6.1.1998 / 20:56:14 / cg" |
|
2749 |
"Modified: / 8.1.1998 / 00:34:51 / cg" |
|
2750 |
! |
|
2751 |
||
2752 |
_WGraphics_setPaintMode:nativeContext |
|
2753 |
|gc| |
|
2754 |
||
2755 |
gc := self gcForWGraphics:nativeContext. |
|
270 | 2756 |
gc function:#copy. |
2757 |
Transcript showCR:'copy ...'. |
|
255 | 2758 |
|
2759 |
"Created: / 8.1.1998 / 00:33:44 / cg" |
|
270 | 2760 |
"Modified: / 24.1.1998 / 19:20:16 / cg" |
255 | 2761 |
! |
2762 |
||
2763 |
_WGraphics_setXORMode:nativeContext |
|
270 | 2764 |
|gc jColor rgb invColor device| |
255 | 2765 |
|
2766 |
gc := self gcForWGraphics:nativeContext. |
|
270 | 2767 |
jColor := nativeContext argAt:1. |
2768 |
||
2769 |
"/ on trueColor systems, use the provided |
|
2770 |
"/ rgb value for inverting. |
|
2771 |
"/ on palette systems, use white ^ black |
|
2772 |
||
2773 |
device := gc graphicsDevice. |
|
2774 |
device visualType == #TrueColor ifTrue:[ |
|
2775 |
rgb := jColor instVarNamed:'value'. |
|
2776 |
rgb := rgb bitAnd:16rFFFFFF. |
|
2777 |
rgb == 0 ifTrue:[ |
|
2778 |
rgb := 16rFFFFFF. |
|
2779 |
]. |
|
2780 |
invColor := rgb |
|
2781 |
] ifFalse:[ |
|
2782 |
invColor := device blackpixel bitXor:device whitepixel. |
|
2783 |
]. |
|
2784 |
gc function:#xor. |
|
2785 |
gc paint:(Color colorId:invColor). |
|
2786 |
||
255 | 2787 |
"Created: / 8.1.1998 / 00:36:17 / cg" |
270 | 2788 |
"Modified: / 24.1.1998 / 19:54:55 / cg" |
255 | 2789 |
! |
2790 |
||
2791 |
_WLabelPeer_create:nativeContext |
|
2792 |
|jLabelPeer jLabel jFrame frame label |
|
2793 |
lbl| |
|
2794 |
||
2795 |
jLabelPeer := nativeContext receiver. |
|
2796 |
jLabel := jLabelPeer instVarNamed:'target'. |
|
2797 |
||
2798 |
lbl := jLabel instVarNamed:'text'. |
|
2799 |
lbl notNil ifTrue:[ |
|
261 | 2800 |
lbl := Java as_ST_String:lbl |
255 | 2801 |
]. |
2802 |
||
2803 |
jFrame := nativeContext argAt:1. |
|
2804 |
frame := jFrame instVarNamed:'pData'. |
|
2805 |
||
2806 |
label := Label in:frame. |
|
2807 |
lbl notNil ifTrue:[ |
|
261 | 2808 |
label label:lbl |
255 | 2809 |
]. |
2810 |
self createdWindowsView:label for:jLabelPeer. |
|
2811 |
||
2812 |
WindowCreationTrace == true ifTrue:[ |
|
261 | 2813 |
'WLabelPeer_create: ' print. frame print. ' -> ' print. label printNL. |
2814 |
]. |
|
2815 |
||
255 | 2816 |
"Created: / 7.1.1998 / 21:42:31 / cg" |
261 | 2817 |
"Modified: / 13.1.1998 / 22:10:47 / cg" |
255 | 2818 |
! |
2819 |
||
2820 |
_WLabelPeer_setAlignment:nativeContext |
|
2821 |
|label alignNr| |
|
2822 |
||
2823 |
alignNr := nativeContext argAt:1. |
|
2824 |
label := self viewForWPeer:nativeContext. |
|
2825 |
label notNil ifTrue:[ |
|
2826 |
]. |
|
2827 |
||
2828 |
"Created: / 7.1.1998 / 21:43:12 / cg" |
|
2829 |
"Modified: / 8.1.1998 / 17:35:29 / cg" |
|
2830 |
! |
|
2831 |
||
2832 |
_WLabelPeer_setText:nativeContext |
|
2833 |
|label jString| |
|
2834 |
||
2835 |
jString := nativeContext argAt:1. |
|
2836 |
||
2837 |
label := self viewForWPeer:nativeContext. |
|
2838 |
label label:(Java as_ST_String:jString) |
|
2839 |
||
2840 |
"Created: / 7.1.1998 / 21:43:51 / cg" |
|
2841 |
"Modified: / 8.1.1998 / 17:35:50 / cg" |
|
2842 |
! |
|
2843 |
||
270 | 2844 |
_WListPeer_addItem:nativeContext |
2845 |
|jString index selListView| |
|
2846 |
||
2847 |
selListView := self viewForWPeer:nativeContext. |
|
2848 |
||
2849 |
jString := nativeContext argAt:1. |
|
2850 |
index := nativeContext argAt:2. |
|
2851 |
||
2852 |
selListView model list addLast:(Java as_ST_String:jString). |
|
2853 |
selListView model changed:#list. |
|
2854 |
||
2855 |
"Modified: / 24.1.1998 / 18:51:32 / cg" |
|
2856 |
"Created: / 24.1.1998 / 21:10:05 / cg" |
|
2857 |
! |
|
2858 |
||
2859 |
_WListPeer_create:nativeContext |
|
2860 |
|jListPeer jFrame frame selectionInListView| |
|
2861 |
||
2862 |
jListPeer := nativeContext receiver. |
|
2863 |
||
2864 |
jFrame := nativeContext argAt:1. |
|
2865 |
frame := jFrame instVarNamed:'pData'. |
|
2866 |
||
2867 |
selectionInListView := ScrollableView for:SelectionInListView in:frame. |
|
2868 |
selectionInListView action:[:index | jListPeer perform:#'handleListChanged(I)V' with:(index - 1)]. |
|
2869 |
selectionInListView doubleClickAction:[:index | jListPeer perform:#'handleAction(I)V' with:(index - 1)]. |
|
2870 |
selectionInListView model:(SelectionInList new list:(OrderedCollection new)). |
|
2871 |
selectionInListView useIndex:true. |
|
2872 |
||
2873 |
self createdWindowsView:selectionInListView for:jListPeer. |
|
2874 |
||
2875 |
WindowCreationTrace == true ifTrue:[ |
|
2876 |
'WTextAreaPeer_create: ' print. frame print. ' -> ' print. selectionInListView printNL. |
|
2877 |
]. |
|
2878 |
||
2879 |
"Created: / 24.1.1998 / 19:58:54 / cg" |
|
2880 |
"Modified: / 25.1.1998 / 01:29:40 / cg" |
|
2881 |
! |
|
2882 |
||
2883 |
_WListPeer_isSelected:nativeContext |
|
2884 |
|selectionInListView index model| |
|
2885 |
||
2886 |
selectionInListView := self viewForWPeer:nativeContext. |
|
2887 |
||
2888 |
index := nativeContext argAt:1. |
|
2889 |
(model := selectionInListView model) notNil ifTrue:[ |
|
2890 |
(model selectionIndex == (index + 1)) "/ JAVA indexing starts at 0 |
|
2891 |
ifTrue:[ |
|
2892 |
^ 1 |
|
2893 |
] |
|
2894 |
]. |
|
2895 |
^ 0. |
|
2896 |
||
2897 |
"Created: / 24.1.1998 / 22:42:31 / cg" |
|
2898 |
"Modified: / 25.1.1998 / 01:35:32 / cg" |
|
2899 |
! |
|
2900 |
||
2901 |
_WListPeer_select:nativeContext |
|
2902 |
|selectionInListView index model| |
|
2903 |
||
2904 |
selectionInListView := self viewForWPeer:nativeContext. |
|
2905 |
||
2906 |
index := nativeContext argAt:1. |
|
2907 |
(model := selectionInListView model) notNil ifTrue:[ |
|
2908 |
model selectionIndex:(index + 1). "/ JAVA indexing starts at 0 |
|
2909 |
] |
|
2910 |
||
2911 |
"Created: / 24.1.1998 / 22:32:35 / cg" |
|
2912 |
"Modified: / 25.1.1998 / 01:28:46 / cg" |
|
2913 |
! |
|
2914 |
||
2915 |
_WListPeer_setMultipleSelections:nativeContext |
|
2916 |
|selectionInListView onOff| |
|
2917 |
||
2918 |
selectionInListView := self viewForWPeer:nativeContext. |
|
2919 |
||
2920 |
onOff := (nativeContext argAt:1) ~~ 0. |
|
2921 |
||
2922 |
selectionInListView multipleSelectOk:onOff. |
|
2923 |
||
2924 |
"Modified: / 24.1.1998 / 20:01:06 / cg" |
|
2925 |
! |
|
2926 |
||
255 | 2927 |
_WMenuBarPeer_create:nativeContext |
2928 |
|jMenuBarPeer jMenuBar jFrame frame menuBar| |
|
2929 |
||
2930 |
jMenuBarPeer := nativeContext receiver. |
|
2931 |
jMenuBar := jMenuBarPeer instVarNamed:'target'. |
|
2932 |
||
2933 |
jFrame := nativeContext argAt:1. |
|
2934 |
frame := jFrame instVarNamed:'pData'. |
|
2935 |
||
2936 |
menuBar := MenuPanel in:frame. |
|
2937 |
menuBar verticalLayout:false. |
|
270 | 2938 |
menuBar realize. |
255 | 2939 |
|
2940 |
self createdWindowsView:menuBar for:jMenuBarPeer. |
|
2941 |
||
2942 |
WindowCreationTrace == true ifTrue:[ |
|
270 | 2943 |
'WMenuBarPeer_create: ' print. frame print. ' -> ' print. menuBar printNL. |
261 | 2944 |
]. |
2945 |
||
255 | 2946 |
"Created: / 7.1.1998 / 21:38:31 / cg" |
270 | 2947 |
"Modified: / 25.1.1998 / 13:19:03 / cg" |
255 | 2948 |
! |
2949 |
||
2950 |
_WMenuItemPeer_create:nativeContext |
|
2951 |
|jMenuItemPeer jMenuItem jMenuPeer menu item lbl| |
|
2952 |
||
2953 |
jMenuItemPeer := nativeContext receiver. |
|
2954 |
jMenuItem := jMenuItemPeer instVarNamed:'target'. |
|
2955 |
||
2956 |
jMenuPeer := nativeContext argAt:1. |
|
2957 |
menu := jMenuPeer instVarNamed:'pData'. |
|
2958 |
||
2959 |
item := menu createAtIndex:nil. |
|
261 | 2960 |
item value:[jMenuItemPeer perform:#'handleAction(I)V' with:0]. |
255 | 2961 |
|
2962 |
lbl := jMenuItem instVarNamed:'label'. |
|
2963 |
lbl notNil ifTrue:[ |
|
261 | 2964 |
lbl := Java as_ST_String:lbl. |
2965 |
item label:lbl |
|
255 | 2966 |
]. |
2967 |
||
2968 |
jMenuItemPeer instVarNamed:'pData' put:item. |
|
2969 |
||
2970 |
WindowOPTrace == true ifTrue:[ |
|
261 | 2971 |
'WMenuItem_create: ' print. menu print. ' -> ' print. item printNL. |
2972 |
]. |
|
255 | 2973 |
|
2974 |
"Created: / 7.1.1998 / 21:40:44 / cg" |
|
261 | 2975 |
"Modified: / 14.1.1998 / 17:55:01 / cg" |
255 | 2976 |
! |
2977 |
||
2978 |
_WMenuItemPeer_enable:nativeContext |
|
2979 |
|jMenuItemPeer item state| |
|
2980 |
||
2981 |
jMenuItemPeer := nativeContext receiver. |
|
2982 |
item := jMenuItemPeer instVarNamed:'pData'. |
|
2983 |
||
2984 |
state := nativeContext argAt:1. |
|
2985 |
item enabled:(state == 0) not |
|
2986 |
||
2987 |
"Modified: / 4.8.1997 / 03:05:50 / cg" |
|
2988 |
"Created: / 7.1.1998 / 22:41:38 / cg" |
|
2989 |
! |
|
2990 |
||
2991 |
_WMenuPeer_createMenu:nativeContext |
|
2992 |
|jMenuPeer jMenu jMenuBarPeer menuPanel menu |
|
2993 |
lbl item| |
|
2994 |
||
2995 |
jMenuPeer := nativeContext receiver. |
|
2996 |
jMenu := jMenuPeer instVarNamed:'target'. |
|
2997 |
||
2998 |
jMenuBarPeer := nativeContext argAt:1. |
|
2999 |
menuPanel := jMenuBarPeer instVarNamed:'pData'. |
|
3000 |
||
3001 |
item := menuPanel createAtIndex:nil. |
|
3002 |
lbl := jMenu instVarNamed:'label'. |
|
3003 |
lbl notNil ifTrue:[ |
|
261 | 3004 |
lbl := Java as_ST_String:lbl. |
3005 |
item label:lbl |
|
255 | 3006 |
]. |
3007 |
||
3008 |
menu := MenuPanel new. |
|
3009 |
item submenu:menu. |
|
3010 |
||
3011 |
jMenuPeer instVarNamed:'pData' put:menu. |
|
3012 |
||
3013 |
'createMenuPeer: ' print. menuPanel print. ' -> ' print. menu printNL. |
|
261 | 3014 |
|
255 | 3015 |
"Created: / 7.1.1998 / 21:39:50 / cg" |
261 | 3016 |
"Modified: / 13.1.1998 / 22:11:09 / cg" |
3017 |
! |
|
3018 |
||
3019 |
_WScrollbarPeer__setValues:nativeContext |
|
270 | 3020 |
|scrollBar value visibleAmount min max| |
261 | 3021 |
|
3022 |
scrollBar := self viewForWPeer:nativeContext. |
|
3023 |
||
3024 |
value := nativeContext argAt:1. |
|
3025 |
visibleAmount := nativeContext argAt:2. |
|
3026 |
min := nativeContext argAt:3. |
|
3027 |
max := nativeContext argAt:4. |
|
3028 |
||
3029 |
(min ~~ 0 |
|
3030 |
or:[max ~~ 100]) ifTrue:[ |
|
270 | 3031 |
scrollBar thumb start:min stop:max. |
261 | 3032 |
]. |
3033 |
||
3034 |
scrollBar thumbOrigin:value thumbHeight:visibleAmount. |
|
3035 |
||
3036 |
"Created: / 13.1.1998 / 22:13:57 / cg" |
|
270 | 3037 |
"Modified: / 25.1.1998 / 11:51:14 / cg" |
261 | 3038 |
! |
3039 |
||
3040 |
_WScrollbarPeer_create:nativeContext |
|
3041 |
|jScrollbarPeer jScrollbar jFrame frame scrollBar |
|
3042 |
lbl min max| |
|
3043 |
||
3044 |
jScrollbarPeer := nativeContext receiver. |
|
3045 |
jScrollbar := jScrollbarPeer instVarNamed:'target'. |
|
3046 |
||
3047 |
jFrame := nativeContext argAt:1. |
|
3048 |
frame := jFrame instVarNamed:'pData'. |
|
3049 |
||
3050 |
(jScrollbar instVarNamed:'orientation') == 0 "HORIZONTAL" ifTrue:[ |
|
270 | 3051 |
scrollBar := HorizontalScrollBar in:frame. |
261 | 3052 |
] ifFalse:[ |
270 | 3053 |
scrollBar := ScrollBar in:frame. |
261 | 3054 |
]. |
3055 |
min := jScrollbar instVarNamed:'minimum'. |
|
3056 |
max := jScrollbar instVarNamed:'maximum'. |
|
3057 |
||
3058 |
self createdWindowsView:scrollBar for:jScrollbarPeer. |
|
3059 |
||
3060 |
WindowCreationTrace == true ifTrue:[ |
|
270 | 3061 |
'WScrollbarPeer_create: ' print. frame print. ' -> ' print. scrollBar printNL. |
261 | 3062 |
]. |
3063 |
||
3064 |
"Created: / 5.1.1998 / 01:53:30 / cg" |
|
270 | 3065 |
"Modified: / 25.1.1998 / 11:55:14 / cg" |
3066 |
! |
|
3067 |
||
3068 |
_WScrollbarPeer_setLineIncrement:nativeContext |
|
3069 |
|scrollBar inc| |
|
3070 |
||
3071 |
scrollBar := self viewForWPeer:nativeContext. |
|
3072 |
||
3073 |
inc := nativeContext argAt:1. |
|
3074 |
"/ scrollBar thumb lineIncrement:inc. |
|
3075 |
||
3076 |
"Created: / 25.1.1998 / 11:52:19 / cg" |
|
3077 |
! |
|
3078 |
||
3079 |
_WScrollbarPeer_setPageIncrement:nativeContext |
|
3080 |
|scrollBar inc| |
|
3081 |
||
3082 |
scrollBar := self viewForWPeer:nativeContext. |
|
3083 |
||
3084 |
inc := nativeContext argAt:1. |
|
3085 |
"/ scrollBar thumb pageIncrement:inc. |
|
3086 |
||
3087 |
"Created: / 25.1.1998 / 11:52:01 / cg" |
|
255 | 3088 |
! |
3089 |
||
3090 |
_WTextAreaPeer_create:nativeContext |
|
3091 |
|jTextAreaPeer jFrame frame editTextView| |
|
3092 |
||
3093 |
jTextAreaPeer := nativeContext receiver. |
|
3094 |
||
3095 |
jFrame := nativeContext argAt:1. |
|
3096 |
frame := jFrame instVarNamed:'pData'. |
|
3097 |
||
261 | 3098 |
editTextView := HVScrollableView for:EditTextView in:frame. |
255 | 3099 |
|
3100 |
self createdWindowsView:editTextView for:jTextAreaPeer. |
|
3101 |
||
3102 |
WindowCreationTrace == true ifTrue:[ |
|
270 | 3103 |
'WTextAreaPeer_create: ' print. frame print. ' -> ' print. editTextView printNL. |
255 | 3104 |
]. |
3105 |
||
3106 |
"Created: / 7.1.1998 / 21:49:49 / cg" |
|
261 | 3107 |
"Modified: / 15.1.1998 / 12:56:18 / cg" |
255 | 3108 |
! |
3109 |
||
3110 |
_WTextAreaPeer_insertText:nativeContext |
|
3111 |
|textView pos string jstring| |
|
3112 |
||
3113 |
textView := self viewForWPeer:nativeContext. |
|
3114 |
||
3115 |
jstring := nativeContext argAt:1. |
|
3116 |
string := Java as_ST_String:jstring. |
|
3117 |
pos := nativeContext argAt:2. |
|
3118 |
||
3119 |
textView insert:string at:pos. |
|
3120 |
^ nil |
|
3121 |
||
3122 |
"Created: / 7.1.1998 / 21:50:23 / cg" |
|
3123 |
"Modified: / 8.1.1998 / 17:36:24 / cg" |
|
3124 |
! |
|
3125 |
||
253 | 3126 |
_WTextComponentPeer_enableEditing:nativeContext |
271 | 3127 |
|textView enabled| |
255 | 3128 |
|
3129 |
textView := self viewForWPeer:nativeContext. |
|
271 | 3130 |
enabled := (nativeContext argAt:1) ~~ 0. |
3131 |
||
3132 |
^ textView readOnly:enabled not |
|
253 | 3133 |
|
3134 |
"Created: / 5.1.1998 / 01:29:38 / cg" |
|
271 | 3135 |
"Modified: / 25.1.1998 / 16:29:56 / cg" |
255 | 3136 |
! |
3137 |
||
3138 |
_WTextComponentPeer_getSelectionEnd:nativeContext |
|
3139 |
|textView| |
|
3140 |
||
3141 |
textView := self viewForWPeer:nativeContext. |
|
3142 |
||
3143 |
^ textView characterPositionOfSelectionEnd |
|
3144 |
||
3145 |
"Created: / 8.1.1998 / 17:41:56 / cg" |
|
261 | 3146 |
"Modified: / 15.1.1998 / 15:47:18 / cg" |
255 | 3147 |
! |
3148 |
||
3149 |
_WTextComponentPeer_getSelectionStart:nativeContext |
|
3150 |
|textView| |
|
3151 |
||
3152 |
textView := self viewForWPeer:nativeContext. |
|
3153 |
||
261 | 3154 |
^ textView characterPositionOfSelection - 1 |
255 | 3155 |
|
3156 |
"Created: / 15.8.1997 / 15:45:45 / cg" |
|
261 | 3157 |
"Modified: / 15.1.1998 / 15:46:51 / cg" |
255 | 3158 |
! |
3159 |
||
3160 |
_WTextComponentPeer_getText:nativeContext |
|
3161 |
|textView string jString| |
|
3162 |
||
3163 |
textView := self viewForWPeer:nativeContext. |
|
3164 |
||
3165 |
string := textView contents asString. |
|
3166 |
jString := Java as_String:string. |
|
3167 |
^ jString |
|
3168 |
||
3169 |
"Created: / 6.1.1998 / 21:05:15 / cg" |
|
3170 |
"Modified: / 8.1.1998 / 17:36:52 / cg" |
|
253 | 3171 |
! |
3172 |
||
3173 |
_WTextComponentPeer_select:nativeContext |
|
261 | 3174 |
|textView selStart selEnd| |
255 | 3175 |
|
3176 |
textView := self viewForWPeer:nativeContext. |
|
261 | 3177 |
selStart := nativeContext argAt:1. |
3178 |
selEnd := nativeContext argAt:2. |
|
3179 |
||
3180 |
selStart == selEnd ifTrue:[ |
|
270 | 3181 |
"/ clear selection |
3182 |
textView unselect. |
|
3183 |
"/ and set caret |
|
3184 |
textView cursorToCharacterPosition:selStart + 1 |
|
261 | 3185 |
] ifFalse:[ |
270 | 3186 |
"/ change selection |
3187 |
textView selectFromCharacterPosition:selStart+1 to:selEnd |
|
261 | 3188 |
]. |
253 | 3189 |
|
3190 |
"Created: / 15.8.1997 / 15:45:58 / cg" |
|
261 | 3191 |
"Modified: / 15.1.1998 / 21:55:57 / cg" |
253 | 3192 |
! |
3193 |
||
3194 |
_WTextComponentPeer_setText:nativeContext |
|
255 | 3195 |
|textView string jstring| |
3196 |
||
3197 |
textView := self viewForWPeer:nativeContext. |
|
253 | 3198 |
|
3199 |
jstring := nativeContext argAt:1. |
|
3200 |
string := Java as_ST_String:jstring. |
|
3201 |
||
3202 |
textView contents:string. |
|
3203 |
||
3204 |
"Created: / 5.1.1998 / 01:28:23 / cg" |
|
261 | 3205 |
"Modified: / 15.1.1998 / 15:59:57 / cg" |
253 | 3206 |
! |
3207 |
||
3208 |
_WTextFieldPeer_create:nativeContext |
|
3209 |
|jTextFieldPeer jFrame frame editField| |
|
3210 |
||
3211 |
jTextFieldPeer := nativeContext receiver. |
|
3212 |
||
3213 |
jFrame := nativeContext argAt:1. |
|
3214 |
frame := jFrame instVarNamed:'pData'. |
|
3215 |
||
3216 |
editField := EditField in:frame. |
|
3217 |
||
3218 |
self createdWindowsView:editField for:jTextFieldPeer. |
|
3219 |
||
272 | 3220 |
editField crAction:[ |
3221 |
jTextFieldPeer invoke:#handleAction. |
|
3222 |
]. |
|
253 | 3223 |
WindowCreationTrace == true ifTrue:[ |
272 | 3224 |
'WTextFieldPeer_create: ' print. frame print. ' -> ' print. editField printNL. |
261 | 3225 |
]. |
3226 |
||
253 | 3227 |
"Created: / 5.1.1998 / 01:27:37 / cg" |
272 | 3228 |
"Modified: / 25.1.1998 / 20:34:45 / cg" |
253 | 3229 |
! |
3230 |
||
271 | 3231 |
_WTextFieldPeer_setEchoCharacter:nativeContext |
3232 |
|editField char| |
|
3233 |
||
3234 |
editField := self viewForWPeer:nativeContext. |
|
3235 |
||
3236 |
char := nativeContext argAt:1. |
|
3237 |
editField passwordCharacter:(Character value:char). |
|
3238 |
||
3239 |
"Created: / 25.1.1998 / 16:28:30 / cg" |
|
3240 |
! |
|
3241 |
||
255 | 3242 |
_WToolkit_eventLoop:nativeContext |
261 | 3243 |
JavaEventThread := Processor activeProcess. |
3244 |
[ |
|
270 | 3245 |
[true] whileTrue:[ |
3246 |
AbortSignal handle:[:ex | |
|
3247 |
ex return |
|
3248 |
] do:[ |
|
3249 |
self doWindowsEventThread. |
|
3250 |
] |
|
3251 |
]. |
|
261 | 3252 |
] valueNowOrOnUnwindDo:[ |
270 | 3253 |
JavaEventThread := nil. |
261 | 3254 |
]. |
3255 |
||
255 | 3256 |
"Created: / 6.1.1998 / 21:01:44 / cg" |
261 | 3257 |
"Modified: / 15.1.1998 / 19:48:55 / cg" |
3258 |
! |
|
3259 |
||
3260 |
_WToolkit_getScreenHeight:nativeContext |
|
3261 |
^ Screen current height |
|
3262 |
||
3263 |
"Modified: / 20.3.1997 / 13:50:04 / cg" |
|
3264 |
"Created: / 13.1.1998 / 09:24:45 / cg" |
|
3265 |
! |
|
3266 |
||
266 | 3267 |
_WToolkit_getScreenResolution:nativeContext |
3268 |
^ Screen current resolution x rounded |
|
3269 |
||
3270 |
"Modified: / 20.3.1997 / 13:50:04 / cg" |
|
3271 |
"Created: / 17.1.1998 / 21:54:48 / cg" |
|
3272 |
! |
|
3273 |
||
261 | 3274 |
_WToolkit_getScreenWidth:nativeContext |
3275 |
^ Screen current width |
|
3276 |
||
3277 |
"Modified: / 20.3.1997 / 13:50:04 / cg" |
|
3278 |
"Created: / 13.1.1998 / 09:24:37 / cg" |
|
255 | 3279 |
! |
3280 |
||
253 | 3281 |
_WToolkit_init:nativeContext |
3282 |
||
3283 |
"Created: / 3.1.1998 / 02:30:57 / cg" |
|
3284 |
! |
|
3285 |
||
3286 |
_WToolkit_loadSystemColors:nativeContext |
|
3287 |
"/ self halt. |
|
3288 |
||
3289 |
"Modified: / 18.3.1997 / 18:43:26 / cg" |
|
3290 |
"Created: / 5.1.1998 / 02:19:09 / cg" |
|
3291 |
! |
|
3292 |
||
3293 |
_WWindowPeer__setResizable:nativeContext |
|
255 | 3294 |
|view onOff| |
3295 |
||
3296 |
view := self viewForWPeer:nativeContext. |
|
253 | 3297 |
|
261 | 3298 |
onOff := (nativeContext argAt:1) == 1. |
3299 |
view isTopView ifTrue:[ |
|
270 | 3300 |
onOff ifTrue:[ |
3301 |
view minExtent:10@10. |
|
3302 |
view maxExtent:(Screen current extent). |
|
3303 |
] ifFalse:[ |
|
3304 |
view minExtent:view extent. |
|
3305 |
view maxExtent:view extent. |
|
3306 |
] |
|
261 | 3307 |
] ifFalse:[ |
270 | 3308 |
(view isMemberOf:JavaEmbeddedFrameView) ifFalse:[ |
3309 |
self halt. |
|
3310 |
] |
|
261 | 3311 |
]. |
253 | 3312 |
|
3313 |
"/ 'JAVA: WWindowPeer_setResizable: ' print. view print. ' yes/no: ' print. onOff printNL. |
|
3314 |
||
3315 |
^ nil |
|
3316 |
||
3317 |
"Created: / 5.1.1998 / 00:57:59 / cg" |
|
262 | 3318 |
"Modified: / 16.1.1998 / 18:08:00 / cg" |
253 | 3319 |
! |
3320 |
||
3321 |
_WWindowPeer__setTitle:nativeContext |
|
255 | 3322 |
|view jString string| |
3323 |
||
3324 |
view := self viewForWPeer:nativeContext. |
|
253 | 3325 |
|
3326 |
jString := nativeContext argAt:1. |
|
3327 |
string := Java as_ST_String:jString. |
|
3328 |
||
3329 |
"/ 'JAVA: WWindowPeer_pSetTitle: ' print. string print. ' ' print. view printNL. |
|
3330 |
||
3331 |
view label:string. |
|
3332 |
^ nil |
|
3333 |
||
3334 |
"Created: / 5.1.1998 / 00:57:17 / cg" |
|
255 | 3335 |
"Modified: / 8.1.1998 / 17:37:41 / cg" |
253 | 3336 |
! |
3337 |
||
3338 |
_WWindowPeer_updateInsets:nativeContext |
|
3339 |
"/ self halt. |
|
3340 |
||
3341 |
"Modified: / 18.3.1997 / 18:43:18 / cg" |
|
3342 |
"Created: / 4.1.1998 / 18:09:04 / cg" |
|
3343 |
! ! |
|
3344 |
||
277 | 3345 |
!JavaVM class methodsFor:'native - awt.windows - jdk1.2'! |
3346 |
||
3347 |
_Font_initIDs:nativeContext |
|
3348 |
"/ new with jdk1.2 ... |
|
3349 |
||
3350 |
"Created: / 27.1.1998 / 21:43:25 / cg" |
|
3351 |
! |
|
3352 |
||
3353 |
_WFramePeer_setTitle:nativeContext |
|
3354 |
|view jString string| |
|
3355 |
||
3356 |
view := self viewForWPeer:nativeContext. |
|
3357 |
||
3358 |
jString := nativeContext argAt:1. |
|
3359 |
string := Java as_ST_String:jString. |
|
3360 |
||
3361 |
"/ 'JAVA: WFramePeer_pSetTitle: ' print. string print. ' ' print. view printNL. |
|
3362 |
||
3363 |
view label:string. |
|
3364 |
^ nil |
|
3365 |
||
3366 |
"Modified: / 8.1.1998 / 17:37:41 / cg" |
|
3367 |
"Created: / 27.1.1998 / 21:42:57 / cg" |
|
3368 |
! |
|
3369 |
||
3370 |
_WPanelPeer_calculateInsets:nativeContext |
|
3371 |
"/ new with jdk1.2 ... |
|
3372 |
||
3373 |
"Created: / 27.1.1998 / 21:40:00 / cg" |
|
3374 |
! ! |
|
3375 |
||
253 | 3376 |
!JavaVM class methodsFor:'native - java.io'! |
3377 |
||
3378 |
_FileDescriptor_initSystemFD:nativeContext |
|
3379 |
|descriptor fileNo idx myStream| |
|
3380 |
||
3381 |
descriptor := nativeContext argAt:1. |
|
3382 |
fileNo := nativeContext argAt:2. |
|
3383 |
||
3384 |
fileNo == 0 ifTrue:[ |
|
277 | 3385 |
myStream := Stdin |
253 | 3386 |
] ifFalse:[ |
277 | 3387 |
fileNo == 1 ifTrue:[ |
3388 |
myStream := JavaConsoleStream ? Stdout |
|
3389 |
] ifFalse:[ |
|
3390 |
fileNo == 2 ifTrue:[ |
|
3391 |
myStream := JavaConsoleStream ? Stderr |
|
3392 |
] ifFalse:[ |
|
3393 |
self halt:'invalid fileNo given'. |
|
3394 |
self internalError:'invalid fileNo given'. |
|
3395 |
] |
|
3396 |
] |
|
253 | 3397 |
]. |
3398 |
||
3399 |
self setOpenFile:myStream at:fileNo. |
|
3400 |
||
3401 |
descriptor instVarNamed:'fd' put:fileNo. |
|
3402 |
^ descriptor |
|
3403 |
||
277 | 3404 |
"Modified: / 27.1.1998 / 18:15:28 / cg" |
253 | 3405 |
! |
3406 |
||
261 | 3407 |
_FileInputStream_available:nativeContext |
3408 |
|file| |
|
3409 |
||
3410 |
file := self validateFile:(nativeContext receiver). |
|
3411 |
file isNil ifTrue:[ |
|
3412 |
self throwIOExceptionWithMessage:'invalid fileNo in available'. |
|
3413 |
^ self |
|
3414 |
]. |
|
3415 |
file isFileStream ifTrue:[ |
|
3416 |
^ file size - file position + 1 |
|
3417 |
]. |
|
3418 |
file atEnd ifTrue:[ |
|
3419 |
^ 0. |
|
3420 |
]. |
|
3421 |
self halt. |
|
3422 |
^ 1 |
|
3423 |
||
3424 |
"Modified: / 14.1.1998 / 15:12:52 / cg" |
|
3425 |
! |
|
3426 |
||
253 | 3427 |
_FileInputStream_close:nativeContext |
3428 |
^ self anyFileStream_close:(nativeContext receiver) |
|
3429 |
||
3430 |
"Modified: / 15.8.1997 / 16:59:56 / cg" |
|
3431 |
"Created: / 4.1.1998 / 17:45:23 / cg" |
|
3432 |
! |
|
3433 |
||
3434 |
_FileInputStream_open:nativeContext |
|
261 | 3435 |
|fs fd fn name stream fileNo| |
253 | 3436 |
|
3437 |
fs := nativeContext receiver. |
|
3438 |
fd := fs instVarNamed:'fd'. |
|
277 | 3439 |
(fileNo := fd instVarNamed:'fd') ~~ 0 ifTrue:[ |
3440 |
fileNo ~~ -1 ifTrue:[ |
|
3441 |
self halt:'file already open'. |
|
3442 |
self internalError:'file already open'. |
|
3443 |
^ self. |
|
3444 |
] |
|
253 | 3445 |
]. |
3446 |
||
3447 |
name := nativeContext argAt:1. |
|
3448 |
name := Java as_ST_String:name. |
|
3449 |
||
3450 |
FileOpenTrace ifTrue:[ |
|
277 | 3451 |
('JAVA: opening ' , name) infoPrintCR. |
253 | 3452 |
]. |
3453 |
||
261 | 3454 |
stream := self fileStreamForReading:name. |
253 | 3455 |
stream isNil ifTrue:[ |
277 | 3456 |
FileOpenTrace ifTrue:[ |
3457 |
('JAVA: failed to open ' , name , ' for reading.') infoPrintCR. |
|
3458 |
]. |
|
3459 |
||
3460 |
self throwIOExceptionWithMessage:('cannot open ' , name , ' for reading'). |
|
3461 |
||
3462 |
^ self. |
|
253 | 3463 |
]. |
3464 |
||
261 | 3465 |
"/ FileOpenConfirmation ifTrue:[ |
3466 |
"/ (self confirm:('JAVA Security check\\Opening ''' , name , ''' for reading.\Grant permission ?') withCRs) |
|
3467 |
"/ ifFalse:[ |
|
3468 |
"/ self throwIOExceptionWithMessage:('no permission to open ' , name , ' for reading'). |
|
3469 |
"/ ^ self |
|
3470 |
"/ ] |
|
3471 |
"/ ]. |
|
3472 |
||
253 | 3473 |
fileNo := self addOpenFile:stream. |
3474 |
||
3475 |
FileOpenTrace ifTrue:[ |
|
277 | 3476 |
('JAVA: opened ' , name , ' as FD ' , fileNo printString) infoPrintCR. |
253 | 3477 |
]. |
3478 |
||
3479 |
fd instVarNamed:'fd' put:fileNo. |
|
3480 |
||
3481 |
"Created: / 4.1.1998 / 16:47:12 / cg" |
|
277 | 3482 |
"Modified: / 27.1.1998 / 18:27:01 / cg" |
253 | 3483 |
! |
3484 |
||
3485 |
_FileInputStream_read:nativeContext |
|
3486 |
|file byte| |
|
3487 |
||
3488 |
file := self validateFile:(nativeContext receiver). |
|
3489 |
||
3490 |
FileIOTrace ifTrue:[ |
|
261 | 3491 |
('JAVA: read 1 byte from ' , file pathName) infoPrintCR. |
253 | 3492 |
]. |
3493 |
||
3494 |
byte := file nextByte. |
|
3495 |
byte isNil ifTrue:[ |
|
261 | 3496 |
^ -1 |
253 | 3497 |
]. |
3498 |
^ byte |
|
3499 |
||
3500 |
"Created: / 5.1.1998 / 02:17:08 / cg" |
|
3501 |
"Modified: / 5.1.1998 / 02:17:25 / cg" |
|
3502 |
! |
|
3503 |
||
3504 |
_FileInputStream_readBytes:nativeContext |
|
3505 |
|bytes offset count stream nRead| |
|
3506 |
||
3507 |
bytes := nativeContext argAt:1. |
|
3508 |
offset := nativeContext argAt:2. |
|
3509 |
count := nativeContext argAt:3. |
|
3510 |
||
3511 |
stream := self validateFile:(nativeContext receiver). |
|
3512 |
||
3513 |
"/ should always be bytes |
|
261 | 3514 |
bytes class isBytes ifFalse:[ |
3515 |
self halt. |
|
3516 |
]. |
|
253 | 3517 |
|
3518 |
FileIOTrace ifTrue:[ |
|
261 | 3519 |
('JAVA: read ' , count printString , ' bytes from ' , stream pathName) infoPrintCR. |
3520 |
]. |
|
3521 |
||
3522 |
"/ stream readWait. |
|
253 | 3523 |
nRead := stream nextBytes:count into:bytes startingAt:offset+1. |
3524 |
nRead == 0 ifTrue:[ |
|
261 | 3525 |
stream atEnd ifTrue:[ |
3526 |
FileIOTrace ifTrue:[ |
|
3527 |
('JAVA: at EOF ' , nRead printString) infoPrintCR. |
|
3528 |
]. |
|
3529 |
^ -1 |
|
3530 |
]. |
|
253 | 3531 |
]. |
3532 |
count ~~ nRead ifTrue:[ |
|
261 | 3533 |
FileIOTrace ifTrue:[ |
3534 |
('JAVA: only got ' , nRead printString) infoPrintCR. |
|
3535 |
] |
|
253 | 3536 |
]. |
3537 |
^ nRead |
|
3538 |
||
3539 |
"Created: / 4.1.1998 / 16:49:09 / cg" |
|
261 | 3540 |
"Modified: / 14.1.1998 / 15:15:01 / cg" |
3541 |
! |
|
3542 |
||
3543 |
_FileOutputStream_close:nativeContext |
|
3544 |
^ self anyFileStream_close:(nativeContext receiver) |
|
3545 |
||
3546 |
"Modified: / 15.8.1997 / 16:59:56 / cg" |
|
3547 |
"Created: / 13.1.1998 / 09:33:16 / cg" |
|
3548 |
! |
|
3549 |
||
3550 |
_FileOutputStream_open:nativeContext |
|
3551 |
|fs fd name stream fileNo| |
|
3552 |
||
3553 |
fs := nativeContext receiver. |
|
3554 |
fd := fs instVarNamed:'fd'. |
|
3555 |
(fd instVarNamed:'fd') ~~ 0 ifTrue:[ |
|
270 | 3556 |
self halt:'file already open'. |
3557 |
self internalError:'file already open'. |
|
3558 |
^ self. |
|
261 | 3559 |
]. |
3560 |
||
3561 |
name := nativeContext argAt:1. |
|
3562 |
name := Java as_ST_String:name. |
|
3563 |
||
3564 |
FileOpenTrace ifTrue:[ |
|
270 | 3565 |
('JAVA: opening ' , name) infoPrintCR. |
261 | 3566 |
]. |
3567 |
||
3568 |
FileOpenConfirmation ifTrue:[ |
|
270 | 3569 |
(self confirm:('JAVA Security check\\Opening ''' , name , ''' for writing.\Grant permission ?') withCRs) |
3570 |
ifFalse:[ |
|
3571 |
self throwIOExceptionWithMessage:('no permission to open ' , name , ' for writing'). |
|
3572 |
^ self |
|
3573 |
] |
|
261 | 3574 |
]. |
3575 |
||
3576 |
stream := name asFilename writeStream. |
|
3577 |
stream isNil ifTrue:[ |
|
270 | 3578 |
self throwIOExceptionWithMessage:('cannot open ' , name , ' for writing'). |
261 | 3579 |
]. |
3580 |
||
3581 |
fileNo := self addOpenFile:stream. |
|
3582 |
||
3583 |
FileOpenTrace ifTrue:[ |
|
270 | 3584 |
('JAVA: opened ' , name , ' as FD ' , fileNo printString , ' for writing') infoPrintCR. |
261 | 3585 |
]. |
3586 |
||
3587 |
fd instVarNamed:'fd' put:fileNo. |
|
3588 |
||
3589 |
"Modified: / 16.1.1998 / 13:32:58 / cg" |
|
3590 |
! |
|
3591 |
||
3592 |
_FileOutputStream_write:nativeContext |
|
3593 |
|byte file| |
|
3594 |
||
3595 |
byte := nativeContext argAt:1. |
|
3596 |
||
3597 |
file := self validateFile:(nativeContext receiver). |
|
3598 |
||
3599 |
FileIOTrace ifTrue:[ |
|
3600 |
file isFileStream ifTrue:[ |
|
3601 |
('JAVA: write 1 byte to ' , file pathName) infoPrintCR. |
|
3602 |
] ifFalse:[ |
|
3603 |
file ~~ Stdout ifTrue:[ |
|
3604 |
file ~~ Stderr ifTrue:[ |
|
3605 |
('JAVA: write 1 byte to ' , file displayString) infoPrintCR. |
|
3606 |
] |
|
3607 |
] |
|
3608 |
] |
|
3609 |
]. |
|
3610 |
||
3611 |
"/ should always be bytes |
|
3612 |
||
3613 |
file nextPutByte:byte |
|
3614 |
||
3615 |
"Created: / 13.1.1998 / 09:32:13 / cg" |
|
3616 |
"Modified: / 13.1.1998 / 09:32:31 / cg" |
|
253 | 3617 |
! |
3618 |
||
255 | 3619 |
_FileOutputStream_writeBytes:nativeContext |
3620 |
|bytes offset count stream| |
|
3621 |
||
3622 |
bytes := nativeContext argAt:1. |
|
3623 |
offset := nativeContext argAt:2. |
|
3624 |
count := nativeContext argAt:3. |
|
3625 |
||
3626 |
stream := self validateFile:(nativeContext receiver). |
|
3627 |
||
3628 |
FileIOTrace ifTrue:[ |
|
261 | 3629 |
stream isFileStream ifTrue:[ |
3630 |
('JAVA: write ' , count printString , ' bytes to ' , stream pathName) infoPrintCR. |
|
3631 |
] ifFalse:[ |
|
3632 |
stream ~~ Stdout ifTrue:[ |
|
3633 |
stream ~~ Stderr ifTrue:[ |
|
3634 |
('JAVA: write ' , count printString , ' bytes to ' , stream displayString) infoPrintCR. |
|
3635 |
] |
|
3636 |
] |
|
3637 |
] |
|
255 | 3638 |
]. |
3639 |
||
3640 |
"/ should always be bytes |
|
3641 |
||
3642 |
stream nextPutBytes:count from:bytes startingAt:offset+1 |
|
3643 |
||
3644 |
"Created: / 7.1.1998 / 20:46:19 / cg" |
|
3645 |
"Modified: / 7.1.1998 / 20:47:34 / cg" |
|
3646 |
! |
|
3647 |
||
253 | 3648 |
_File_canRead0:nativeContext |
3649 |
|file path f| |
|
3650 |
||
3651 |
file := nativeContext receiver. |
|
3652 |
path := file instVarNamed:'path'. |
|
3653 |
path notNil ifTrue:[ |
|
270 | 3654 |
path := Java as_ST_String:path. |
3655 |
(f := path asFilename) isReadable ifTrue:[ |
|
3656 |
^ 1 "/ TRUE |
|
3657 |
] |
|
253 | 3658 |
]. |
255 | 3659 |
^ 0 "/ FALSE |
3660 |
||
253 | 3661 |
"Created: / 4.1.1998 / 18:09:55 / cg" |
261 | 3662 |
"Modified: / 15.1.1998 / 12:10:34 / cg" |
253 | 3663 |
! |
3664 |
||
3665 |
_File_exists0:nativeContext |
|
3666 |
|file path f| |
|
3667 |
||
3668 |
file := nativeContext receiver. |
|
3669 |
path := file instVarNamed:'path'. |
|
3670 |
path notNil ifTrue:[ |
|
270 | 3671 |
path := Java as_ST_String:path. |
3672 |
(f := path asFilename) exists ifTrue:[ |
|
3673 |
^ 1 "TRUE" |
|
3674 |
] |
|
255 | 3675 |
]. |
3676 |
^ 0 "FALSE" |
|
3677 |
||
3678 |
"Created: / 5.1.1998 / 02:07:48 / cg" |
|
261 | 3679 |
"Modified: / 15.1.1998 / 12:10:27 / cg" |
255 | 3680 |
! |
3681 |
||
3682 |
_File_isAbsolute:nativeContext |
|
3683 |
|file path f| |
|
3684 |
||
3685 |
file := nativeContext receiver. |
|
3686 |
path := file instVarNamed:'path'. |
|
3687 |
path notNil ifTrue:[ |
|
261 | 3688 |
path := Java as_ST_String:path. |
3689 |
(f := path asFilename) isAbsolute ifTrue:[ |
|
3690 |
^ 1 "/ TRUE |
|
3691 |
] |
|
255 | 3692 |
]. |
3693 |
^ 0 "/ FALSE |
|
3694 |
||
3695 |
"Modified: / 8.8.1997 / 12:04:05 / cg" |
|
3696 |
"Created: / 11.1.1998 / 09:54:38 / cg" |
|
3697 |
! |
|
3698 |
||
3699 |
_File_isDirectory0:nativeContext |
|
3700 |
|file path f| |
|
3701 |
||
3702 |
file := nativeContext receiver. |
|
3703 |
path := file instVarNamed:'path'. |
|
3704 |
path notNil ifTrue:[ |
|
270 | 3705 |
path := Java as_ST_String:path. |
3706 |
(f := path asFilename) exists ifTrue:[ |
|
3707 |
f isDirectory ifTrue:[^ 1 "TRUE"] |
|
3708 |
] |
|
255 | 3709 |
]. |
3710 |
^ 0 "FALSE" |
|
3711 |
||
3712 |
"Created: / 7.1.1998 / 10:31:37 / cg" |
|
261 | 3713 |
"Modified: / 15.1.1998 / 12:10:20 / cg" |
255 | 3714 |
! |
3715 |
||
3716 |
_File_isFile0:nativeContext |
|
3717 |
|file path f| |
|
3718 |
||
3719 |
file := nativeContext receiver. |
|
3720 |
path := file instVarNamed:'path'. |
|
3721 |
path notNil ifTrue:[ |
|
270 | 3722 |
path := Java as_ST_String:path. |
3723 |
(f := path asFilename) exists ifTrue:[ |
|
3724 |
f isDirectory ifFalse:[^ 1 "TRUE"] |
|
3725 |
] |
|
255 | 3726 |
]. |
3727 |
^ 0 "/ FALSE |
|
3728 |
||
3729 |
"Created: / 11.1.1998 / 11:40:22 / cg" |
|
261 | 3730 |
"Modified: / 15.1.1998 / 12:10:13 / cg" |
255 | 3731 |
! |
3732 |
||
3733 |
_File_length0:nativeContext |
|
3734 |
|file path f| |
|
3735 |
||
3736 |
file := nativeContext receiver. |
|
3737 |
path := file instVarNamed:'path'. |
|
3738 |
path notNil ifTrue:[ |
|
270 | 3739 |
path := Java as_ST_String:path. |
3740 |
(f := path asFilename) exists ifTrue:[ |
|
3741 |
^ f fileSize |
|
3742 |
] |
|
253 | 3743 |
]. |
261 | 3744 |
^ -1 |
3745 |
||
255 | 3746 |
"Created: / 7.1.1998 / 12:18:57 / cg" |
261 | 3747 |
"Modified: / 15.1.1998 / 12:10:06 / cg" |
3748 |
! |
|
3749 |
||
3750 |
_File_list0:nativeContext |
|
3751 |
|file path f files| |
|
3752 |
||
3753 |
file := nativeContext receiver. |
|
3754 |
path := file instVarNamed:'path'. |
|
3755 |
path notNil ifTrue:[ |
|
270 | 3756 |
path := Java as_ST_String:path. |
3757 |
(f := path asFilename) exists ifTrue:[ |
|
3758 |
f isDirectory ifTrue:[ |
|
3759 |
files := f directoryContents asArray. |
|
3760 |
files := files collect:[:nm | Java as_String:nm]. |
|
3761 |
^ files |
|
3762 |
] |
|
3763 |
] |
|
261 | 3764 |
]. |
3765 |
^ nil |
|
3766 |
||
3767 |
"Created: / 14.1.1998 / 21:30:22 / cg" |
|
3768 |
"Modified: / 14.1.1998 / 21:32:09 / cg" |
|
253 | 3769 |
! ! |
3770 |
||
277 | 3771 |
!JavaVM class methodsFor:'native - java.io - jdk1.2'! |
3772 |
||
3773 |
_FileDescriptor_initIDs:nativeContext |
|
3774 |
"/ introduced with jdk1.2 ... (sigh) |
|
3775 |
||
3776 |
"Created: / 27.1.1998 / 18:16:29 / cg" |
|
3777 |
! |
|
3778 |
||
3779 |
_FileInputStream_initIDs:nativeContext |
|
3780 |
"/ introduced with jdk1.2 ... (sigh) |
|
3781 |
||
3782 |
"Created: / 27.1.1998 / 18:15:51 / cg" |
|
3783 |
! |
|
3784 |
||
3785 |
_FileOutputStream_initIDs:nativeContext |
|
3786 |
"/ introduced with jdk1.2 ... (sigh) |
|
3787 |
||
3788 |
"Created: / 27.1.1998 / 18:16:40 / cg" |
|
3789 |
! |
|
3790 |
||
3791 |
_File_canonPath:nativeContext |
|
3792 |
"/ introduced with jdk1.2 ... (sigh) |
|
3793 |
||
3794 |
|jPath path realPath| |
|
3795 |
||
3796 |
jPath := nativeContext argAt:1. |
|
3797 |
jPath isNil ifTrue:[^ jPath]. |
|
3798 |
||
3799 |
path := Java as_ST_String:jPath. |
|
3800 |
realPath := path asFilename pathName. |
|
3801 |
||
3802 |
^ Java as_String:realPath |
|
3803 |
||
3804 |
"Created: / 27.1.1998 / 18:35:58 / cg" |
|
3805 |
"Modified: / 27.1.1998 / 21:36:03 / cg" |
|
3806 |
! |
|
3807 |
||
3808 |
_File_initIDs:nativeContext |
|
3809 |
"/ introduced with jdk1.2 ... (sigh) |
|
3810 |
||
3811 |
"Created: / 27.1.1998 / 18:25:19 / cg" |
|
3812 |
! ! |
|
3813 |
||
253 | 3814 |
!JavaVM class methodsFor:'native - java.lang'! |
3815 |
||
255 | 3816 |
_ClassLoader_defineClass0:nativeContext |
3817 |
"create a new class from a given byteArray. |
|
3818 |
Here, construct a stream on it and pass the work to the |
|
3819 |
JavaClassReader." |
|
3820 |
||
3821 |
|jClassLoader jName name data offset length inStream newClass |
|
3822 |
loaderStub jClass| |
|
3823 |
||
3824 |
jClassLoader := nativeContext receiver. |
|
3825 |
jName := nativeContext argAt:1. |
|
3826 |
||
3827 |
"/ className is now optional ... |
|
3828 |
"/ jName isNil ifTrue:[ |
|
3829 |
"/ self internalError:'nil name in defineClass'. |
|
3830 |
"/ ^ nil |
|
3831 |
"/ ] ifFalse:[ |
|
3832 |
"/ name := Java as_ST_String:jName. |
|
3833 |
"/ ]. |
|
3834 |
||
3835 |
data := nativeContext argAt:2. |
|
3836 |
offset := nativeContext argAt:3. |
|
3837 |
length := nativeContext argAt:4. |
|
3838 |
||
3839 |
inStream := data readStream. |
|
3840 |
inStream position:offset + 1. |
|
3841 |
inStream readLimit:(offset + length). |
|
3842 |
||
270 | 3843 |
"/ loaderStub := Plug new. |
3844 |
"/ loaderStub respondTo:#loadClass: with:[:clsName | |
|
3845 |
"/ |jName| |
|
3846 |
"/ |
|
3847 |
"/self halt. |
|
3848 |
"/ jName := Java as_String:clsName. |
|
3849 |
"/ "/ jClassLoader loadClass:jName |
|
3850 |
"/ jClassLoader |
|
3851 |
"/ perform:#'loadClass(Ljava/lang/String;)Ljava/lang/Class;' |
|
3852 |
"/ with:jName. |
|
3853 |
"/ ]. |
|
255 | 3854 |
|
3855 |
('JAVA: defining class ...') infoPrintCR. |
|
3856 |
||
3857 |
"/ self internalError:'break'. |
|
3858 |
||
3859 |
newClass := JavaClassReader |
|
270 | 3860 |
readStream:inStream |
3861 |
loader:jClassLoader "loaderStub" |
|
3862 |
loadUnresolved:false. |
|
255 | 3863 |
|
3864 |
newClass isNil ifTrue:[ |
|
3865 |
('JAVA: defineClass failed') infoPrintCR. |
|
3866 |
^ nil. |
|
3867 |
]. |
|
3868 |
Transcript showCR:('defined class ' , newClass fullName , '.'). |
|
3869 |
newClass classLoader:jClassLoader. |
|
3870 |
||
3871 |
('Java: defined new class: ' , newClass fullName) infoPrintCR. |
|
3872 |
||
268
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
3873 |
jClass := self javaClassObjectForClass:newClass. |
255 | 3874 |
^ jClass |
3875 |
||
3876 |
"Created: / 7.1.1998 / 12:35:10 / cg" |
|
270 | 3877 |
"Modified: / 24.1.1998 / 15:26:21 / cg" |
255 | 3878 |
! |
3879 |
||
253 | 3880 |
_ClassLoader_findSystemClass0:nativeContext |
3881 |
|loader name class jClass| |
|
3882 |
||
3883 |
loader := nativeContext receiver. |
|
3884 |
name := nativeContext argAt:1. |
|
3885 |
name := Java as_ST_String:name. |
|
3886 |
||
255 | 3887 |
('JAVA: findSystemClass0 for ' , name , ' loader is ' , loader displayString) infoPrintCR. |
3888 |
loader class == (Java classForName:'java.util.SystemClassLoader') ifTrue:[ |
|
270 | 3889 |
Java classForName:name. |
253 | 3890 |
]. |
3891 |
||
255 | 3892 |
"/ JavaClassReader classLoaderQuerySignal answer:nil "loader" |
3893 |
"/ do:[ |
|
3894 |
"/ class := Java classForName:name. |
|
3895 |
"/ JavaClassReader postLoadActions:true. |
|
3896 |
"/ ]. |
|
3897 |
class := Java at:name. |
|
3898 |
(class isNil |
|
3899 |
"or:[class classLoader notNil]") ifTrue:[ |
|
253 | 3900 |
"/ self halt:'class: ' , name , ' not found.'. |
3901 |
"/ self internalError:'class: ' , name , ' not found.'. |
|
3902 |
||
270 | 3903 |
self |
3904 |
throwExceptionClassName:'java.lang.ClassNotFoundException' |
|
3905 |
withMessage:'class: ' , name , ' not found.'. |
|
3906 |
^ nil |
|
253 | 3907 |
]. |
3908 |
||
3909 |
'JAVA: findSystemClass0 - loaded: ' infoPrint. class fullName infoPrintCR. |
|
268
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
3910 |
jClass := self javaClassObjectForClass:class. |
253 | 3911 |
^ jClass |
3912 |
||
3913 |
"Created: / 5.1.1998 / 02:53:04 / cg" |
|
268
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
3914 |
"Modified: / 23.1.1998 / 17:47:30 / cg" |
255 | 3915 |
! |
3916 |
||
3917 |
_ClassLoader_getSystemResourceAsStream0:nativeContext |
|
3918 |
|jString rString dir file text data inStream| |
|
3919 |
||
3920 |
jString := nativeContext argAt:1. |
|
3921 |
rString := Java as_ST_String:jString. |
|
3922 |
Java classPath do:[:aPath | |
|
277 | 3923 |
(dir := aPath asFilename) exists ifTrue:[ |
3924 |
(file := dir construct:rString) exists ifTrue:[ |
|
3925 |
(Java isExcludedFromClassPath:file) ifFalse:[ |
|
3926 |
text := file contents asString. |
|
3927 |
||
3928 |
"/ Copy data from returned buffer into Java byte array. |
|
3929 |
||
3930 |
data := text asByteArray. |
|
3931 |
||
3932 |
"/ Create input stream using byte array |
|
3933 |
||
3934 |
inStream := (Java classForName:'java.io.ByteArrayInputStream') basicNew. |
|
3935 |
inStream invoke:'<init>([B)V' with:data. |
|
3936 |
^ inStream. |
|
3937 |
] |
|
3938 |
] |
|
3939 |
] |
|
255 | 3940 |
]. |
3941 |
^ nil |
|
3942 |
||
3943 |
"Created: / 8.1.1998 / 16:06:56 / cg" |
|
277 | 3944 |
"Modified: / 27.1.1998 / 21:58:54 / cg" |
253 | 3945 |
! |
3946 |
||
3947 |
_ClassLoader_init:nativeContext |
|
3948 |
^ nil |
|
3949 |
||
3950 |
"Created: / 5.1.1998 / 02:04:43 / cg" |
|
3951 |
! |
|
3952 |
||
255 | 3953 |
_ClassLoader_resolveClass0:nativeContext |
3954 |
"resolve a new class as previously created by defineClass0" |
|
3955 |
||
3956 |
|jClassLoader jCls cls loaderStub| |
|
3957 |
||
3958 |
jClassLoader := nativeContext receiver. |
|
3959 |
jCls := nativeContext argAt:1. |
|
3960 |
jCls isNil ifTrue:[ |
|
261 | 3961 |
self halt. |
3962 |
^ nil |
|
255 | 3963 |
]. |
3964 |
cls := JavaClasses at:jCls ifAbsent:nil. |
|
3965 |
cls isNil ifTrue:[ |
|
261 | 3966 |
self halt. |
3967 |
^ nil |
|
255 | 3968 |
]. |
3969 |
Transcript showCR:('resolving class ' , cls fullName , ' ...'). |
|
3970 |
||
3971 |
JavaClassReader classLoaderQuerySignal answer:jClassLoader |
|
3972 |
do:[ |
|
261 | 3973 |
JavaClassReader postLoadActions:true. |
3974 |
cls constantPool do:[:entry | |
|
3975 |
(entry isMemberOf:JavaUnresolvedClassConstant) ifTrue:[ |
|
3976 |
self halt:'debugHalt'. |
|
3977 |
entry preResolve. |
|
3978 |
self halt:'debugHalt'. |
|
3979 |
] |
|
3980 |
] |
|
255 | 3981 |
]. |
3982 |
||
3983 |
"Created: / 7.1.1998 / 13:12:27 / cg" |
|
3984 |
"Modified: / 8.1.1998 / 16:13:57 / cg" |
|
3985 |
! |
|
3986 |
||
253 | 3987 |
_Class_forName:nativeContext |
3988 |
"get a java.lang.Class by name" |
|
3989 |
||
255 | 3990 |
|jClassName className cls jClass s m c loader| |
253 | 3991 |
|
3992 |
jClassName := nativeContext argAt:1. |
|
3993 |
className := Java as_ST_String:jClassName. |
|
3994 |
||
255 | 3995 |
(s := nativeContext sender) notNil ifTrue:[ |
270 | 3996 |
(s isMemberOf:JavaContext) ifTrue:[ |
3997 |
c := s method javaClass. |
|
3998 |
loader := c classLoader. |
|
3999 |
loader isNil ifTrue:[ |
|
255 | 4000 |
"/ self halt. |
270 | 4001 |
] |
4002 |
] |
|
255 | 4003 |
]. |
4004 |
||
4005 |
JavaClassReader classLoaderQuerySignal answer:loader |
|
4006 |
do:[ |
|
270 | 4007 |
cls := Java classForName:className. |
255 | 4008 |
]. |
4009 |
||
4010 |
"/(className startsWith:'sun.awt') ifTrue:[self halt]. |
|
4011 |
"/('classForName: ' , className , ' -> ') print. |
|
4012 |
"/cls notNil ifTrue:[cls fullName printCR] ifFalse:['nil' printCR]. |
|
4013 |
||
253 | 4014 |
cls isNil ifTrue:[ |
270 | 4015 |
ExceptionTrace ifTrue:[ |
4016 |
self halt:'no such class:' , className. |
|
4017 |
]. |
|
4018 |
self throwClassNotFoundException:className. |
|
4019 |
"/ not proceedable |
|
4020 |
AbortSignal raise. |
|
4021 |
"/ not reached |
|
4022 |
^ self |
|
253 | 4023 |
]. |
4024 |
||
261 | 4025 |
cls classInit. |
4026 |
||
268
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
4027 |
jClass := self javaClassObjectForClass:cls. |
253 | 4028 |
^ jClass |
4029 |
||
268
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
4030 |
"Modified: / 23.1.1998 / 17:48:00 / cg" |
253 | 4031 |
! |
4032 |
||
4033 |
_Class_getClassLoader:nativeContext |
|
4034 |
"get a classes loader" |
|
4035 |
||
4036 |
|loader| |
|
4037 |
||
4038 |
loader := JavaClassReader classLoaderQuerySignal raise. |
|
4039 |
('JAVA: getClassLoader - ' , loader printString) infoPrintCR. |
|
4040 |
||
4041 |
"/ self unimplementedNativeMethod. |
|
4042 |
^ loader |
|
4043 |
||
4044 |
"Modified: / 21.8.1997 / 16:32:02 / cg" |
|
4045 |
"Created: / 5.1.1998 / 02:51:59 / cg" |
|
4046 |
! |
|
4047 |
||
255 | 4048 |
_Class_getName:nativeContext |
4049 |
"get a classes name" |
|
4050 |
||
4051 |
|jClass cls| |
|
4052 |
||
4053 |
jClass := nativeContext receiver. |
|
4054 |
cls := JavaClasses at:jClass. |
|
4055 |
^ Java as_String:((cls fullName copyFrom:1) replaceAll:$/ with:$.). |
|
4056 |
||
4057 |
"Modified: / 6.1.1998 / 18:30:52 / cg" |
|
4058 |
! |
|
4059 |
||
253 | 4060 |
_Class_getPrimitiveClass:nativeContext |
4061 |
"get a primitive class by name" |
|
4062 |
||
4063 |
|jClassName className cls| |
|
4064 |
||
4065 |
jClassName := nativeContext argAt:1. |
|
4066 |
className := Java as_ST_String:jClassName. |
|
4067 |
||
4068 |
JavaClasses isNil ifTrue:[ |
|
261 | 4069 |
self initializePrimitiveClasses |
253 | 4070 |
]. |
4071 |
cls := JavaClasses at:className. |
|
4072 |
||
4073 |
"/ cls := Java classForName:className. |
|
4074 |
"/ cls isNil ifTrue:[ |
|
4075 |
"/ cls := JavaClasses at:('JavaBase_' , className) asSymbol ifAbsent:nil. |
|
4076 |
"/ #( |
|
4077 |
"/ 'boolean' #Boolean |
|
4078 |
"/ 'float' #ShortFloat |
|
4079 |
"/ 'double' #Float |
|
4080 |
"/ 'int' #Integer |
|
4081 |
"/ 'long' #Integer |
|
4082 |
"/ 'char' #Character |
|
4083 |
"/ 'short' #Integer |
|
4084 |
"/ 'byte' #Integer |
|
4085 |
"/ 'void' #UndefinedObject |
|
4086 |
"/ ) pairWiseDo:[:nm :sym | |
|
4087 |
"/ className = nm ifTrue:[ |
|
4088 |
"/ cls := Smalltalk at:sym. |
|
4089 |
"/ ] |
|
4090 |
"/ ]. |
|
4091 |
"/ |
|
4092 |
"/ cls isNil ifTrue:[ |
|
4093 |
"/ self internalError:'class: ' , className , ' not found.'. |
|
4094 |
"/ ]. |
|
4095 |
"/ ]. |
|
4096 |
^ cls |
|
4097 |
||
4098 |
"Created: / 4.1.1998 / 00:46:03 / cg" |
|
4099 |
"Modified: / 4.1.1998 / 01:12:27 / cg" |
|
4100 |
! |
|
4101 |
||
255 | 4102 |
_Class_getSuperclass:nativeContext |
4103 |
"return a classes superclass" |
|
4104 |
||
4105 |
|jClass cls superCls| |
|
4106 |
||
4107 |
jClass := nativeContext receiver. |
|
4108 |
cls := JavaClasses at:jClass. |
|
4109 |
superCls := cls superclass. |
|
4110 |
superCls == JavaObject ifTrue:[ |
|
270 | 4111 |
^ nil. |
255 | 4112 |
]. |
4113 |
jClass := JavaClasses at:cls ifAbsent:nil. |
|
4114 |
jClass isNil ifTrue:[ |
|
270 | 4115 |
"/ class must be initialized (with all of its superclasses ?). |
4116 |
cls classInit. |
|
4117 |
||
4118 |
JavaClasses at:cls put:(jClass := (Java at:'java.lang.Class') new). |
|
4119 |
JavaClasses at:jClass put:cls. |
|
255 | 4120 |
]. |
4121 |
^ jClass |
|
4122 |
||
4123 |
"Created: / 12.1.1998 / 12:38:36 / cg" |
|
261 | 4124 |
"Modified: / 15.1.1998 / 00:57:34 / cg" |
255 | 4125 |
! |
4126 |
||
4127 |
_Class_isInterface:nativeContext |
|
4128 |
"return true, if this class is an interface" |
|
4129 |
||
4130 |
|jClass cls| |
|
4131 |
||
4132 |
jClass := nativeContext receiver. |
|
4133 |
cls := JavaClasses at:jClass. |
|
4134 |
cls isInterface ifTrue:[^ 1 "TRUE"]. |
|
4135 |
^ 0 "FALSE" |
|
4136 |
||
4137 |
"Created: / 12.1.1998 / 12:37:02 / cg" |
|
4138 |
! |
|
4139 |
||
253 | 4140 |
_Class_newInstance:nativeContext |
4141 |
"get an instance for a java.lang.Class" |
|
4142 |
||
4143 |
|jClass cls newInst| |
|
4144 |
||
4145 |
jClass := nativeContext receiver. |
|
4146 |
cls := JavaClasses at:jClass. |
|
261 | 4147 |
cls classInit. |
253 | 4148 |
newInst := cls newCleared. |
255 | 4149 |
newInst perform:#'<init>()V'. |
253 | 4150 |
|
4151 |
^ newInst |
|
4152 |
||
4153 |
"Created: / 2.1.1998 / 22:41:38 / cg" |
|
261 | 4154 |
"Modified: / 15.1.1998 / 00:57:37 / cg" |
253 | 4155 |
! |
4156 |
||
4157 |
_Double_doubleToLongBits:nativeContext |
|
4158 |
|f i| |
|
4159 |
||
4160 |
f := nativeContext argAt:1. |
|
4161 |
||
4162 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
261 | 4163 |
i := f basicAt:8. |
4164 |
i := i bitOr:((f basicAt:7) bitShift:8). |
|
4165 |
i := i bitOr:((f basicAt:6) bitShift:16). |
|
4166 |
i := i bitOr:((f basicAt:5) bitShift:24). |
|
4167 |
i := i bitOr:((f basicAt:4) bitShift:32). |
|
4168 |
i := i bitOr:((f basicAt:3) bitShift:40). |
|
4169 |
i := i bitOr:((f basicAt:2) bitShift:48). |
|
4170 |
i := i bitOr:((f basicAt:1) bitShift:56). |
|
253 | 4171 |
] ifFalse:[ |
261 | 4172 |
i := f basicAt:1. |
4173 |
i := i bitOr:((f basicAt:2) bitShift:8). |
|
4174 |
i := i bitOr:((f basicAt:3) bitShift:16). |
|
4175 |
i := i bitOr:((f basicAt:4) bitShift:24). |
|
4176 |
i := i bitOr:((f basicAt:5) bitShift:32). |
|
4177 |
i := i bitOr:((f basicAt:6) bitShift:40). |
|
4178 |
i := i bitOr:((f basicAt:7) bitShift:48). |
|
4179 |
i := i bitOr:((f basicAt:8) bitShift:56). |
|
253 | 4180 |
]. |
4181 |
||
4182 |
^ i. |
|
4183 |
||
4184 |
"Created: / 4.1.1998 / 01:39:12 / cg" |
|
4185 |
! |
|
4186 |
||
4187 |
_Double_longBitsToDouble:nativeContext |
|
4188 |
|i aFloat| |
|
4189 |
||
4190 |
i := nativeContext argAt:1. |
|
4191 |
||
4192 |
aFloat := Float new. |
|
4193 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
261 | 4194 |
aFloat basicAt:1 put:((i bitShift:-56) bitAnd:16rFF). |
4195 |
aFloat basicAt:2 put:((i bitShift:-48) bitAnd:16rFF). |
|
4196 |
aFloat basicAt:3 put:((i bitShift:-40) bitAnd:16rFF). |
|
4197 |
aFloat basicAt:4 put:((i bitShift:-32) bitAnd:16rFF). |
|
4198 |
aFloat basicAt:5 put:((i bitShift:-24) bitAnd:16rFF). |
|
4199 |
aFloat basicAt:6 put:((i bitShift:-16) bitAnd:16rFF). |
|
4200 |
aFloat basicAt:7 put:((i bitShift:-8) bitAnd:16rFF). |
|
4201 |
aFloat basicAt:8 put:(i bitAnd:16rFF). |
|
253 | 4202 |
] ifFalse:[ |
261 | 4203 |
aFloat basicAt:1 put:(i bitAnd:16rFF). |
4204 |
aFloat basicAt:2 put:((i bitShift:-8) bitAnd:16rFF). |
|
4205 |
aFloat basicAt:3 put:((i bitShift:-16) bitAnd:16rFF). |
|
4206 |
aFloat basicAt:4 put:((i bitShift:-24) bitAnd:16rFF). |
|
4207 |
aFloat basicAt:5 put:((i bitShift:-32) bitAnd:16rFF). |
|
4208 |
aFloat basicAt:6 put:((i bitShift:-40) bitAnd:16rFF). |
|
4209 |
aFloat basicAt:7 put:((i bitShift:-48) bitAnd:16rFF). |
|
4210 |
aFloat basicAt:8 put:((i bitShift:-56) bitAnd:16rFF). |
|
253 | 4211 |
]. |
4212 |
||
4213 |
^ aFloat. |
|
4214 |
||
4215 |
"Created: / 4.1.1998 / 01:45:00 / cg" |
|
4216 |
! |
|
4217 |
||
255 | 4218 |
_Double_valueOf0:nativeContext |
4219 |
|s d| |
|
4220 |
||
4221 |
s := nativeContext argAt:1. |
|
4222 |
s notNil ifTrue:[ |
|
261 | 4223 |
s := Java as_ST_String:s. |
4224 |
d := Float readFrom:s onError:nil. |
|
255 | 4225 |
]. |
4226 |
d isNil ifTrue:[ |
|
261 | 4227 |
self throwNumberFormatException. |
4228 |
"/ not reached |
|
255 | 4229 |
]. |
4230 |
||
4231 |
^ d |
|
4232 |
||
4233 |
"Modified: / 8.8.1997 / 12:03:55 / cg" |
|
4234 |
"Created: / 7.1.1998 / 11:09:43 / cg" |
|
4235 |
! |
|
4236 |
||
253 | 4237 |
_Float_floatToIntBits:nativeContext |
4238 |
|f i| |
|
4239 |
||
4240 |
f := nativeContext argAt:1. |
|
4241 |
||
4242 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
261 | 4243 |
i := f basicAt:4. |
4244 |
i := i bitOr:((f basicAt:3) bitShift:8). |
|
4245 |
i := i bitOr:((f basicAt:2) bitShift:16). |
|
4246 |
i := i bitOr:((f basicAt:1) bitShift:24). |
|
253 | 4247 |
] ifFalse:[ |
261 | 4248 |
i := f basicAt:1. |
4249 |
i := i bitOr:((f basicAt:2) bitShift:8). |
|
4250 |
i := i bitOr:((f basicAt:3) bitShift:16). |
|
4251 |
i := i bitOr:((f basicAt:4) bitShift:24). |
|
253 | 4252 |
]. |
4253 |
||
4254 |
^ i. |
|
4255 |
||
4256 |
"Created: / 4.1.1998 / 01:25:50 / cg" |
|
4257 |
! |
|
4258 |
||
261 | 4259 |
_Float_intBitsToFloat:nativeContet |
4260 |
|i aFloat| |
|
4261 |
||
4262 |
i := nativeContet argAt:1. |
|
4263 |
||
4264 |
aFloat := ShortFloat basicNew. |
|
4265 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
4266 |
aFloat basicAt:1 put:((i bitShift:-24) bitAnd:16rFF). |
|
4267 |
aFloat basicAt:2 put:((i bitShift:-16) bitAnd:16rFF). |
|
4268 |
aFloat basicAt:3 put:((i bitShift:-8) bitAnd:16rFF). |
|
4269 |
aFloat basicAt:4 put:(i bitAnd:16rFF). |
|
4270 |
] ifFalse:[ |
|
4271 |
aFloat basicAt:1 put:(i bitAnd:16rFF). |
|
4272 |
aFloat basicAt:2 put:((i bitShift:-8) bitAnd:16rFF). |
|
4273 |
aFloat basicAt:3 put:((i bitShift:-16) bitAnd:16rFF). |
|
4274 |
aFloat basicAt:4 put:((i bitShift:-24) bitAnd:16rFF). |
|
4275 |
]. |
|
4276 |
||
4277 |
^ aFloat. |
|
4278 |
||
4279 |
"Created: / 13.1.1998 / 23:03:36 / cg" |
|
4280 |
"Modified: / 13.1.1998 / 23:05:01 / cg" |
|
4281 |
! |
|
4282 |
||
255 | 4283 |
_Math_ceil:nativeContext |
4284 |
"ceiling" |
|
4285 |
||
4286 |
|dVal| |
|
4287 |
||
4288 |
dVal := nativeContext argAt:1. |
|
4289 |
(nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[ |
|
261 | 4290 |
self halt:'expected double arg' |
255 | 4291 |
]. |
4292 |
^ dVal ceilingAsFloat |
|
4293 |
||
4294 |
"Created: / 7.1.1998 / 15:43:00 / cg" |
|
4295 |
! |
|
4296 |
||
4297 |
_Math_cos:nativeContext |
|
4298 |
"cosine" |
|
4299 |
||
4300 |
|dVal| |
|
4301 |
||
4302 |
dVal := nativeContext argAt:1. |
|
4303 |
(nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[ |
|
261 | 4304 |
self halt:'expected double arg' |
255 | 4305 |
]. |
4306 |
^ dVal cos |
|
4307 |
||
4308 |
"Created: / 7.1.1998 / 15:41:30 / cg" |
|
4309 |
! |
|
4310 |
||
4311 |
_Math_floor:nativeContext |
|
4312 |
"floor" |
|
4313 |
||
4314 |
|dVal| |
|
4315 |
||
4316 |
dVal := nativeContext argAt:1. |
|
4317 |
(nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[ |
|
261 | 4318 |
self halt:'expected double arg' |
255 | 4319 |
]. |
4320 |
^ dVal floorAsFloat |
|
4321 |
||
4322 |
"Created: / 7.1.1998 / 19:09:21 / cg" |
|
4323 |
! |
|
4324 |
||
4325 |
_Math_log:nativeContext |
|
4326 |
"logarithm" |
|
4327 |
||
4328 |
|dVal| |
|
4329 |
||
4330 |
dVal := nativeContext argAt:1. |
|
4331 |
(nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[ |
|
261 | 4332 |
self halt:'expected double arg' |
255 | 4333 |
]. |
4334 |
^ dVal log |
|
4335 |
||
4336 |
"Created: / 7.1.1998 / 15:42:19 / cg" |
|
4337 |
! |
|
4338 |
||
4339 |
_Math_pow:nativeContext |
|
4340 |
"power" |
|
4341 |
||
4342 |
|dVal1 dVal2| |
|
4343 |
||
4344 |
dVal1 := nativeContext argAt:1. |
|
4345 |
(nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[ |
|
261 | 4346 |
self halt:'expected double arg' |
255 | 4347 |
]. |
4348 |
dVal2 := nativeContext argAt:3. |
|
4349 |
(nativeContext argAt:4) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[ |
|
261 | 4350 |
self halt:'expected double arg' |
255 | 4351 |
]. |
4352 |
^ dVal1 raisedTo:dVal2 |
|
4353 |
||
4354 |
"Modified: / 15.8.1997 / 05:24:27 / cg" |
|
4355 |
"Created: / 7.1.1998 / 15:44:13 / cg" |
|
4356 |
! |
|
4357 |
||
4358 |
_Math_sin:nativeContext |
|
4359 |
"sine" |
|
4360 |
||
4361 |
|dVal| |
|
4362 |
||
4363 |
dVal := nativeContext argAt:1. |
|
4364 |
(nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[ |
|
261 | 4365 |
self halt:'expected double arg' |
255 | 4366 |
]. |
4367 |
^ dVal sin |
|
4368 |
||
4369 |
"Created: / 7.1.1998 / 15:41:40 / cg" |
|
4370 |
! |
|
4371 |
||
4372 |
_Math_sqrt:nativeContext |
|
4373 |
"square root" |
|
4374 |
||
4375 |
|dVal| |
|
4376 |
||
4377 |
dVal := nativeContext argAt:1. |
|
4378 |
(nativeContext argAt:2) ~~ DUMMY_DOUBLE_HIGHWORD ifTrue:[ |
|
261 | 4379 |
self halt:'expected double arg' |
255 | 4380 |
]. |
4381 |
^ dVal sqrt |
|
4382 |
||
4383 |
"Created: / 7.1.1998 / 15:42:40 / cg" |
|
4384 |
! |
|
4385 |
||
253 | 4386 |
_Object_clone:nativeContext |
4387 |
"clone an object" |
|
4388 |
||
4389 |
|o rslt| |
|
4390 |
||
4391 |
o := nativeContext receiver. |
|
4392 |
rslt := o shallowCopy. |
|
4393 |
^ rslt |
|
4394 |
||
4395 |
"Created: / 4.1.1998 / 19:39:26 / cg" |
|
4396 |
! |
|
4397 |
||
255 | 4398 |
_Object_getClass:nativeContext |
4399 |
"return an objects class" |
|
4400 |
||
4401 |
|o cls jClass| |
|
4402 |
||
4403 |
o := nativeContext receiver. |
|
4404 |
cls := o class. |
|
4405 |
||
268
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
4406 |
jClass := self javaClassObjectForClass:cls. |
255 | 4407 |
^ jClass |
4408 |
||
4409 |
"Created: / 6.1.1998 / 18:28:27 / cg" |
|
268
f7357f1142c8
provide & use a helper to associate java.lang.class insts to javaClasses
cg
parents:
266
diff
changeset
|
4410 |
"Modified: / 23.1.1998 / 17:48:22 / cg" |
255 | 4411 |
! |
4412 |
||
253 | 4413 |
_Object_hashCode:nativeContext |
4414 |
"identityHash" |
|
4415 |
||
4416 |
|o rslt| |
|
4417 |
||
4418 |
o := nativeContext receiver. |
|
4419 |
rslt := o identityHash. |
|
4420 |
^ rslt |
|
4421 |
||
4422 |
"Created: / 4.1.1998 / 19:40:26 / cg" |
|
4423 |
! |
|
4424 |
||
255 | 4425 |
_Object_notify:nativeContext |
4426 |
"wakeup" |
|
4427 |
||
4428 |
self wakeup:(nativeContext receiver). |
|
4429 |
||
4430 |
"Created: / 6.1.1998 / 21:09:26 / cg" |
|
4431 |
! |
|
4432 |
||
253 | 4433 |
_Object_notifyAll:nativeContext |
4434 |
self wakeupAll:(nativeContext receiver). |
|
4435 |
||
4436 |
"Created: / 3.1.1998 / 03:06:56 / cg" |
|
4437 |
! |
|
4438 |
||
4439 |
_Object_wait:nativeMethodContext |
|
4440 |
"wait" |
|
4441 |
||
4442 |
|tmo handle sema enteredMonitors| |
|
4443 |
||
4444 |
handle := nativeMethodContext receiver. |
|
4445 |
tmo := nativeMethodContext argAt:1. |
|
4446 |
||
4447 |
"/ DEBUG BEGIN |
|
4448 |
(nativeMethodContext argAt:2) == DUMMY_LONG_HIGHWORD ifFalse:[ |
|
261 | 4449 |
self halt:'expected long arg' |
253 | 4450 |
]. |
4451 |
"/ DEBUG END |
|
4452 |
||
4453 |
sema := JavaVM semaphoreFor:handle. |
|
4454 |
||
4455 |
"/ temporarily leave all entered monitors. |
|
4456 |
||
4457 |
enteredMonitors := self enteredMonitors. |
|
4458 |
||
4459 |
enteredMonitors size > 0 ifTrue:[ |
|
261 | 4460 |
MonitorTrace ifTrue:[ |
4461 |
('====> wait - exit ' , enteredMonitors size printString , ' monitors in ' , Processor activeProcess name , ' ...') infoPrintCR. |
|
4462 |
]. |
|
4463 |
enteredMonitors do:[:handle | |
|
4464 |
|mon| |
|
4465 |
||
4466 |
mon := LockTable at:handle ifAbsent:nil. |
|
4467 |
mon isNil ifTrue:[ |
|
4468 |
self halt:'no monitor in wait'. |
|
4469 |
] ifFalse:[ |
|
4470 |
MonitorTrace ifTrue:[ |
|
4471 |
('====> wait - exit monitor for ' , handle displayString , ' in ' , Processor activeProcess name , ' ...') infoPrintCR. |
|
4472 |
]. |
|
4473 |
mon exit. |
|
4474 |
]. |
|
4475 |
]. |
|
253 | 4476 |
]. |
4477 |
||
4478 |
[ |
|
261 | 4479 |
ThreadTrace ifTrue:[ |
4480 |
('====> thread ' , Processor activeProcess name , ' waiting ...') infoPrintCR. |
|
4481 |
]. |
|
4482 |
tmo = 0 ifTrue:[ |
|
4483 |
Processor activeProcess state:#javaWait. |
|
4484 |
sema wait. |
|
4485 |
] ifFalse:[ |
|
4486 |
sema waitWithTimeout:tmo / 1000. |
|
4487 |
]. |
|
253 | 4488 |
] valueNowOrOnUnwindDo:[ |
261 | 4489 |
JavaVM releaseSemaphoreFor:handle. |
253 | 4490 |
]. |
4491 |
||
4492 |
"/ re-enter monitors. |
|
4493 |
||
4494 |
enteredMonitors size > 0 ifTrue:[ |
|
261 | 4495 |
MonitorTrace ifTrue:[ |
4496 |
('====> wait - reenter ' , enteredMonitors size printString , ' monitors in ' , Processor activeProcess name , ' ...') infoPrintCR. |
|
4497 |
]. |
|
4498 |
enteredMonitors do:[:handle | |
|
4499 |
|mon| |
|
4500 |
||
4501 |
LockTableAccess critical:[ |
|
4502 |
mon := LockTable at:handle ifAbsent:nil. |
|
4503 |
mon isNil ifTrue:[ |
|
4504 |
LockTable at:handle put:(mon := Monitor new) |
|
4505 |
] |
|
4506 |
]. |
|
4507 |
MonitorTrace ifTrue:[ |
|
4508 |
('====> wait - reenter monitor for ' , handle displayString , ' in ' , Processor activeProcess name , ' ...') infoPrintCR. |
|
4509 |
]. |
|
4510 |
mon enter. |
|
4511 |
] |
|
253 | 4512 |
]. |
4513 |
||
4514 |
ThreadTrace ifTrue:[ |
|
261 | 4515 |
'====> thread continues ...' printCR. |
253 | 4516 |
] |
4517 |
||
255 | 4518 |
"Modified: / 9.1.1998 / 10:41:47 / cg" |
253 | 4519 |
! |
4520 |
||
4521 |
_Runtime_buildLibName:nativeContext |
|
4522 |
|jPath jFileName path fileName libName| |
|
4523 |
||
4524 |
jPath := nativeContext argAt:1. |
|
4525 |
jFileName := nativeContext argAt:2. |
|
4526 |
||
4527 |
path := Java as_ST_String:jPath. |
|
4528 |
fileName := Java as_ST_String:jFileName. |
|
4529 |
||
4530 |
path = '__builtIn__' ifTrue:[ |
|
261 | 4531 |
libName := path , '/' , fileName |
253 | 4532 |
] ifFalse:[ |
261 | 4533 |
libName := path , '/lib' , fileName , '.so'. |
253 | 4534 |
]. |
4535 |
^ Java as_String:libName. |
|
4536 |
||
4537 |
"Modified: / 8.8.1997 / 12:05:05 / cg" |
|
4538 |
"Created: / 4.1.1998 / 19:07:14 / cg" |
|
4539 |
! |
|
4540 |
||
261 | 4541 |
_Runtime_execInternal:nativeContext |
4542 |
"Run a unix-command; return a process object." |
|
4543 |
||
4544 |
|cmdAndArgArray envArray cmd jProcessClass jProcess| |
|
4545 |
||
4546 |
"/ cmdAndArgArray := nativeContext argAt:1. |
|
4547 |
"/ envArray := nativeContext argAt:2. |
|
4548 |
"/ |
|
4549 |
"/ cmd := cmdAndArgArray at:1. |
|
4550 |
"/ |
|
4551 |
"/ jProcessClass := Java classForName:'java.lang.UNIXProcess'. |
|
4552 |
"/ jProcessClass notNil ifTrue:[ |
|
4553 |
"/ jProcess := jProcessClass newCleared. |
|
4554 |
"/ jProcess |
|
4555 |
"/ perform:#'<init>([Ljava/lang/String;[Ljava/lang/String;)V' |
|
4556 |
"/ with:cmdAndArgArray |
|
4557 |
"/ with:envArray. |
|
4558 |
"/ ^ jProcess |
|
4559 |
"/ ]. |
|
4560 |
self throwIOExceptionWithMessage:'Process execution disabled/unimplemented'. |
|
4561 |
^ nil |
|
4562 |
||
4563 |
"Created: / 15.1.1998 / 01:50:31 / cg" |
|
4564 |
"Modified: / 15.1.1998 / 02:09:29 / cg" |
|
4565 |
! |
|
4566 |
||
255 | 4567 |
_Runtime_exitInternal:nativeContext |
4568 |
"exit - here, we only shut down java threads" |
|
4569 |
||
4570 |
|enteredMonitors| |
|
4571 |
||
4572 |
(enteredMonitors := self enteredMonitors) size > 0 ifTrue:[ |
|
261 | 4573 |
enteredMonitors do:[:handle | |
4574 |
| mon | |
|
4575 |
||
4576 |
mon := LockTable at:handle ifAbsent:nil. |
|
4577 |
mon isNil ifTrue:[ |
|
4578 |
self halt:'no monitor in exitInternal'. |
|
4579 |
] ifFalse:[ |
|
4580 |
mon exit. |
|
255 | 4581 |
('====> terminateThread - exit monitor for ' , handle displayString , ' in ' , Processor activeProcess name , ' ...') infoPrintCR. |
4582 |
"/ LockTableAccess critical:[ |
|
4583 |
"/ mon isFree ifTrue:[ |
|
4584 |
"/ LockTable removeKey:handle |
|
4585 |
"/ ] |
|
4586 |
"/ ] |
|
261 | 4587 |
]. |
4588 |
]. |
|
255 | 4589 |
]. |
4590 |
||
4591 |
JavaVM releaseAllJavaResources. |
|
4592 |
AbortSignal raise. |
|
4593 |
self halt. |
|
4594 |
||
4595 |
"Created: / 7.1.1998 / 22:48:51 / cg" |
|
4596 |
"Modified: / 7.1.1998 / 22:56:07 / cg" |
|
4597 |
! |
|
4598 |
||
4599 |
_Runtime_freeMemory:nativeContext |
|
4600 |
"free memory - Returns the number of free bytes" |
|
4601 |
||
4602 |
^ ObjectMemory freeListSpace + ObjectMemory freeSpace |
|
4603 |
||
4604 |
"Created: / 12.1.1998 / 12:59:53 / cg" |
|
4605 |
! |
|
4606 |
||
4607 |
_Runtime_gc:nativeContext |
|
4608 |
"Runs the garbage collector. |
|
4609 |
Ignored, since the ST-gc runs all the time." |
|
4610 |
||
4611 |
^ self |
|
4612 |
||
4613 |
"Modified: / 12.1.1998 / 12:58:32 / cg" |
|
4614 |
! |
|
4615 |
||
253 | 4616 |
_Runtime_initializeLinkerInternal:nativeContext |
4617 |
"init sharedLib linker, return searchPath as javaString" |
|
4618 |
||
4619 |
|path| |
|
4620 |
||
4621 |
"/ mhmh - what is done here ? |
|
4622 |
||
4623 |
path := ''. |
|
4624 |
LibPath do:[:comp | path size == 0 ifTrue:[ |
|
261 | 4625 |
path := path , comp |
4626 |
] ifFalse:[ |
|
4627 |
path := path , ':' , comp |
|
4628 |
] |
|
4629 |
]. |
|
253 | 4630 |
|
4631 |
^ Java as_String:path |
|
4632 |
||
4633 |
"Modified: / 7.8.1997 / 21:17:03 / cg" |
|
4634 |
"Created: / 4.1.1998 / 17:53:15 / cg" |
|
4635 |
! |
|
4636 |
||
4637 |
_Runtime_loadFileInternal:nativeContext |
|
4638 |
"load a sharedLib, return boolean 0 (false) if fail; 1 (true) if ok" |
|
4639 |
||
4640 |
|ret| |
|
4641 |
||
4642 |
ret := self _Runtime_loadFileInternalI:nativeContext. |
|
4643 |
ret < 0 ifTrue:[ ret := 0 ]. |
|
4644 |
^ ret |
|
4645 |
||
4646 |
"Created: / 4.1.1998 / 19:10:20 / cg" |
|
4647 |
"Modified: / 4.1.1998 / 19:11:04 / cg" |
|
4648 |
! |
|
4649 |
||
4650 |
_Runtime_loadFileInternalI:nativeContext |
|
4651 |
"1.1b3 change; load a sharedLib like 'loadFileInternal', |
|
4652 |
but return integer: |
|
261 | 4653 |
-1 outOfMemory error |
4654 |
0 failed to load |
|
4655 |
1 loaded or already loaded (i.e. ok)" |
|
253 | 4656 |
|
4657 |
|jLibName libName libHandle| |
|
4658 |
||
4659 |
jLibName := nativeContext argAt:1. |
|
4660 |
libName := Java as_ST_String:jLibName. |
|
4661 |
||
4662 |
(SimulatedLibs includes:libName) ifTrue:[ |
|
261 | 4663 |
('JAVA: builtIn libLoad simulated: ' , libName) printNL. |
4664 |
^ 1 |
|
253 | 4665 |
]. |
4666 |
(LoadedLibs notNil and:[LoadedLibs includesKey:libName]) ifTrue:[ |
|
261 | 4667 |
('JAVA: already loaded: ' , libName) printNL. |
4668 |
^ 1 |
|
253 | 4669 |
]. |
4670 |
||
4671 |
libName asFilename exists ifFalse:[ |
|
261 | 4672 |
('JAVA: no file to load: ' , libName) printNL. |
4673 |
^ 0 |
|
253 | 4674 |
]. |
4675 |
||
4676 |
libHandle := ObjectFileLoader loadLibrary:libName. |
|
4677 |
libHandle isNil ifTrue:[ |
|
261 | 4678 |
('JAVA: failed to load: ' , libName) printNL. |
4679 |
^ 0 |
|
253 | 4680 |
]. |
4681 |
||
4682 |
LoadedLibs isNil ifTrue:[ |
|
261 | 4683 |
LoadedLibs := Dictionary new. |
253 | 4684 |
]. |
4685 |
||
4686 |
LoadedLibs at:libName put:libHandle. |
|
4687 |
^ 1 |
|
4688 |
||
4689 |
"Modified: / 8.8.1997 / 12:05:07 / cg" |
|
4690 |
"Created: / 4.1.1998 / 19:10:54 / cg" |
|
4691 |
! |
|
4692 |
||
255 | 4693 |
_Runtime_totalMemory:nativeContext |
4694 |
"free memory - Returns the total number of bytes" |
|
4695 |
||
4696 |
^ ObjectMemory oldSpaceSize + ObjectMemory newSpaceSize |
|
4697 |
||
4698 |
"Created: / 12.1.1998 / 12:59:23 / cg" |
|
4699 |
! |
|
4700 |
||
261 | 4701 |
_SecurityManager_classLoaderDepth:nativeContext |
4702 |
|con depth| |
|
4703 |
||
4704 |
con := thisContext sender. |
|
4705 |
depth := 1. |
|
4706 |
[con notNil] whileTrue:[ |
|
4707 |
con receiver == JavaClassReader classLoaderQuerySignal ifTrue:[ |
|
4708 |
con selector == #handle:do: ifTrue:[ |
|
4709 |
depth := depth + 1 |
|
4710 |
] |
|
4711 |
]. |
|
4712 |
con := con sender. |
|
4713 |
]. |
|
4714 |
'JAVA: classLoaderDepth -> ' infoPrint. depth infoPrintCR. |
|
4715 |
^ depth. |
|
4716 |
||
4717 |
"Created: / 13.1.1998 / 09:21:46 / cg" |
|
4718 |
"Modified: / 13.1.1998 / 09:33:43 / cg" |
|
4719 |
! |
|
4720 |
||
4721 |
_SecurityManager_currentClassLoader:nativeContext |
|
4722 |
|loader| |
|
4723 |
||
4724 |
loader := JavaClassReader classLoaderQuerySignal raise. |
|
4725 |
'JAVA: currentClassLoader -> ' infoPrint. loader displayString infoPrintCR. |
|
4726 |
^ loader. |
|
4727 |
||
4728 |
"Created: / 13.1.1998 / 09:23:28 / cg" |
|
4729 |
! |
|
4730 |
||
253 | 4731 |
_System_arraycopy:nativeContext |
4732 |
|srcArray srcIdx dstArray dstIdx count| |
|
4733 |
||
4734 |
srcArray := nativeContext argAt:1. |
|
4735 |
srcIdx := nativeContext argAt:2. |
|
4736 |
dstArray := nativeContext argAt:3. |
|
4737 |
dstIdx := nativeContext argAt:4. |
|
4738 |
count := nativeContext argAt:5. |
|
4739 |
||
4740 |
srcArray class isBytes ifTrue:[ |
|
261 | 4741 |
dstArray class isBytes ifFalse:[ |
4742 |
self halt:'incompatible arraycopy collections'. |
|
4743 |
]. |
|
4744 |
dstArray replaceBytesFrom:(dstIdx+1) to:(dstIdx+count) with:srcArray startingAt:(srcIdx+1). |
|
253 | 4745 |
] ifFalse:[ |
261 | 4746 |
dstArray replaceFrom:(dstIdx+1) to:(dstIdx+count) with:srcArray startingAt:(srcIdx+1). |
253 | 4747 |
]. |
4748 |
^ nil. |
|
4749 |
||
4750 |
"Created: / 3.1.1998 / 01:56:44 / cg" |
|
4751 |
"Modified: / 3.1.1998 / 02:01:37 / cg" |
|
4752 |
! |
|
4753 |
||
4754 |
_System_currentTimeMillis:nativeContext |
|
4755 |
"return the milliseconds since 1.jan.1970" |
|
4756 |
||
4757 |
|seconds| |
|
4758 |
||
255 | 4759 |
^ AbsoluteTime now millisecondDeltaFrom:(AbsoluteTime day:1 month:1 year:1970 hour:1 minutes:0 seconds:0). |
4760 |
"/ seconds := AbsoluteTime now - (AbsoluteTime day:1 month:1 year:1970 hour:1 minutes:0 seconds:0). |
|
4761 |
"/ ^ seconds * 1000 |
|
253 | 4762 |
|
4763 |
"Created: / 3.1.1998 / 03:25:50 / cg" |
|
255 | 4764 |
"Modified: / 10.1.1998 / 01:32:24 / cg" |
253 | 4765 |
! |
4766 |
||
4767 |
_System_initProperties:nativeContext |
|
4768 |
|props stProps| |
|
4769 |
||
4770 |
props := nativeContext argAt:1. |
|
4771 |
stProps := self systemProperties. |
|
4772 |
||
4773 |
"/ recursively invoke myself on the Java HashTable. |
|
4774 |
"/ calling 'put' to stuff in the values ... |
|
4775 |
||
4776 |
stProps keysAndValuesDo:[:key :value | |
|
270 | 4777 |
|keyObj valueObj| |
4778 |
||
4779 |
keyObj := Java as_String:key. |
|
4780 |
valueObj := Java as_String:value. |
|
4781 |
||
4782 |
props |
|
4783 |
perform:#'put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;' |
|
4784 |
with:keyObj |
|
4785 |
with:valueObj. |
|
253 | 4786 |
]. |
4787 |
^ props |
|
4788 |
||
4789 |
"Created: / 3.1.1998 / 14:25:22 / cg" |
|
4790 |
"Modified: / 4.1.1998 / 14:23:18 / cg" |
|
4791 |
! |
|
4792 |
||
4793 |
_System_setErr0:nativeContext |
|
4794 |
|stream| |
|
4795 |
||
4796 |
stream := nativeContext argAt:1. |
|
4797 |
||
4798 |
self setOpenFile:(self javaConsoleStream ? Stderr) at:2. |
|
4799 |
||
4800 |
nativeContext receiver instVarNamed:'err' put:stream. |
|
4801 |
||
4802 |
"Created: / 18.3.1997 / 15:02:05 / cg" |
|
4803 |
"Modified: / 4.1.1998 / 16:21:15 / cg" |
|
4804 |
! |
|
4805 |
||
4806 |
_System_setIn0:nativeContext |
|
4807 |
|stream| |
|
4808 |
||
4809 |
stream := nativeContext argAt:1. |
|
4810 |
||
4811 |
self setOpenFile:Stdin at:0. |
|
4812 |
||
4813 |
nativeContext receiver instVarNamed:'in' put:stream. |
|
4814 |
||
4815 |
"Created: / 4.1.1998 / 16:16:38 / cg" |
|
4816 |
"Modified: / 4.1.1998 / 16:20:44 / cg" |
|
4817 |
! |
|
4818 |
||
4819 |
_System_setOut0:nativeContext |
|
4820 |
|stream| |
|
4821 |
||
4822 |
stream := nativeContext argAt:1. |
|
4823 |
||
4824 |
self setOpenFile:(self javaConsoleStream ? Stdout) at:1. |
|
4825 |
||
4826 |
nativeContext receiver instVarNamed:'out' put:stream. |
|
4827 |
||
4828 |
"Created: / 4.1.1998 / 16:18:26 / cg" |
|
4829 |
"Modified: / 4.1.1998 / 16:20:23 / cg" |
|
4830 |
! |
|
4831 |
||
4832 |
_Thread_currentThread:nativeMethodContext |
|
4833 |
|t p prio| |
|
4834 |
||
4835 |
p := Processor activeProcess. |
|
4836 |
t := self javaThreadForSTProcess:p. |
|
4837 |
t notNil ifTrue:[ |
|
261 | 4838 |
^ t |
253 | 4839 |
]. |
4840 |
t := self newThread:'main'. |
|
4841 |
Java threads at:t put:p. |
|
4842 |
^ t |
|
4843 |
||
4844 |
"Created: / 3.1.1998 / 01:42:28 / cg" |
|
4845 |
"Modified: / 4.1.1998 / 14:59:13 / cg" |
|
4846 |
! |
|
4847 |
||
4848 |
_Thread_isAlive:nativeContext |
|
4849 |
"is it alive ?" |
|
4850 |
||
4851 |
|jThread stProcess| |
|
4852 |
||
4853 |
jThread := nativeContext receiver. |
|
4854 |
stProcess := JavaVM stProcessForJavaThread:jThread. |
|
4855 |
stProcess isNil ifTrue:[ |
|
261 | 4856 |
('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL. |
4857 |
^ 0 "FALSE" |
|
255 | 4858 |
]. |
4859 |
stProcess isDead ifTrue:[^ 0 "FALSE"]. |
|
4860 |
^ 1 "TRUE" |
|
4861 |
||
4862 |
"Created: / 5.1.1998 / 02:03:51 / cg" |
|
4863 |
"Modified: / 8.1.1998 / 01:07:03 / cg" |
|
4864 |
! |
|
4865 |
||
4866 |
_Thread_isInterrupted:nativeContext |
|
4867 |
"ask if a thread is interrupted (clear interruptState if arg is true)" |
|
4868 |
||
4869 |
|jThread stProcess clearInterrupt rslt| |
|
4870 |
||
4871 |
jThread := nativeContext receiver. |
|
4872 |
stProcess := self stProcessForJavaThread:jThread. |
|
4873 |
stProcess isNil ifTrue:[ |
|
261 | 4874 |
self halt. |
4875 |
^ 0 |
|
253 | 4876 |
]. |
255 | 4877 |
|
4878 |
clearInterrupt := nativeContext argAt:1. |
|
4879 |
rslt := stProcess isInterrupted ifTrue:[1] ifFalse:[0]. |
|
4880 |
clearInterrupt ~~ 0 ifTrue:[stProcess clearInterruptActions]. |
|
4881 |
^ rslt |
|
4882 |
||
4883 |
"Modified: / 2.1.1998 / 21:49:06 / cg" |
|
4884 |
"Created: / 7.1.1998 / 18:50:26 / cg" |
|
4885 |
! |
|
4886 |
||
4887 |
_Thread_resume0:nativeContext |
|
4888 |
"yield" |
|
4889 |
||
4890 |
|jThread stProcess| |
|
4891 |
||
4892 |
jThread := nativeContext receiver. |
|
4893 |
stProcess := JavaVM stProcessForJavaThread:jThread. |
|
4894 |
stProcess isNil ifTrue:[ |
|
261 | 4895 |
('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL. |
4896 |
^ nil "void" |
|
255 | 4897 |
]. |
4898 |
stProcess resume |
|
4899 |
||
4900 |
"Modified: / 8.1.1998 / 00:14:43 / cg" |
|
4901 |
"Created: / 8.1.1998 / 01:06:27 / cg" |
|
253 | 4902 |
! |
4903 |
||
4904 |
_Thread_setPriority0:nativeMethodContext |
|
4905 |
|t p prio| |
|
4906 |
||
4907 |
t := nativeMethodContext receiver. |
|
4908 |
p := JavaVM stProcessForJavaThread:t. |
|
4909 |
prio := nativeMethodContext argAt:1. |
|
4910 |
||
4911 |
p isNil ifTrue:[ |
|
261 | 4912 |
'JAVA [info]: no process yet (in setPriority)' infoPrintCR. |
4913 |
^ nil |
|
253 | 4914 |
]. |
4915 |
||
4916 |
ThreadTrace ifTrue:[ |
|
261 | 4917 |
'JAVA [info]: setPrio: ' print. t print. ' pri= ' print. prio print. ' p= ' print. p printNL. |
253 | 4918 |
]. |
4919 |
^ nil |
|
4920 |
||
4921 |
"Created: / 2.1.1998 / 19:05:55 / cg" |
|
4922 |
"Modified: / 2.1.1998 / 22:38:20 / cg" |
|
4923 |
! |
|
4924 |
||
255 | 4925 |
_Thread_sleep:nativeContext |
4926 |
"sleep for some milliseconds " |
|
4927 |
||
4928 |
|millis| |
|
4929 |
||
4930 |
(nativeContext argAt:2) ~~ DUMMY_LONG_HIGHWORD ifTrue:[ |
|
261 | 4931 |
self internalError:'expected long arg'. |
255 | 4932 |
] ifFalse:[ |
261 | 4933 |
millis := nativeContext argAt:1. |
4934 |
Delay waitForMilliseconds:(millis max:50) |
|
255 | 4935 |
]. |
4936 |
||
4937 |
"Created: / 7.1.1998 / 15:34:23 / cg" |
|
261 | 4938 |
"Modified: / 13.1.1998 / 13:48:25 / cg" |
255 | 4939 |
! |
4940 |
||
253 | 4941 |
_Thread_start:nativeContext |
4942 |
"start the thread" |
|
4943 |
||
4944 |
|jThread jName name stProcess| |
|
4945 |
||
4946 |
jThread := nativeContext receiver. |
|
4947 |
(jThread instVarNamed:'priority') < 1 ifTrue:[ |
|
270 | 4948 |
self halt. |
4949 |
jThread instVarNamed:'priority' put:1. |
|
253 | 4950 |
]. |
4951 |
||
4952 |
stProcess := JavaProcess |
|
270 | 4953 |
for:[ |
4954 |
[ |
|
4955 |
JavaVM javaExceptionSignal handle:[:ex | |
|
4956 |
|procName exClass| |
|
4957 |
||
4958 |
procName := stProcess name. |
|
4959 |
exClass := ex parameter class. |
|
4960 |
||
4961 |
exClass == (Java at:'java.lang.ThreadDeath') ifTrue:[ |
|
4962 |
('JAVA: thread ' , procName , ' terminated') infoPrintCR. |
|
4963 |
] ifFalse:[ |
|
4964 |
Transcript |
|
4965 |
showCR:('JAVA: thread ''' |
|
4966 |
, procName |
|
4967 |
, ''' terminated with exception: ' |
|
4968 |
, exClass name). |
|
4969 |
]. |
|
4970 |
ex return. |
|
4971 |
] do:[ |
|
4972 |
jThread perform:#'run()V'. |
|
4973 |
('JAVA: thread ' , stProcess name , ' terminated') infoPrintCR. |
|
4974 |
||
4975 |
jThread perform:#'exit()V'. |
|
4976 |
('JAVA: after exit of thread ' , stProcess name) infoPrintCR. |
|
4977 |
] |
|
4978 |
] valueNowOrOnUnwindDo:[ |
|
4979 |
Java threads removeKey:jThread ifAbsent:[]. |
|
4980 |
] |
|
4981 |
] |
|
4982 |
priority:(Processor activePriority). |
|
253 | 4983 |
|
4984 |
jName := jThread instVarNamed:'name'. |
|
4985 |
jName isString ifFalse:[ |
|
270 | 4986 |
name := Java as_ST_String:jName. |
253 | 4987 |
] ifTrue:[ |
270 | 4988 |
name := jName |
253 | 4989 |
]. |
4990 |
||
4991 |
"/ when that process terminates, wakup any waiters |
|
4992 |
stProcess addExitAction:[self wakeup:jThread]. |
|
4993 |
||
4994 |
stProcess name:'JAVA-' , name. |
|
4995 |
stProcess resume. |
|
4996 |
||
4997 |
Java threads at:jThread put:stProcess. |
|
4998 |
||
4999 |
^ nil |
|
5000 |
||
5001 |
"Created: / 3.1.1998 / 02:05:52 / cg" |
|
262 | 5002 |
"Modified: / 17.1.1998 / 13:18:34 / cg" |
255 | 5003 |
! |
5004 |
||
5005 |
_Thread_stop0:nativeContext |
|
5006 |
"terminate a thread" |
|
5007 |
||
5008 |
|jThread stProcess death| |
|
5009 |
||
5010 |
jThread := nativeContext receiver. |
|
5011 |
||
5012 |
stProcess := JavaVM stProcessForJavaThread:jThread. |
|
5013 |
stProcess isNil ifTrue:[ |
|
270 | 5014 |
('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL. |
5015 |
^ nil "void" |
|
255 | 5016 |
]. |
5017 |
death := nativeContext argAt:1. |
|
5018 |
stProcess |
|
270 | 5019 |
interruptWith:[ |
5020 |
JavaVM javaExceptionSignal handle:[:ex | |
|
5021 |
Processor activeProcess terminate |
|
5022 |
] do:[ |
|
5023 |
('JAVA: thread exit: ' , jThread displayString) infoPrintNL. |
|
5024 |
jThread perform:#'exit()V'. |
|
5025 |
self throwException:death. |
|
5026 |
] |
|
5027 |
]. |
|
255 | 5028 |
stProcess resume. |
5029 |
||
5030 |
[stProcess isDead] whileFalse:[ |
|
270 | 5031 |
stProcess resume. |
5032 |
Delay waitForSeconds:0.1 |
|
255 | 5033 |
]. |
5034 |
stProcess terminate |
|
5035 |
||
5036 |
"Created: / 8.1.1998 / 13:11:17 / cg" |
|
5037 |
"Modified: / 9.1.1998 / 03:49:45 / cg" |
|
5038 |
! |
|
5039 |
||
5040 |
_Thread_suspend0:nativeContext |
|
5041 |
"yield" |
|
5042 |
||
5043 |
|jThread stProcess| |
|
5044 |
||
5045 |
jThread := nativeContext receiver. |
|
5046 |
stProcess := JavaVM stProcessForJavaThread:jThread. |
|
5047 |
stProcess isNil ifTrue:[ |
|
261 | 5048 |
('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL. |
5049 |
^ nil "void" |
|
255 | 5050 |
]. |
5051 |
stProcess suspend |
|
5052 |
||
5053 |
"Created: / 8.1.1998 / 01:05:49 / cg" |
|
5054 |
"Modified: / 8.1.1998 / 01:06:36 / cg" |
|
5055 |
! |
|
5056 |
||
5057 |
_Thread_yield:nativeContext |
|
5058 |
"yield" |
|
5059 |
||
5060 |
|jThread stProcess| |
|
5061 |
||
5062 |
jThread := nativeContext receiver. |
|
5063 |
stProcess := JavaVM stProcessForJavaThread:jThread. |
|
5064 |
stProcess isNil ifTrue:[ |
|
261 | 5065 |
('JAVA: no stProcess for javaThread: ' , jThread displayString) printNL. |
5066 |
^ nil "void" |
|
255 | 5067 |
]. |
5068 |
stProcess == Processor activeProcess ifTrue:[ |
|
261 | 5069 |
Processor yield. |
255 | 5070 |
] ifFalse:[ |
261 | 5071 |
self halt. |
255 | 5072 |
]. |
5073 |
||
5074 |
"Created: / 5.1.1998 / 02:03:51 / cg" |
|
5075 |
"Modified: / 8.1.1998 / 01:06:41 / cg" |
|
253 | 5076 |
! |
5077 |
||
5078 |
_Throwable_fillInStackTrace:nativeContext |
|
255 | 5079 |
|exClass exceptionObject list con| |
253 | 5080 |
|
5081 |
exClass := Java classNamed:'java.lang.Throwable'. |
|
5082 |
||
5083 |
exceptionObject := nativeContext receiver. |
|
5084 |
||
5085 |
"/ |
|
5086 |
"/ debugging only |
|
5087 |
"/ |
|
5088 |
(exceptionObject isKindOf:(Java classNamed:'java.lang.Throwable')) ifFalse:[ |
|
270 | 5089 |
self halt |
253 | 5090 |
]. |
5091 |
||
5092 |
con := thisContext sender. |
|
5093 |
||
5094 |
"/ |
|
5095 |
"/ we are not interrested in all intermediate Exception frames ... |
|
5096 |
"/ |
|
5097 |
FullExceptionTrace ifFalse:[ |
|
270 | 5098 |
"/ first, skip any JavaVM contexts |
5099 |
[con receiver == exceptionObject] whileFalse:[ |
|
5100 |
con := con sender |
|
5101 |
]. |
|
5102 |
"/ then, all exception-init contexts |
|
5103 |
[con receiver == exceptionObject] whileTrue:[ |
|
5104 |
con := con sender |
|
5105 |
]. |
|
253 | 5106 |
]. |
5107 |
||
255 | 5108 |
list := OrderedCollection new. |
5109 |
[con notNil] whileTrue:[ |
|
270 | 5110 |
(con isKindOf:JavaContext) ifTrue:[ |
5111 |
"/ add a copy, in case the context continues with some |
|
5112 |
"/ cleanup ... |
|
5113 |
list add:con shallowCopy |
|
5114 |
]. |
|
5115 |
con := con sender |
|
255 | 5116 |
]. |
5117 |
||
5118 |
exceptionObject instVarNamed:'backtrace' put:(list asArray). |
|
253 | 5119 |
|
5120 |
^ nil. |
|
5121 |
||
5122 |
"Created: / 4.1.1998 / 14:27:40 / cg" |
|
261 | 5123 |
"Modified: / 14.1.1998 / 23:57:51 / cg" |
255 | 5124 |
! |
5125 |
||
5126 |
_Throwable_printStackTrace0:nativeContext |
|
261 | 5127 |
|out outStream exceptionObject contextList| |
255 | 5128 |
|
5129 |
outStream := nativeContext argAt:1. |
|
5130 |
exceptionObject := nativeContext receiver. |
|
5131 |
||
5132 |
contextList := exceptionObject instVarNamed:'backtrace'. |
|
5133 |
||
261 | 5134 |
out := self javaConsoleStream. |
5135 |
out cr. |
|
5136 |
out nextPutLine:'JAVA: stackTrace:'. |
|
255 | 5137 |
|
5138 |
contextList do:[:con | |
|
270 | 5139 |
out |
5140 |
nextPutAll:' '; |
|
5141 |
nextPutAll:(con method javaClass fullName); |
|
5142 |
nextPutAll:'.'; |
|
5143 |
nextPutAll:(con method selector); |
|
5144 |
nextPutAll:' ['; |
|
5145 |
nextPutAll:(con method javaClass sourceFile); |
|
5146 |
nextPutAll:' '; |
|
5147 |
nextPutAll:(con lineNumber displayString); |
|
5148 |
nextPutAll:']'. |
|
5149 |
out cr |
|
261 | 5150 |
]. |
5151 |
out nextPutLine:'----------------------------------------------------' |
|
255 | 5152 |
|
5153 |
"Created: / 4.1.1998 / 14:27:40 / cg" |
|
261 | 5154 |
"Modified: / 15.1.1998 / 00:14:40 / cg" |
255 | 5155 |
! ! |
5156 |
||
277 | 5157 |
!JavaVM class methodsFor:'native - java.lang - jdk1.2'! |
5158 |
||
5159 |
_AccessController_beginPrivileged:nativeContext |
|
5160 |
"/ introduced with jdk1.2 |
|
5161 |
||
5162 |
"Created: / 27.1.1998 / 18:18:11 / cg" |
|
5163 |
! |
|
5164 |
||
5165 |
_AccessController_endPrivileged:nativeContext |
|
5166 |
"/ introduced with jdk1.2 |
|
5167 |
||
5168 |
"Created: / 27.1.1998 / 18:18:32 / cg" |
|
5169 |
! |
|
5170 |
||
5171 |
_AccessController_getStackAccessControlContext:nativeContext |
|
5172 |
"/ introduced with jdk1.2 |
|
5173 |
||
5174 |
"/ supposed to do more here ... |
|
5175 |
||
5176 |
^ nil |
|
5177 |
||
5178 |
"Created: / 27.1.1998 / 18:22:15 / cg" |
|
5179 |
! |
|
5180 |
||
5181 |
_ClassLoader$NativeLibrary_load:nativeContext |
|
5182 |
"/ introduced with jdk1.2 ... (sigh) |
|
5183 |
||
5184 |
|nativeLoader jLibName libName libHandle index| |
|
5185 |
||
5186 |
nativeLoader := nativeContext receiver. |
|
5187 |
jLibName := nativeContext argAt:1. |
|
5188 |
libName := Java as_ST_String:jLibName. |
|
5189 |
||
5190 |
(index := SimulatedNativeLibs indexOf:libName) ~~ 0 ifTrue:[ |
|
5191 |
('JAVA: builtIn nativeLibLoad simulated: ' , libName) printNL. |
|
5192 |
nativeLoader instVarNamed:'handle' put:index. |
|
5193 |
^ self "/ void |
|
5194 |
]. |
|
5195 |
(LoadedNativeLibs notNil |
|
5196 |
and:[LoadedNativeLibs includesKey:libName]) ifTrue:[ |
|
5197 |
('JAVA: native library already loaded: ' , libName) printNL. |
|
5198 |
nativeLoader instVarNamed:'handle' put:(LoadedNativeLibs at:libName). |
|
5199 |
^ self "/ void |
|
5200 |
]. |
|
5201 |
||
5202 |
libName asFilename exists ifFalse:[ |
|
5203 |
('JAVA: no file to load nativeLib: ' , libName) printNL. |
|
5204 |
^ self "/ void |
|
5205 |
]. |
|
5206 |
||
5207 |
libHandle := ObjectFileLoader loadLibrary:libName. |
|
5208 |
libHandle isNil ifTrue:[ |
|
5209 |
('JAVA: failed to load nativeLib: ' , libName) printNL. |
|
5210 |
^ self "/ void |
|
5211 |
]. |
|
5212 |
||
5213 |
LoadedNativeLibs isNil ifTrue:[ |
|
5214 |
LoadedNativeLibs := Dictionary new. |
|
5215 |
]. |
|
5216 |
||
5217 |
LoadedNativeLibs at:libName put:libHandle. |
|
5218 |
nativeLoader instVarNamed:'handle' put:(LoadedNativeLibs at:libName). |
|
5219 |
^ self "/ void |
|
5220 |
||
5221 |
"Created: / 27.1.1998 / 18:38:37 / cg" |
|
5222 |
"Modified: / 27.1.1998 / 18:55:06 / cg" |
|
5223 |
! |
|
5224 |
||
5225 |
_ClassLoader_initIDs:nativeContext |
|
5226 |
"/ introduced with jdk1.2 ... (sigh) |
|
5227 |
||
5228 |
"Created: / 27.1.1998 / 18:37:08 / cg" |
|
5229 |
! |
|
5230 |
||
5231 |
_Component_initIDs:nativeContext |
|
5232 |
"/ introduced with jdk1.2 ... (sigh) |
|
5233 |
||
5234 |
"Created: / 27.1.1998 / 19:53:29 / cg" |
|
5235 |
! |
|
5236 |
||
5237 |
_System_getCallerClass:nativeContext |
|
5238 |
"/ introduced with jdk1.2 |
|
5239 |
||
5240 |
|senderContext cls| |
|
5241 |
||
5242 |
senderContext := nativeContext sender. |
|
5243 |
[senderContext receiver == (Java at:'java.lang.System')] whileTrue:[ |
|
5244 |
senderContext := senderContext sender. |
|
5245 |
]. |
|
5246 |
||
5247 |
senderContext method isStatic ifTrue:[ |
|
5248 |
cls := senderContext receiver |
|
5249 |
] ifFalse:[ |
|
5250 |
cls := senderContext receiver class |
|
5251 |
]. |
|
5252 |
cls isJavaClass ifTrue:[ |
|
5253 |
^ self javaClassObjectForClass:cls |
|
5254 |
]. |
|
5255 |
(cls isMemberOf:(Java at:'java.lang.Class')) ifTrue:[ |
|
5256 |
^ Java at:'java.lang.Class' |
|
5257 |
]. |
|
5258 |
self halt. |
|
5259 |
^ nil |
|
5260 |
||
5261 |
"Modified: / 27.1.1998 / 18:33:13 / cg" |
|
5262 |
! |
|
5263 |
||
5264 |
_Toolkit_initIDs:nativeContext |
|
5265 |
"/ introduced with jdk1.2 ... (sigh) |
|
5266 |
||
5267 |
"Created: / 27.1.1998 / 19:53:50 / cg" |
|
5268 |
! ! |
|
5269 |
||
255 | 5270 |
!JavaVM class methodsFor:'native - java.math'! |
5271 |
||
5272 |
_BigInteger_plumbInit:nativeContext |
|
5273 |
"/ self unimplementedNativeMethod. |
|
5274 |
||
5275 |
"Created: / 12.1.1998 / 12:55:53 / cg" |
|
253 | 5276 |
! ! |
5277 |
||
5278 |
!JavaVM class methodsFor:'native - java.net'! |
|
5279 |
||
5280 |
_InetAddressImpl_getInetFamily:nativeContext |
|
5281 |
"/ self unimplementedNativeMethod. |
|
5282 |
^ 0 |
|
5283 |
||
5284 |
"Modified: / 15.8.1997 / 17:04:43 / cg" |
|
5285 |
"Created: / 5.1.1998 / 02:05:48 / cg" |
|
5286 |
! |
|
5287 |
||
5288 |
_InetAddressImpl_getLocalHostName:nativeContext |
|
5289 |
"" |
|
5290 |
||
5291 |
|hostName| |
|
5292 |
||
5293 |
hostName := OperatingSystem getHostName. |
|
5294 |
||
5295 |
^ (Java as_String:hostName). |
|
5296 |
||
5297 |
"Modified: / 7.8.1997 / 21:16:55 / cg" |
|
5298 |
"Created: / 5.1.1998 / 02:07:03 / cg" |
|
5299 |
! |
|
5300 |
||
255 | 5301 |
_InetAddressImpl_lookupAllHostAddr:nativeContext |
5302 |
"" |
|
5303 |
||
5304 |
|jAddrImpl jHostName hostName addrBytes| |
|
5305 |
||
5306 |
jAddrImpl := nativeContext receiver. |
|
5307 |
jHostName := nativeContext argAt:1. |
|
5308 |
||
5309 |
hostName := Java as_ST_String:jHostName. |
|
5310 |
addrBytes := Socket ipAddressOfHost:hostName. |
|
5311 |
addrBytes isNil ifTrue:[ |
|
261 | 5312 |
addrBytes := #[0 0 0 0] copy |
255 | 5313 |
]. |
5314 |
^ Array with:addrBytes |
|
5315 |
||
5316 |
"Modified: / 8.8.1997 / 12:04:25 / cg" |
|
5317 |
"Created: / 7.1.1998 / 18:51:31 / cg" |
|
5318 |
! |
|
5319 |
||
253 | 5320 |
_InetAddressImpl_makeAnyLocalAddress:nativeContext |
5321 |
"" |
|
5322 |
||
5323 |
|jAddrImpl jAddr hostName addrBytes address| |
|
5324 |
||
5325 |
jAddrImpl := nativeContext receiver. |
|
5326 |
jAddr := nativeContext argAt:1. |
|
5327 |
||
5328 |
hostName := OperatingSystem getHostName. |
|
5329 |
addrBytes := Socket ipAddressOfHost:hostName. |
|
5330 |
"/ MSB first into an integer. |
|
5331 |
address := (addrBytes at:1). |
|
5332 |
address := (address bitShift:8) bitOr:(addrBytes at:2). |
|
5333 |
address := (address bitShift:8) bitOr:(addrBytes at:3). |
|
5334 |
address := (address bitShift:8) bitOr:(addrBytes at:4). |
|
5335 |
||
5336 |
jAddr instVarNamed:'hostName' put:(Java as_String:hostName). |
|
5337 |
jAddr instVarNamed:'address' put:address. |
|
5338 |
jAddr instVarNamed:'family' put:0. |
|
5339 |
||
5340 |
^ nil |
|
5341 |
||
5342 |
"Modified: / 7.8.1997 / 21:16:57 / cg" |
|
5343 |
"Created: / 5.1.1998 / 02:06:27 / cg" |
|
255 | 5344 |
! |
5345 |
||
5346 |
_PlainSocketImpl_initProto:nativeContext |
|
5347 |
||
5348 |
"Created: / 12.1.1998 / 12:56:52 / cg" |
|
271 | 5349 |
! |
5350 |
||
5351 |
_PlainSocketImpl_socketClose:nativeContext |
|
5352 |
|jsock sock| |
|
5353 |
||
5354 |
jsock := nativeContext receiver. |
|
5355 |
||
5356 |
sock := self validateFile:jsock. |
|
5357 |
sock notNil ifTrue:[ |
|
5358 |
FileIOTrace ifTrue:[ |
|
5359 |
'JAVA: close socket' infoPrintCR |
|
5360 |
]. |
|
5361 |
sock close. |
|
5362 |
]. |
|
5363 |
||
5364 |
"Modified: / 21.8.1997 / 17:09:40 / cg" |
|
5365 |
"Created: / 25.1.1998 / 20:04:24 / cg" |
|
5366 |
! |
|
5367 |
||
5368 |
_PlainSocketImpl_socketConnect:nativeContext |
|
272 | 5369 |
|jsock jaddr port sock addr hostName ok| |
271 | 5370 |
|
5371 |
jsock := nativeContext receiver. |
|
5372 |
jaddr := nativeContext argAt:1. |
|
5373 |
port := nativeContext argAt:2. |
|
5374 |
||
5375 |
hostName := jaddr instVarNamed:'hostName'. |
|
5376 |
hostName notNil ifTrue:[ |
|
5377 |
hostName := Java as_ST_String:hostName |
|
5378 |
] ifFalse:[ |
|
272 | 5379 |
addr := jaddr instVarNamed:'address'. |
5380 |
addr notNil ifTrue:[ |
|
5381 |
hostName := ByteArray new:4. |
|
5382 |
hostName at:4 put:(addr bitAnd:16rFF). |
|
5383 |
addr := addr bitShift:-8. |
|
5384 |
hostName at:3 put:(addr bitAnd:16rFF). |
|
5385 |
addr := addr bitShift:-8. |
|
5386 |
hostName at:2 put:(addr bitAnd:16rFF). |
|
5387 |
addr := addr bitShift:-8. |
|
5388 |
hostName at:1 put:(addr bitAnd:16rFF). |
|
5389 |
]. |
|
271 | 5390 |
]. |
5391 |
hostName isNil ifTrue:[ |
|
5392 |
self halt. |
|
5393 |
]. |
|
5394 |
||
5395 |
sock := self validateFile:jsock. |
|
5396 |
sock notNil ifTrue:[ |
|
5397 |
FileIOTrace ifTrue:[ |
|
5398 |
('JAVA: socket connect to ' , hostName printString , ' port ' , port printString) infoPrintCR |
|
5399 |
]. |
|
5400 |
(self confirm:'connect to host: ' , hostName printString , ' - ok ?') |
|
5401 |
ifFalse:[ |
|
5402 |
self |
|
5403 |
throwExceptionClassName:'java.io.IOException' |
|
5404 |
withMessage:'connect permission denied'. |
|
5405 |
]. |
|
5406 |
||
5407 |
ok := sock connectTo:hostName port:port. |
|
5408 |
ok ifFalse:[ |
|
5409 |
self |
|
5410 |
throwExceptionClassName:'java.io.IOException' |
|
5411 |
withMessage:'connect failed'. |
|
5412 |
] |
|
5413 |
]. |
|
5414 |
||
5415 |
"Created: / 25.1.1998 / 20:02:27 / cg" |
|
272 | 5416 |
"Modified: / 25.1.1998 / 20:57:59 / cg" |
271 | 5417 |
! |
5418 |
||
5419 |
_PlainSocketImpl_socketCreate:nativeContext |
|
5420 |
|jsock isStream fd sock fileNo| |
|
5421 |
||
5422 |
jsock := nativeContext receiver. |
|
5423 |
isStream := (nativeContext argAt:1) == 1. |
|
5424 |
||
5425 |
fd := jsock instVarNamed:'fd'. |
|
5426 |
(fd instVarNamed:'fd') ~~ 0 ifTrue:[ |
|
5427 |
self halt:'file already open'. |
|
5428 |
self internalError:'file already open'. |
|
5429 |
self |
|
5430 |
throwExceptionClassName:'java.io.IOException' |
|
5431 |
withMessage:'file already open in socketCreate'. |
|
5432 |
^ self. |
|
5433 |
]. |
|
5434 |
||
5435 |
FileOpenTrace ifTrue:[ |
|
5436 |
('JAVA: create socket') infoPrintCR. |
|
5437 |
]. |
|
5438 |
||
5439 |
isStream ifTrue:[ |
|
5440 |
sock := Socket newTCP |
|
5441 |
] ifFalse:[ |
|
5442 |
sock := Socket newUDP |
|
5443 |
]. |
|
5444 |
sock isNil ifTrue:[ |
|
5445 |
self |
|
5446 |
throwExceptionClassName:'java.io.IOException' |
|
5447 |
withMessage:'socketCreate failed'. |
|
5448 |
]. |
|
5449 |
||
5450 |
fileNo := self addOpenFile:sock. |
|
5451 |
fd instVarNamed:'fd' put:fileNo. |
|
5452 |
||
5453 |
"Created: / 25.1.1998 / 19:59:25 / cg" |
|
5454 |
"Modified: / 25.1.1998 / 19:59:45 / cg" |
|
272 | 5455 |
! |
5456 |
||
5457 |
_SocketInputStream_socketRead:nativeContext |
|
5458 |
^ self _FileInputStream_readBytes:nativeContext |
|
5459 |
||
5460 |
"Created: / 25.1.1998 / 20:56:53 / cg" |
|
5461 |
! |
|
5462 |
||
5463 |
_SocketOutputStream_socketWrite:nativeContext |
|
5464 |
^ self _FileOutputStream_writeBytes:nativeContext |
|
5465 |
||
5466 |
"Created: / 25.1.1998 / 21:06:55 / cg" |
|
253 | 5467 |
! ! |
5468 |
||
5469 |
!JavaVM class methodsFor:'native - java.utils'! |
|
5470 |
||
5471 |
_ResourceBundle_getClassContext:nativeContext |
|
5472 |
"returns an array filled with the contextChain receivers classes. |
|
5473 |
What an ugly, messy interface." |
|
5474 |
||
5475 |
|chain con cls jClass| |
|
5476 |
||
5477 |
chain := OrderedCollection new. |
|
5478 |
con := thisContext sender. |
|
5479 |
[con notNil] whileTrue:[ |
|
261 | 5480 |
(con isMemberOf:JavaContext) ifTrue:[ |
5481 |
cls := con receiver class. |
|
5482 |
cls isMeta ifTrue:[ |
|
5483 |
"/ t'was a static method |
|
5484 |
cls := cls soleInstance |
|
5485 |
]. |
|
5486 |
jClass := JavaClasses at:cls ifAbsent:nil. |
|
5487 |
jClass isNil ifTrue:[ |
|
5488 |
JavaClasses at:cls put:(jClass := (Java at:'java.lang.Class') new). |
|
5489 |
JavaClasses at:jClass put:cls. |
|
5490 |
]. |
|
5491 |
chain add:jClass. |
|
5492 |
]. |
|
5493 |
con := con sender. |
|
253 | 5494 |
]. |
5495 |
^ chain asArray |
|
5496 |
||
5497 |
"Created: / 5.1.1998 / 02:47:00 / cg" |
|
5498 |
"Modified: / 5.1.1998 / 02:49:47 / cg" |
|
5499 |
! ! |
|
5500 |
||
255 | 5501 |
!JavaVM class methodsFor:'native - netscape'! |
5502 |
||
5503 |
_MozillaAppletContext_pMochaOnLoad:nativeContext |
|
5504 |
|id| |
|
5505 |
||
5506 |
id := nativeContext argAt:1. |
|
5507 |
'JAVA: MozillaAppletContext_pMochaOnLoad: ' print. id printNL. |
|
5508 |
^ nil |
|
5509 |
||
5510 |
"Modified: / 21.8.1997 / 16:40:45 / cg" |
|
5511 |
"Created: / 6.1.1998 / 20:37:13 / cg" |
|
5512 |
! |
|
5513 |
||
5514 |
_MozillaAppletContext_pShowStatus:nativeContext |
|
5515 |
|s js| |
|
5516 |
||
5517 |
js := nativeContext argAt:1. |
|
5518 |
s := Java as_ST_String:js. |
|
5519 |
||
5520 |
self activityNotification:s. |
|
5521 |
"/ Transcript showCR:s. |
|
5522 |
^ nil |
|
5523 |
||
5524 |
"Created: / 6.1.1998 / 18:31:34 / cg" |
|
5525 |
"Modified: / 8.1.1998 / 17:06:13 / cg" |
|
5526 |
! |
|
5527 |
||
5528 |
_URLStreamHandlerFactory_pInit:nativeContext |
|
5529 |
"/ self unimplementedNativeMethod. |
|
5530 |
||
5531 |
"Created: / 10.1.1998 / 15:47:24 / cg" |
|
5532 |
! ! |
|
5533 |
||
5534 |
!JavaVM class methodsFor:'native - sun.audio'! |
|
5535 |
||
5536 |
_AudioDevice_audioClose:nativeContext |
|
261 | 5537 |
|device fd stream| |
5538 |
||
5539 |
device := nativeContext receiver. |
|
5540 |
device notNil ifTrue:[ |
|
5541 |
fd := device instVarNamed:'dev'. |
|
5542 |
(fd notNil and:[fd > 0]) ifTrue:[ |
|
5543 |
stream := self getOpenFileAt:fd. |
|
5544 |
stream notNil ifTrue:[ |
|
5545 |
stream close. |
|
5546 |
device instVarNamed:'dev' put:0. |
|
5547 |
] |
|
5548 |
] |
|
5549 |
] |
|
255 | 5550 |
|
5551 |
"Created: / 10.1.1998 / 15:45:16 / cg" |
|
261 | 5552 |
"Modified: / 13.1.1998 / 18:08:20 / cg" |
255 | 5553 |
! |
5554 |
||
5555 |
_AudioDevice_audioOpen:nativeContext |
|
261 | 5556 |
|f stream fileNo| |
5557 |
||
5558 |
NoAudio ifTrue:[ |
|
5559 |
^ -1 |
|
5560 |
]. |
|
5561 |
||
5562 |
f := '/dev/audio' asFilename. |
|
5563 |
"/ stream := f readWriteStream. |
|
5564 |
Stream streamErrorSignal handle:[:ex | |
|
5565 |
Stream streamErrorSignal handle:[:ex | |
|
5566 |
stream := nil. |
|
5567 |
ex return. |
|
5568 |
] do:[ |
|
5569 |
stream := SoundStream writing. |
|
5570 |
]. |
|
5571 |
] do:[ |
|
5572 |
stream := SoundStream writing. |
|
5573 |
]. |
|
5574 |
stream isNil ifTrue:[ |
|
5575 |
f exists ifTrue:[ |
|
5576 |
^ 0 |
|
5577 |
]. |
|
5578 |
^ -1 |
|
5579 |
]. |
|
5580 |
||
5581 |
stream setSampleRate:8000. |
|
5582 |
fileNo := self addOpenFile:stream. |
|
5583 |
||
5584 |
FileOpenTrace ifTrue:[ |
|
5585 |
('JAVA: opened audioDevice as FD ' , fileNo printString) infoPrintCR. |
|
5586 |
]. |
|
5587 |
||
5588 |
^ fileNo |
|
255 | 5589 |
|
5590 |
"Created: / 10.1.1998 / 15:45:30 / cg" |
|
261 | 5591 |
"Modified: / 14.1.1998 / 14:57:16 / cg" |
5592 |
! |
|
5593 |
||
5594 |
_AudioDevice_audioWrite:nativeContext |
|
5595 |
|device fd stream bytes count| |
|
5596 |
||
5597 |
device := nativeContext receiver. |
|
5598 |
device notNil ifTrue:[ |
|
5599 |
fd := device instVarNamed:'dev'. |
|
5600 |
(fd notNil and:[fd > 0]) ifTrue:[ |
|
5601 |
stream := self getOpenFileAt:fd. |
|
5602 |
stream notNil ifTrue:[ |
|
5603 |
bytes := nativeContext argAt:1. |
|
5604 |
count := nativeContext argAt:2. |
|
5605 |
stream nextPutBytes:count from:bytes startingAt:1 |
|
5606 |
] |
|
5607 |
] |
|
5608 |
] |
|
5609 |
||
5610 |
"Created: / 10.1.1998 / 15:45:16 / cg" |
|
5611 |
"Modified: / 13.1.1998 / 18:07:20 / cg" |
|
255 | 5612 |
! ! |
5613 |
||
5614 |
!JavaVM class methodsFor:'native - sun.awt'! |
|
5615 |
||
5616 |
_GifImageDecoder_parseImage:nativeContext |
|
261 | 5617 |
|decoder width height bool1 depth subHdrBytes dstBytes i1 i2 colorModel |
5618 |
stream byte compressedData compressedSize index count data |
|
5619 |
leftOffs topOffs codeLen flags pixelStore clrModel t buffSize| |
|
255 | 5620 |
|
5621 |
decoder := nativeContext receiver. |
|
5622 |
||
5623 |
i1 := nativeContext argAt:1. |
|
5624 |
i2 := nativeContext argAt:2. |
|
5625 |
width := nativeContext argAt:3. |
|
5626 |
height := nativeContext argAt:4. |
|
5627 |
bool1 := nativeContext argAt:5. |
|
5628 |
depth := nativeContext argAt:6. |
|
261 | 5629 |
subHdrBytes := nativeContext argAt:7. |
255 | 5630 |
dstBytes := nativeContext argAt:8. |
5631 |
colorModel := nativeContext argAt:9. |
|
5632 |
||
261 | 5633 |
leftOffs := subHdrBytes wordAt:1 MSB:false. |
5634 |
topOffs := subHdrBytes wordAt:3 MSB:false. |
|
5635 |
width := subHdrBytes wordAt:5 MSB:false. |
|
5636 |
height := subHdrBytes wordAt:7 MSB:false. |
|
5637 |
flags := subHdrBytes at:9. |
|
5638 |
codeLen := subHdrBytes at:10. |
|
5639 |
||
5640 |
stream := decoder instVarNamed:'input'. |
|
5641 |
pixelStore := decoder instVarNamed:'store'. |
|
5642 |
||
5643 |
buffSize := (width * height // 2) max:4096. |
|
5644 |
compressedData := ByteArray uninitializedNew:buffSize. |
|
5645 |
||
5646 |
"get compressed data" |
|
5647 |
index := 1. |
|
5648 |
count := stream perform:#read. |
|
5649 |
||
5650 |
[count notNil and:[count > 0]] whileTrue:[ |
|
270 | 5651 |
(index + count) > buffSize ifTrue:[ |
5652 |
t := ByteArray uninitializedNew:(buffSize * 2). |
|
5653 |
t replaceFrom:1 to:buffSize with:compressedData startingAt:1. |
|
5654 |
compressedData := t. |
|
5655 |
buffSize := buffSize * 2. |
|
5656 |
]. |
|
5657 |
count := stream |
|
5658 |
perform:#'read([BII)I' |
|
5659 |
with:compressedData |
|
5660 |
with:index-1 |
|
5661 |
with:count. |
|
5662 |
count > 0 ifTrue:[ |
|
5663 |
index := index + count. |
|
5664 |
count := stream perform:#read. |
|
5665 |
] |
|
261 | 5666 |
]. |
5667 |
compressedSize := index - 1. |
|
5668 |
||
5669 |
data := pixelStore perform:#'allocateLines(I)Ljava/lang/Object;' with:height. |
|
5670 |
(data isMemberOf:ByteArray) ifFalse:[ |
|
270 | 5671 |
self halt. |
5672 |
^ 0. |
|
261 | 5673 |
]. |
5674 |
"/ 'GIFReader: decompressing ...' infoPrintCR. |
|
5675 |
||
5676 |
||
5677 |
GIFReader |
|
270 | 5678 |
decompressGIFFrom:compressedData |
5679 |
count:compressedSize |
|
5680 |
into:data |
|
5681 |
startingAt:1 |
|
5682 |
codeLen:(codeLen + 1). |
|
261 | 5683 |
|
5684 |
clrModel := pixelStore instVarNamed:'colormodel'. |
|
5685 |
||
5686 |
pixelStore |
|
270 | 5687 |
perform:#'setPixels(IIII[BII)Z' |
5688 |
withArguments: |
|
5689 |
(Array |
|
5690 |
with:0 "/ x |
|
5691 |
with:0 "/ y |
|
5692 |
with:width "/ w |
|
5693 |
with:height "/ h |
|
5694 |
with:data |
|
5695 |
with:0 "/ offs |
|
5696 |
with:width). "/ scanSize |
|
261 | 5697 |
|
5698 |
pixelStore perform:#'imageComplete()V'. |
|
5699 |
"/ perform:#'imageComplete(I)V' |
|
5700 |
"/ with:((Java at:'java.awt.image.ImageConsumer') instVarNamed:'STATICIMAGEDONE'). |
|
5701 |
||
255 | 5702 |
"/ self internalError:'breakPoint'. |
5703 |
^ 1 "/ true |
|
5704 |
||
261 | 5705 |
"Modified: / 14.1.1998 / 15:10:59 / cg" |
255 | 5706 |
! |
5707 |
||
5708 |
_ImageRepresentation_disposeImage:nativeContext |
|
262 | 5709 |
|imgRep img| |
255 | 5710 |
|
5711 |
imgRep := nativeContext receiver. |
|
262 | 5712 |
|
5713 |
img := imgRep instVarNamed:'pData'. |
|
5714 |
(img notNil and:[img ~~ 0]) ifTrue:[ |
|
270 | 5715 |
ImageStretchCache notNil ifTrue:[ |
5716 |
ImageStretchCache removeKey:img ifAbsent:nil. |
|
5717 |
] |
|
262 | 5718 |
]. |
5719 |
||
261 | 5720 |
imgRep instVarNamed:'pData' put:0. |
5721 |
"/ self halt. |
|
255 | 5722 |
|
5723 |
"Created: / 7.1.1998 / 22:31:46 / cg" |
|
262 | 5724 |
"Modified: / 17.1.1998 / 13:26:55 / cg" |
255 | 5725 |
! |
5726 |
||
5727 |
_ImageRepresentation_finish:nativeContext |
|
5728 |
|imgRep bool| |
|
5729 |
||
5730 |
imgRep := nativeContext receiver. |
|
5731 |
bool := nativeContext argAt:1. |
|
261 | 5732 |
"/ self halt. |
255 | 5733 |
'JAVA: ImageRepresentation_finish ignored for now' infoPrintCR. |
5734 |
||
5735 |
^ 1 "/ true |
|
5736 |
||
5737 |
"Created: / 8.1.1998 / 00:11:40 / cg" |
|
261 | 5738 |
"Modified: / 13.1.1998 / 13:41:35 / cg" |
5739 |
! |
|
5740 |
||
5741 |
_ImageRepresentation_imageDraw:nativeContext |
|
5742 |
|imgRep x y img deviceImage jGraphics gc clr| |
|
5743 |
||
5744 |
imgRep := nativeContext receiver. |
|
5745 |
img := imgRep instVarNamed:'pData'. |
|
5746 |
(img isNil or:[img == 0]) ifTrue:[ |
|
270 | 5747 |
"/ self halt. |
5748 |
^ self. |
|
261 | 5749 |
]. |
5750 |
jGraphics := nativeContext argAt:1. |
|
5751 |
gc := jGraphics instVarNamed:'pData'. |
|
5752 |
gc realized ifFalse:[^ self]. |
|
5753 |
||
5754 |
x := nativeContext argAt:2. |
|
5755 |
y := nativeContext argAt:3. |
|
5756 |
clr := nativeContext argAt:4. |
|
5757 |
deviceImage := img onDevice:gc device. |
|
5758 |
deviceImage ~~ img ifTrue:[ |
|
270 | 5759 |
imgRep instVarNamed:'pData' put:deviceImage. |
261 | 5760 |
]. |
5761 |
deviceImage displayOn:gc x:x y:y. |
|
5762 |
^ 1. |
|
5763 |
||
5764 |
"Created: / 13.1.1998 / 13:32:28 / cg" |
|
5765 |
"Modified: / 15.1.1998 / 12:21:27 / cg" |
|
5766 |
! |
|
5767 |
||
5768 |
_ImageRepresentation_imageStretch:nativeContext |
|
5769 |
|imgRep x1 y1 x2 y2 srcX1 srcY1 w h |
|
5770 |
img deviceImage jGraphics gc clr stretchWidth stretchHeight| |
|
5771 |
||
5772 |
imgRep := nativeContext receiver. |
|
5773 |
img := imgRep instVarNamed:'pData'. |
|
5774 |
(img isNil or:[img == 0]) ifTrue:[ |
|
270 | 5775 |
"/ self halt. |
5776 |
^ self. |
|
261 | 5777 |
]. |
5778 |
||
5779 |
jGraphics := nativeContext argAt:1. |
|
5780 |
gc := jGraphics instVarNamed:'pData'. |
|
5781 |
gc realized ifFalse:[^ self]. |
|
5782 |
||
5783 |
x1 := nativeContext argAt:2. |
|
5784 |
y1 := nativeContext argAt:3. |
|
5785 |
x2 := nativeContext argAt:4. |
|
5786 |
y2:= nativeContext argAt:5. |
|
5787 |
srcX1 := nativeContext argAt:6. |
|
5788 |
srcY1 := nativeContext argAt:7. |
|
5789 |
w := nativeContext argAt:8. |
|
5790 |
h := nativeContext argAt:9. |
|
5791 |
clr := nativeContext argAt:10. |
|
5792 |
||
5793 |
(srcX1 ~~ 0 or:[srcY1 ~~ 0]) ifTrue:[ |
|
270 | 5794 |
self halt. |
5795 |
^ self. |
|
261 | 5796 |
]. |
5797 |
(w ~~ img width or:[h ~~ img height]) ifTrue:[ |
|
270 | 5798 |
self halt. |
5799 |
^ self |
|
261 | 5800 |
]. |
5801 |
||
5802 |
"/ TODO: remember magnified images somewhere for a while, |
|
5803 |
"/ to avoid repeated action ... |
|
5804 |
||
5805 |
stretchWidth := (x2-x1). |
|
5806 |
stretchHeight := (y2-y1). |
|
5807 |
||
5808 |
(stretchWidth == img width |
|
5809 |
and:[stretchHeight == img height]) ifTrue:[ |
|
270 | 5810 |
deviceImage := img onDevice:gc device. |
5811 |
deviceImage ~~ img ifTrue:[ |
|
5812 |
imgRep instVarNamed:'pData' put:deviceImage. |
|
5813 |
]. |
|
261 | 5814 |
] ifFalse:[ |
270 | 5815 |
ImageStretchCache notNil ifTrue:[ |
5816 |
deviceImage := ImageStretchCache at:img ifAbsent:nil. |
|
5817 |
]. |
|
5818 |
(deviceImage isNil |
|
5819 |
or:[deviceImage width ~~ stretchWidth |
|
5820 |
or:[deviceImage height ~~ stretchHeight]]) ifTrue:[ |
|
5821 |
deviceImage := (img magnifiedTo:stretchWidth@stretchHeight) onDevice:gc device. |
|
5822 |
ImageStretchCache isNil ifTrue:[ |
|
5823 |
ImageStretchCache := WeakIdentityDictionary new. |
|
5824 |
]. |
|
5825 |
ImageStretchCache at:img put:deviceImage |
|
5826 |
]. |
|
261 | 5827 |
]. |
5828 |
deviceImage displayOn:gc x:x1 y:y1 |
|
5829 |
||
5830 |
"Created: / 13.1.1998 / 13:32:28 / cg" |
|
5831 |
"Modified: / 15.1.1998 / 13:14:47 / cg" |
|
255 | 5832 |
! |
5833 |
||
5834 |
_ImageRepresentation_offscreenInit:nativeContext |
|
262 | 5835 |
|imgRep jclr w h form screenDevice| |
255 | 5836 |
|
5837 |
imgRep := nativeContext receiver. |
|
261 | 5838 |
jclr := nativeContext argAt:1. |
262 | 5839 |
|
5840 |
w := imgRep instVarNamed:'width'. |
|
5841 |
h := imgRep instVarNamed:'height'. |
|
5842 |
||
5843 |
screenDevice := Screen current. |
|
5844 |
form := Form width:w height:h depth:(screenDevice depth) on:screenDevice. |
|
5845 |
||
5846 |
imgRep instVarNamed:'pData' put:form. |
|
5847 |
"/ self halt. |
|
255 | 5848 |
|
5849 |
"Created: / 7.1.1998 / 22:31:46 / cg" |
|
262 | 5850 |
"Modified: / 17.1.1998 / 12:36:43 / cg" |
261 | 5851 |
! |
5852 |
||
5853 |
_ImageRepresentation_setBytePixels:nativeContext |
|
5854 |
|imgRep x y w h clrModel bytes i1 i2 |
|
5855 |
img depth cmap rgbMap opaque transparentColorIndex| |
|
5856 |
||
5857 |
imgRep := nativeContext receiver. |
|
5858 |
x := nativeContext argAt:1. |
|
5859 |
y := nativeContext argAt:2. |
|
5860 |
w := nativeContext argAt:3. |
|
5861 |
h := nativeContext argAt:4. |
|
5862 |
clrModel := nativeContext argAt:5. |
|
5863 |
bytes := nativeContext argAt:6. |
|
5864 |
i1 := nativeContext argAt:7. "/ offset ?? |
|
5865 |
i2 := nativeContext argAt:8. "/ scanLineWidth ?? |
|
5866 |
||
5867 |
"/ self halt. |
|
5868 |
||
5869 |
depth := clrModel instVarNamed:'pixel_bits'. |
|
5870 |
(clrModel instVarNamed:'map_size') ~~ 0 ifTrue:[ |
|
5871 |
rgbMap := clrModel instVarNamed:'rgb'. |
|
5872 |
cmap := Array new:rgbMap size. |
|
5873 |
rgbMap |
|
5874 |
keysAndValuesDo:[:idx :rgb | |
|
5875 |
cmap at:idx put:(Color rgbValue:(rgb bitAnd:16rFFFFFF)) |
|
5876 |
]. |
|
5877 |
]. |
|
5878 |
||
5879 |
opaque := (clrModel instVarNamed:'opaque') ~~ 0. |
|
5880 |
opaque ifFalse:[ |
|
5881 |
transparentColorIndex := clrModel instVarNamed:'transparent_index' |
|
5882 |
]. |
|
5883 |
||
5884 |
img := imgRep instVarNamed:'pData'. |
|
5885 |
(img isNil or:[img == 0]) ifTrue:[ |
|
5886 |
img := Image width:w height:h depth:depth fromArray:bytes. |
|
5887 |
cmap notNil ifTrue:[ |
|
5888 |
img colorMap:cmap. |
|
5889 |
img photometric:#palette |
|
5890 |
]. |
|
5891 |
opaque ifFalse:[ |
|
5892 |
img mask:(ImageReader |
|
5893 |
buildMaskFromColor:transparentColorIndex |
|
5894 |
for:bytes |
|
5895 |
width:w |
|
5896 |
height:h) |
|
5897 |
]. |
|
5898 |
||
5899 |
imgRep instVarNamed:'pData' put:img. |
|
5900 |
||
5901 |
] ifFalse:[ |
|
5902 |
self halt. |
|
5903 |
]. |
|
5904 |
^ 1. |
|
5905 |
||
5906 |
"Created: / 7.1.1998 / 22:31:46 / cg" |
|
5907 |
"Modified: / 14.1.1998 / 14:51:44 / cg" |
|
262 | 5908 |
! |
5909 |
||
5910 |
_OffScreenImageSource_sendPixels:nativeContext |
|
5911 |
"/ self halt. |
|
5912 |
||
5913 |
"Modified: / 16.1.1998 / 18:22:23 / cg" |
|
5914 |
"Created: / 17.1.1998 / 12:36:25 / cg" |
|
255 | 5915 |
! ! |
5916 |
||
253 | 5917 |
!JavaVM class methodsFor:'semaphores & monitors'! |
5918 |
||
5919 |
monitorFor:someObject |
|
5920 |
|mon| |
|
5921 |
||
5922 |
LockTableAccess critical:[ |
|
261 | 5923 |
mon := LockTable at:someObject ifAbsent:nil. |
5924 |
mon isNil ifTrue:[ |
|
5925 |
LockTable at:someObject put:(mon := Monitor new) |
|
5926 |
] |
|
253 | 5927 |
]. |
5928 |
^ mon |
|
5929 |
||
5930 |
"Created: / 2.1.1998 / 19:01:52 / cg" |
|
5931 |
! |
|
5932 |
||
5933 |
releaseAndSignalForAllSemaphoreFor:someObject |
|
5934 |
|sema| |
|
5935 |
||
5936 |
WaitTableAccess critical:[ |
|
261 | 5937 |
sema := WaitTable at:someObject ifAbsent:nil. |
5938 |
sema notNil ifTrue:[ |
|
5939 |
WaitTable removeKey:someObject |
|
5940 |
] |
|
253 | 5941 |
]. |
5942 |
||
5943 |
sema notNil ifTrue:[ |
|
261 | 5944 |
sema signalForAll |
253 | 5945 |
] |
5946 |
||
5947 |
"Created: / 2.1.1998 / 18:21:51 / cg" |
|
5948 |
! |
|
5949 |
||
5950 |
releaseAndSignalSemaphoreFor:someObject |
|
5951 |
|sema| |
|
5952 |
||
5953 |
WaitTableAccess critical:[ |
|
261 | 5954 |
sema := WaitTable at:someObject ifAbsent:nil. |
5955 |
sema notNil ifTrue:[ |
|
5956 |
WaitTable removeKey:someObject |
|
5957 |
] |
|
253 | 5958 |
]. |
5959 |
||
5960 |
sema notNil ifTrue:[ |
|
261 | 5961 |
sema signal |
253 | 5962 |
] |
5963 |
||
5964 |
"Created: / 2.1.1998 / 18:20:20 / cg" |
|
5965 |
! |
|
5966 |
||
5967 |
releaseSemaphoreFor:someObject |
|
5968 |
WaitTableAccess critical:[ |
|
261 | 5969 |
WaitTable removeKey:someObject ifAbsent:nil |
253 | 5970 |
] |
5971 |
||
5972 |
"Created: / 2.1.1998 / 18:17:14 / cg" |
|
5973 |
"Modified: / 2.1.1998 / 21:52:03 / cg" |
|
5974 |
! |
|
5975 |
||
5976 |
semaphoreFor:someObject |
|
5977 |
|sema| |
|
5978 |
||
5979 |
WaitTableAccess critical:[ |
|
261 | 5980 |
sema := WaitTable at:someObject ifAbsent:nil. |
5981 |
sema isNil ifTrue:[ |
|
5982 |
WaitTable at:someObject put:(sema := Semaphore new) |
|
5983 |
] |
|
253 | 5984 |
]. |
5985 |
^ sema |
|
5986 |
||
5987 |
"Created: / 2.1.1998 / 18:15:59 / cg" |
|
5988 |
"Modified: / 2.1.1998 / 18:20:31 / cg" |
|
5989 |
! ! |
|
5990 |
||
5991 |
!JavaVM class methodsFor:'vm support'! |
|
5992 |
||
5993 |
monitorEnter:someObject |
|
5994 |
| mon thisProcess| |
|
5995 |
||
5996 |
someObject isNil ifTrue:[ |
|
261 | 5997 |
self halt |
253 | 5998 |
]. |
5999 |
||
6000 |
mon := self monitorFor:someObject. |
|
6001 |
||
6002 |
MonitorTrace ifTrue:[ |
|
261 | 6003 |
('====> entering monitor for ' , someObject displayString , ' in ' , Processor activeProcess name , ' ...') printCR. |
253 | 6004 |
]. |
6005 |
mon enter. |
|
6006 |
MonitorTrace ifTrue:[ |
|
261 | 6007 |
('====> entered it in ' , Processor activeProcess name , ' ...') printCR. |
253 | 6008 |
]. |
6009 |
||
6010 |
self enteredMonitors add:someObject. |
|
6011 |
||
6012 |
"Created: / 2.1.1998 / 23:44:49 / cg" |
|
6013 |
"Modified: / 3.1.1998 / 03:05:02 / cg" |
|
6014 |
! |
|
6015 |
||
6016 |
monitorExit:someObject |
|
6017 |
| mon thisProcess| |
|
6018 |
||
6019 |
someObject isNil ifTrue:[ |
|
261 | 6020 |
self halt |
253 | 6021 |
]. |
6022 |
||
6023 |
mon := self monitorFor:someObject. |
|
6024 |
||
6025 |
MonitorTrace ifTrue:[ |
|
261 | 6026 |
('====> leaving monitor for ' , someObject displayString , ' in ' , Processor activeProcess name , ' ...') printCR. |
253 | 6027 |
]. |
6028 |
mon exit. |
|
6029 |
MonitorTrace ifTrue:[ |
|
261 | 6030 |
('====> left it in ' , Processor activeProcess name , ' ...') printCR. |
253 | 6031 |
]. |
6032 |
||
6033 |
"/ enteredMonitorHandles isNil ifTrue:[ |
|
6034 |
"/ self halt:'oops - no monitor entered'. |
|
6035 |
"/ ]. |
|
6036 |
||
6037 |
self enteredMonitors removeLast ~~ someObject ifTrue:[ |
|
261 | 6038 |
self halt:'oops - monitor enter/exit nesting wrong' |
253 | 6039 |
]. |
6040 |
||
6041 |
"Created: / 2.1.1998 / 23:47:28 / cg" |
|
6042 |
"Modified: / 3.1.1998 / 03:05:18 / cg" |
|
6043 |
! ! |
|
6044 |
||
255 | 6045 |
!JavaVM class methodsFor:'windows - events'! |
6046 |
||
6047 |
awtEventsForEvent:anEvent javaWindow:jWin |
|
6048 |
"given an ST/X event, create corresponding AWT event(s) for it" |
|
6049 |
||
6050 |
|jEv jEv1 jEv2 |
|
261 | 6051 |
modifiers key keyChar untranslatedKey id |
6052 |
type x y w h view menu |
|
255 | 6053 |
eventArgs clickCount jRect |
6054 |
jKeyEventClass jInputEventClass jMouseEventClass |
|
6055 |
jWindowEventClass jPaintEventClass jComponentEventClass| |
|
6056 |
||
6057 |
type := anEvent type. |
|
6058 |
eventArgs := anEvent arguments. |
|
6059 |
||
6060 |
key := 0. |
|
6061 |
modifiers := 0. |
|
6062 |
x := 0. |
|
6063 |
y := 0. |
|
6064 |
||
6065 |
jInputEventClass := Java classForName:'java.awt.event.InputEvent'. |
|
6066 |
||
6067 |
(anEvent isKeyEvent |
|
6068 |
or:[anEvent isButtonEvent |
|
6069 |
or:[anEvent isPointerEnterLeaveEvent]]) ifTrue:[ |
|
6070 |
anEvent hasAlt ifTrue:[ |
|
6071 |
modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'ALT_MASK') |
|
6072 |
]. |
|
6073 |
anEvent hasCtrl ifTrue:[ |
|
6074 |
modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'CTRL_MASK') |
|
6075 |
]. |
|
6076 |
anEvent hasMeta ifTrue:[ |
|
6077 |
modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'META_MASK') |
|
6078 |
]. |
|
6079 |
anEvent hasShift ifTrue:[ |
|
6080 |
modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'SHIFT_MASK') |
|
6081 |
]. |
|
6082 |
anEvent hasButton1 ifTrue:[ |
|
6083 |
modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'BUTTON1_MASK') |
|
6084 |
]. |
|
6085 |
anEvent hasButton2 ifTrue:[ |
|
6086 |
modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'BUTTON2_MASK') |
|
6087 |
]. |
|
6088 |
anEvent hasButton3 ifTrue:[ |
|
6089 |
modifiers := modifiers bitOr:(jInputEventClass instVarNamed:'BUTTON3_MASK') |
|
6090 |
]. |
|
6091 |
||
6092 |
anEvent isPointerEnterLeaveEvent ifFalse:[ |
|
6093 |
"/ ST/X does not (yet) record this information |
|
6094 |
"/ with pointerLeave events. |
|
6095 |
||
6096 |
x := anEvent x. |
|
6097 |
y := anEvent y. |
|
6098 |
]. |
|
6099 |
]. |
|
6100 |
||
6101 |
anEvent isKeyEvent ifTrue:[ |
|
6102 |
jKeyEventClass := Java classForName:'java.awt.event.KeyEvent'. |
|
6103 |
||
6104 |
key := 0. |
|
6105 |
keyChar := 0. |
|
6106 |
||
6107 |
key := anEvent key. |
|
6108 |
key isCharacter ifTrue:[ |
|
6109 |
key := keyChar := key asciiValue |
|
6110 |
] ifFalse:[ |
|
6111 |
untranslatedKey := anEvent view device keyboardMap keyAtValue:key ifAbsent:key. |
|
6112 |
untranslatedKey == #Delete ifTrue:[ |
|
6113 |
key := jKeyEventClass instVarNamed:'VK_DELETE' "/ 127 |
|
6114 |
]. |
|
6115 |
untranslatedKey == #BackSpace ifTrue:[ |
|
6116 |
key := jKeyEventClass instVarNamed:'VK_BACK_SPACE' "/ 8 |
|
6117 |
]. |
|
6118 |
untranslatedKey == #Return ifTrue:[ |
|
6119 |
key := jKeyEventClass instVarNamed:'VK_ENTER' "/ 13 |
|
6120 |
]. |
|
6121 |
untranslatedKey == #Tab ifTrue:[ |
|
6122 |
key := jKeyEventClass instVarNamed:'VK_TAB' "/ 9 |
|
6123 |
]. |
|
6124 |
untranslatedKey == #Home ifTrue:[ |
|
6125 |
key := jKeyEventClass instVarNamed:'VK_HOME' |
|
6126 |
]. |
|
6127 |
untranslatedKey == #End ifTrue:[ |
|
6128 |
key := jKeyEventClass instVarNamed:'VK_END' |
|
6129 |
]. |
|
6130 |
untranslatedKey == #Prior ifTrue:[ |
|
6131 |
key := jKeyEventClass instVarNamed:'VK_PAGE_UP' |
|
6132 |
]. |
|
6133 |
key == #EndOfText ifTrue:[ |
|
6134 |
key := jKeyEventClass instVarNamed:'VK_PAGE_DOWN' |
|
6135 |
]. |
|
6136 |
untranslatedKey == #CursorUp ifTrue:[ |
|
6137 |
key := jKeyEventClass instVarNamed:'VK_UP' |
|
6138 |
]. |
|
6139 |
untranslatedKey == #CursorDown ifTrue:[ |
|
6140 |
key := jKeyEventClass instVarNamed:'VK_DOWN' |
|
6141 |
]. |
|
6142 |
untranslatedKey == #CursorLeft ifTrue:[ |
|
6143 |
key := jKeyEventClass instVarNamed:'VK_LEFT' |
|
6144 |
]. |
|
6145 |
untranslatedKey == #CursorRight ifTrue:[ |
|
6146 |
key := jKeyEventClass instVarNamed:'VK_RIGHT' |
|
6147 |
]. |
|
6148 |
(#( F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11) |
|
6149 |
includes:untranslatedKey) ifTrue:[ |
|
6150 |
key := jKeyEventClass instVarNamed:('VK_' , untranslatedKey) |
|
6151 |
]. |
|
6152 |
]. |
|
6153 |
(type == #'keyPress:x:y:') ifTrue:[ |
|
6154 |
id := jKeyEventClass instVarNamed:'KEY_PRESSED' |
|
6155 |
] ifFalse:[ |
|
6156 |
id := jKeyEventClass instVarNamed:'KEY_RELEASED' |
|
6157 |
]. |
|
261 | 6158 |
jEv := jKeyEventClass newCleared "basicNew". |
255 | 6159 |
jEv instVarNamed:'modifiers' put:modifiers. |
6160 |
jEv instVarNamed:'keyCode' put:key. |
|
6161 |
jEv instVarNamed:'keyChar' put:keyChar. |
|
6162 |
jEv instVarNamed:'id' put:id. |
|
6163 |
"/ jEv instVarNamed:'x' put:x. |
|
6164 |
"/ jEv instVarNamed:'y' put:y. |
|
6165 |
jEv instVarNamed:'when' put:(OperatingSystem getMillisecondTime). |
|
6166 |
^ Array with:jEv |
|
6167 |
]. |
|
6168 |
||
6169 |
(anEvent isButtonEvent |
|
6170 |
or:[anEvent isPointerEnterLeaveEvent]) ifTrue:[ |
|
6171 |
jMouseEventClass := Java classForName:'java.awt.event.MouseEvent'. |
|
6172 |
clickCount := 1. |
|
6173 |
||
6174 |
(type == #'buttonPress:x:y:') ifTrue:[ |
|
270 | 6175 |
id := jMouseEventClass instVarNamed:'MOUSE_PRESSED'. |
255 | 6176 |
] ifFalse:[ |
6177 |
(type == #'buttonRelease:x:y:') ifTrue:[ |
|
270 | 6178 |
id := jMouseEventClass instVarNamed:'MOUSE_RELEASED'. |
255 | 6179 |
] ifFalse:[ |
6180 |
(type == #'buttonMotion:x:y:') ifTrue:[ |
|
270 | 6181 |
(anEvent arguments at:1) == 0 ifTrue:[ |
6182 |
id := jMouseEventClass instVarNamed:'MOUSE_MOVED'. |
|
6183 |
] ifFalse:[ |
|
6184 |
id := jMouseEventClass instVarNamed:'MOUSE_DRAGGED'. |
|
6185 |
]. |
|
255 | 6186 |
] ifFalse:[ |
6187 |
"/ (type == #'pointerMotion:x:y:') ifTrue:[ |
|
270 | 6188 |
"/ id := jMouseEventClass instVarNamed:'MOUSE_MOVED'. |
255 | 6189 |
"/ ] ifFalse:[ |
6190 |
(type == #'pointerEnter:x:y:') ifTrue:[ |
|
270 | 6191 |
id := jMouseEventClass instVarNamed:'MOUSE_ENTERED'. |
255 | 6192 |
] ifFalse:[ |
6193 |
(type == #'pointerLeave:') ifTrue:[ |
|
270 | 6194 |
id := jMouseEventClass instVarNamed:'MOUSE_EXITED'. |
255 | 6195 |
] ifFalse:[ |
6196 |
(type == #'buttonMultiPress:x:y:') ifTrue:[ |
|
6197 |
id := jMouseEventClass instVarNamed:'MOUSE_PRESSED'. |
|
6198 |
clickCount := 2. |
|
6199 |
] ifFalse:[ |
|
6200 |
self halt. |
|
6201 |
] |
|
6202 |
] |
|
6203 |
"/ ] |
|
6204 |
] |
|
6205 |
] |
|
6206 |
] |
|
6207 |
]. |
|
261 | 6208 |
jEv := jMouseEventClass newCleared "basicNew". |
255 | 6209 |
jEv instVarNamed:'modifiers' put:modifiers. |
6210 |
jEv instVarNamed:'id' put:id. |
|
6211 |
jEv instVarNamed:'x' put:x. |
|
6212 |
jEv instVarNamed:'y' put:y. |
|
6213 |
jEv instVarNamed:'when' put:(OperatingSystem getMillisecondTime). |
|
6214 |
^ Array with:jEv |
|
6215 |
]. |
|
6216 |
||
6217 |
||
6218 |
((type == #'exposeX:y:width:height:') |
|
6219 |
or:[(type == #'graphicExposeX:y:width:height:') |
|
6220 |
or:[(type == #damage)]]) ifTrue:[ |
|
6221 |
jPaintEventClass := Java classForName:'java.awt.event.PaintEvent'. |
|
6222 |
jWindowEventClass := Java classForName:'java.awt.event.WindowEvent'. |
|
261 | 6223 |
"/ id := (jPaintEventClass instVarNamed:'PAINT'). |
6224 |
id := (jPaintEventClass instVarNamed:'UPDATE'). |
|
255 | 6225 |
|
6226 |
((type == #'exposeX:y:width:height:') |
|
6227 |
or:[(type == #'graphicExposeX:y:width:height:')]) ifTrue:[ |
|
6228 |
x := eventArgs at:1. |
|
6229 |
y := eventArgs at:2. |
|
6230 |
w := eventArgs at:3. |
|
6231 |
h := eventArgs at:4. |
|
6232 |
] ifFalse:[ |
|
6233 |
x := eventArgs left. |
|
6234 |
y := eventArgs top. |
|
6235 |
w := eventArgs width. |
|
6236 |
h := eventArgs height. |
|
6237 |
]. |
|
6238 |
jRect := (Java classForName:'java.awt.Rectangle') basicNew. |
|
6239 |
jRect instVarNamed:'x' put:x. |
|
6240 |
jRect instVarNamed:'y' put:y. |
|
6241 |
jRect instVarNamed:'width' put:w. |
|
6242 |
jRect instVarNamed:'height' put:h. |
|
6243 |
||
261 | 6244 |
jEv := jPaintEventClass newCleared "basicNew". |
255 | 6245 |
jEv instVarNamed:'id' put:id. |
6246 |
jEv instVarNamed:'updateRect' put:jRect. |
|
6247 |
||
6248 |
"/ jEv instVarNamed:'g' put:jWin. |
|
261 | 6249 |
|
255 | 6250 |
^ Array with:jEv. |
6251 |
]. |
|
6252 |
||
6253 |
(type == #'configureX:y:width:height:') ifTrue:[ |
|
261 | 6254 |
"/ x := eventArgs at:1. |
6255 |
"/ y := eventArgs at:2. |
|
6256 |
||
6257 |
view := anEvent view. |
|
6258 |
w := eventArgs at:3. |
|
6259 |
h := eventArgs at:4. |
|
6260 |
||
6261 |
"/ |
|
6262 |
"/ must change the components extent |
|
6263 |
"/ is there no cleaner way to do this ? |
|
6264 |
"/ |
|
6265 |
view isTopView ifTrue:[ |
|
6266 |
"/ |
|
6267 |
"/ sigh - don't include the menu. |
|
6268 |
"/ |
|
6269 |
menu := self topViewsMenu:view. |
|
6270 |
menu notNil ifTrue:[ |
|
6271 |
"/ must add the menus height |
|
6272 |
h := h - menu height |
|
6273 |
] |
|
6274 |
]. |
|
6275 |
jWin instVarNamed:'width' put:w. |
|
6276 |
jWin instVarNamed:'height' put:h. |
|
6277 |
||
255 | 6278 |
jComponentEventClass := Java classForName:'java.awt.event.ComponentEvent'. |
6279 |
id := (jComponentEventClass instVarNamed:'COMPONENT_MOVED'). |
|
261 | 6280 |
jEv1 := jComponentEventClass newCleared "basicNew". |
255 | 6281 |
jEv1 instVarNamed:'id' put:id. |
6282 |
||
6283 |
id := (jComponentEventClass instVarNamed:'COMPONENT_RESIZED'). |
|
261 | 6284 |
jEv2 := jComponentEventClass newCleared "basicNew". |
255 | 6285 |
jEv2 instVarNamed:'id' put:id. |
261 | 6286 |
|
255 | 6287 |
^ Array with:jEv1 with:jEv2. |
6288 |
]. |
|
6289 |
(type == #'focusIn') ifTrue:[ |
|
261 | 6290 |
'focusIn' printCR. |
255 | 6291 |
jComponentEventClass := Java classForName:'java.awt.event.FocusEvent'. |
6292 |
id := (jComponentEventClass instVarNamed:'FOCUS_GAINED'). |
|
261 | 6293 |
jEv := jComponentEventClass newCleared "basicNew". |
255 | 6294 |
jEv instVarNamed:'id' put:id. |
6295 |
^ Array with:jEv. |
|
6296 |
]. |
|
6297 |
(type == #'focusOut') ifTrue:[ |
|
261 | 6298 |
'focusOut' printCR. |
255 | 6299 |
jComponentEventClass := Java classForName:'java.awt.event.FocusEvent'. |
6300 |
id := (jComponentEventClass instVarNamed:'FOCUS_LOST'). |
|
261 | 6301 |
jEv := jComponentEventClass newCleared "basicNew". |
255 | 6302 |
jEv instVarNamed:'id' put:id. |
6303 |
^ Array with:jEv. |
|
6304 |
]. |
|
6305 |
(type == #'mapped') ifTrue:[ |
|
261 | 6306 |
'mapped' printCR. |
255 | 6307 |
jComponentEventClass := Java classForName:'java.awt.event.ComponentEvent'. |
6308 |
id := (jComponentEventClass instVarNamed:'COMPONENT_SHOWN'). |
|
6309 |
"/ x := eventArgs at:1. |
|
6310 |
"/ y := eventArgs at:2. |
|
261 | 6311 |
jEv := jComponentEventClass newCleared "basicNew". |
255 | 6312 |
jEv instVarNamed:'id' put:id. |
6313 |
^ Array with:jEv. |
|
6314 |
]. |
|
6315 |
(type == #'unmapped') ifTrue:[ |
|
261 | 6316 |
'unmapped' printCR. |
255 | 6317 |
jComponentEventClass := Java classForName:'java.awt.event.ComponentEvent'. |
6318 |
id := (jComponentEventClass instVarNamed:'COMPONENT_HIDDEN'). |
|
6319 |
"/ x := eventArgs at:1. |
|
6320 |
"/ y := eventArgs at:2. |
|
261 | 6321 |
jEv := jComponentEventClass newCleared "basicNew". |
255 | 6322 |
jEv instVarNamed:'id' put:id. |
6323 |
^ Array with:jEv. |
|
6324 |
]. |
|
6325 |
||
6326 |
(type == #terminate) ifTrue:[ |
|
6327 |
jWindowEventClass := Java classForName:'java.awt.event.WindowEvent'. |
|
6328 |
id := (jWindowEventClass instVarNamed:'WINDOW_CLOSED'). |
|
261 | 6329 |
jEv := jWindowEventClass newCleared "basicNew". |
255 | 6330 |
jEv instVarNamed:'id' put:id. |
6331 |
^ Array with:jEv. |
|
6332 |
]. |
|
6333 |
('JAVA: unhandled event:' , type) infoPrintCR. |
|
6334 |
^ nil. |
|
6335 |
||
6336 |
"Created: / 6.1.1998 / 20:38:58 / cg" |
|
270 | 6337 |
"Modified: / 24.1.1998 / 19:17:04 / cg" |
255 | 6338 |
! |
6339 |
||
6340 |
doWindowsEventThread |
|
6341 |
"invoked in an endless loop by the WToolkit-eventLoop |
|
6342 |
native method." |
|
6343 |
||
270 | 6344 |
|sensor event more| |
255 | 6345 |
|
6346 |
JavaWindowGroup isNil ifTrue:[ |
|
270 | 6347 |
"/ '*** eventThread: no windowGroup ...' printCR. |
6348 |
Delay waitForSeconds:0.1. |
|
6349 |
^ self |
|
255 | 6350 |
]. |
6351 |
||
6352 |
KnownWindows isNil ifTrue:[ |
|
270 | 6353 |
"/ '*** eventThread: no views ...' printCR. |
6354 |
Delay waitForSeconds:0.1. |
|
6355 |
^ self |
|
255 | 6356 |
]. |
6357 |
||
6358 |
"/ wait for an event to arrive ... |
|
6359 |
||
6360 |
sensor := JavaWindowGroup sensor. |
|
6361 |
(sensor hasEvents or:[sensor hasDamage]) ifFalse:[ |
|
270 | 6362 |
EventTrace ifTrue:[ |
6363 |
'*** eventThread waiting ...' printCR. |
|
6364 |
]. |
|
6365 |
Processor activeProcess state:#eventWait. |
|
6366 |
sensor eventSemaphore wait. |
|
6367 |
^ self. |
|
255 | 6368 |
]. |
6369 |
||
6370 |
EventTrace ifTrue:[ |
|
270 | 6371 |
'*** eventThread event arrived ...' printCR. |
255 | 6372 |
]. |
6373 |
||
6374 |
"/ EventTrace := true |
|
270 | 6375 |
more := true. |
6376 |
[more] whileTrue:[ |
|
6377 |
sensor hasDamage ifTrue:[ |
|
6378 |
EventTrace ifTrue:[ |
|
6379 |
'*** eventThread: damage arrived ...' printCR. |
|
6380 |
]. |
|
6381 |
event := sensor nextDamage. |
|
6382 |
] ifFalse:[ |
|
6383 |
event := sensor nextEvent. |
|
6384 |
]. |
|
6385 |
event isNil ifTrue:[ |
|
6386 |
'*** eventThread: nil event ignored' printCR. |
|
6387 |
^ self |
|
6388 |
]. |
|
6389 |
||
6390 |
more := self processEvent:event |
|
6391 |
] |
|
255 | 6392 |
|
6393 |
"Created: / 6.1.1998 / 21:02:40 / cg" |
|
270 | 6394 |
"Modified: / 25.1.1998 / 13:29:30 / cg" |
255 | 6395 |
! |
6396 |
||
6397 |
processEvent:event |
|
261 | 6398 |
|evQ jEvents jWToolKit jWinPeer jWin v eventConsumed| |
255 | 6399 |
|
6400 |
KnownWindows isNil ifTrue:[ |
|
270 | 6401 |
^ false |
255 | 6402 |
]. |
6403 |
||
6404 |
v := event view. |
|
261 | 6405 |
jWinPeer := self jPeerForView:v. |
255 | 6406 |
jWinPeer isNil ifTrue:[ |
261 | 6407 |
(v isKindOf:JavaView) ifTrue:[ |
6408 |
"/ mhmh - an event for a JavaView, |
|
6409 |
"/ which has no peer (anyMore ?) |
|
6410 |
"/ should not happen. |
|
6411 |
] ifFalse:[ |
|
6412 |
"/ mhmh - an event for a subcomponent of an ST widget. |
|
6413 |
"/ let it be handled normally. |
|
255 | 6414 |
EventTrace ifTrue:[ |
261 | 6415 |
('*** eventThread: ' , event type , '-event for unknown java-view - passed to view.') printCR. |
255 | 6416 |
]. |
6417 |
event sendEventWithFocusOn:nil. |
|
6418 |
]. |
|
270 | 6419 |
^ true |
261 | 6420 |
]. |
6421 |
||
6422 |
"/ change: |
|
6423 |
"/ in the previous version, events for ST/X widgets (i.e. buttons etc) |
|
6424 |
"/ where not passed to java, but instead forwarded directly to the widget |
|
6425 |
"/ by the code below. |
|
6426 |
"/ This has changed, to pass it to Java, which eventually passes it to the |
|
6427 |
"/ peer via the handleEvent native method (unless the event got consumed). |
|
6428 |
"/ This is req'd to let java keep track of keyboard/mouse input for widgets. |
|
6429 |
||
6430 |
false ifTrue:[ |
|
6431 |
"/ "/ most views handle their events themself (being ST/X views) ... |
|
6432 |
"/ |
|
6433 |
"/ v class ~~ JavaView ifTrue:[ |
|
6434 |
"/"/ v class ~~ StandardSystemView ifTrue:[ |
|
6435 |
"/"/ EventTrace ifTrue:[ |
|
6436 |
"/"/ ('*** eventThread: event handled by view itself (' , v class name , ')') printCR. |
|
6437 |
"/"/ ]. |
|
6438 |
"/"/ event sendEventWithFocusOn:nil. |
|
6439 |
"/"/ ^ self. |
|
6440 |
"/"/ ]. |
|
6441 |
"/ (event type == #'exposeX:y:width:height' |
|
6442 |
"/ or:[event type == #'graphicsExposeX:y:width:height']) ifTrue:[ |
|
6443 |
"/ "/ send to view, but also handle in JAVA |
|
6444 |
"/ event sendEventWithFocusOn:nil. |
|
6445 |
"/ ] |
|
6446 |
"/ ]. |
|
6447 |
||
6448 |
(#( |
|
6449 |
#'mapped' |
|
6450 |
#'unmapped' |
|
6451 |
#'configureX:y:width:height:' |
|
6452 |
#'exposeX:y:width:height:' |
|
6453 |
#'graphicsExposeX:y:width:height:' |
|
6454 |
) includes:event type) ifTrue:[ |
|
255 | 6455 |
event sendEventWithFocusOn:nil. |
6456 |
]. |
|
261 | 6457 |
]. |
6458 |
||
6459 |
"/ what a kludge - some events are passed back to |
|
6460 |
"/ ST via the WComponent-handleEvent native method. |
|
6461 |
"/ However, repaints are not. |
|
6462 |
"/ In order to let ST widgets do the drawing, |
|
6463 |
"/ selectively filter exposeEvents from Java ... |
|
6464 |
||
6465 |
eventConsumed := false. |
|
6466 |
v class == JavaView ifTrue:[ |
|
6467 |
"/ all events handled by Java ... |
|
6468 |
] ifFalse:[ |
|
6469 |
eventConsumed := true. |
|
6470 |
||
6471 |
"/ let widget handle it. |
|
6472 |
event sendEventWithFocusOn:nil. |
|
6473 |
||
6474 |
"/ some are not passed to Java ... |
|
6475 |
event isDamage ifTrue:[ |
|
6476 |
(v isKindOf:TextView) ifTrue:[ |
|
270 | 6477 |
^ true |
6478 |
]. |
|
6479 |
(v isKindOf:Label) ifTrue:[ |
|
6480 |
^ true |
|
6481 |
]. |
|
6482 |
(v isKindOf:ComboBoxView) ifTrue:[ |
|
6483 |
^ true |
|
6484 |
]. |
|
6485 |
(v isKindOf:ScrollBar) ifTrue:[ |
|
261 | 6486 |
^ self |
6487 |
]. |
|
270 | 6488 |
(v isKindOf:Scroller) ifTrue:[ |
261 | 6489 |
^ self |
6490 |
]. |
|
270 | 6491 |
(v isKindOf:MenuPanel) ifTrue:[ |
6492 |
^ true |
|
6493 |
]. |
|
261 | 6494 |
]. |
6495 |
]. |
|
255 | 6496 |
|
6497 |
jWin := jWinPeer instVarNamed:'target'. |
|
6498 |
||
6499 |
EventTrace ifTrue:[ |
|
6500 |
('*** eventThread: event (' , event type , ') handled by JAVA: ') infoPrint. |
|
6501 |
jWinPeer class name infoPrint. ' (' infoPrint. |
|
6502 |
jWin class name infoPrint. ')' infoPrintCR. |
|
6503 |
]. |
|
6504 |
||
6505 |
"/ create an event |
|
6506 |
||
6507 |
jEvents := self awtEventsForEvent:event javaWindow:jWin. |
|
6508 |
jEvents isNil ifTrue:[ |
|
6509 |
EventTrace ifTrue:[ |
|
6510 |
('*** eventThread: event ignored: ' , event type) printCR. |
|
6511 |
]. |
|
270 | 6512 |
^ true |
255 | 6513 |
]. |
6514 |
||
6515 |
"/ v superView isNil ifTrue:[ |
|
6516 |
"/ ('*** eventThread: event ignored for topView: ' , event type) printCR. |
|
6517 |
"/ ^ self |
|
6518 |
"/ ]. |
|
6519 |
||
6520 |
jWToolKit := (Java classForName:'java.awt.Toolkit') invoke:#getDefaultToolkit. |
|
6521 |
||
6522 |
jEvents do:[:jEv | |
|
6523 |
jEv instVarNamed:'source' put:jWin. |
|
6524 |
jEv instVarNamed:'consumed' put:0. |
|
261 | 6525 |
eventConsumed ifFalse:[ |
6526 |
"/ the first gets the original event as data |
|
6527 |
jEv instVarNamed:'data' put:event. |
|
6528 |
eventConsumed := true |
|
6529 |
]. |
|
255 | 6530 |
|
6531 |
"/ post it (them) to the event queue |
|
6532 |
||
6533 |
jWToolKit class |
|
6534 |
invoke:#'postEvent(Ljava/awt/AWTEvent;)V' |
|
6535 |
with:jEv. |
|
6536 |
]. |
|
6537 |
||
270 | 6538 |
^ false |
6539 |
||
255 | 6540 |
"Created: / 6.1.1998 / 20:36:36 / cg" |
270 | 6541 |
"Modified: / 25.1.1998 / 13:38:33 / cg" |
255 | 6542 |
! ! |
6543 |
||
253 | 6544 |
!JavaVM class methodsFor:'documentation'! |
6545 |
||
6546 |
version |
|
277 | 6547 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.11 1998/01/27 21:02:00 cg Exp $' |
253 | 6548 |
! ! |
6549 |
JavaVM initialize! |