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