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