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