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