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