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