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