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