Ported rest of IO natives not to use nativeContext.
--- a/JavaNativeMethodImpl_OpenJDK6.st Wed Jan 30 17:37:19 2013 +0000
+++ b/JavaNativeMethodImpl_OpenJDK6.st Wed Jan 30 18:02:21 2013 +0000
@@ -378,53 +378,10 @@
"Modified (comment): / 18-07-2012 / 23:00:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-anyStream_close: nativeContext
- |jStream fileNo file|
-
- jStream := nativeContext receiver.
-
- file := self validateFile:jStream.
- file == Stdin ifTrue:[
- file := StdinReplacementFileQuerySignal raiseRequest.
- file isNil ifTrue:[
- file := Stdin
- ]
- ].
-
- "/ should always be bytes
-
- (file ~~ Stdin
- and:[file ~~ Stdout
- and:[file ~~ Stderr
- and:[file ~~ Transcript]]]) ifTrue:[
- file close.
- ] ifFalse:[
- self breakPoint: #jv.
- ].
- self setOpenFile:nil at:fileNo.
-
- fileNo := jStream instVarNamed:'fd'.
- fileNo isInteger ifFalse:[
- "/ JDK 1.1.3
- fileNo instVarNamed:'fd' put:0.
- ] ifTrue:[
- "/ JDK 1.0
- jStream instVarNamed:'fd' put:0
- ].
-
- "Created: / 04-02-1998 / 15:22:03 / cg"
- "Modified: / 14-10-1998 / 15:10:07 / cg"
- "Modified: / 28-07-2012 / 02:45:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-anyStream_readBytes: nativeContext
- |bytes offset count stream nRead|
-
- bytes := nativeContext argAt:1.
- offset := nativeContext argAt:2.
- count := nativeContext argAt:3.
-
- stream := self validateFile:(nativeContext receiver).
+anyStream_read: jstream bytes: bytes offset: offset count: count
+ | stream nRead|
+
+ stream := self validateFile: jstream.
"/ should always be bytes
bytes class isBytes ifFalse:[
@@ -469,19 +426,13 @@
].
^ nRead
- "Created: / 04-02-1998 / 15:20:00 / cg"
- "Modified: / 10-11-1998 / 19:56:47 / cg"
- "Modified: / 10-08-2011 / 21:35:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-anyStream_writeBytes: nativeContext
- |bytes offset count stream|
-
- bytes := nativeContext argAt:1.
- offset := nativeContext argAt:2.
- count := nativeContext argAt:3.
-
- stream := self validateFile:(nativeContext receiver).
+ "Created: / 30-01-2013 / 17:55:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+anyStream_write: jstream bytes: bytes offset: offset count: count
+ | stream |
+
+ stream := self validateFile:jstream.
FileIOTrace ifTrue:[
stream isFileStream ifTrue:[
@@ -514,9 +465,7 @@
]
].
- "Created: / 04-02-1998 / 15:23:58 / cg"
- "Modified: / 16-02-1999 / 11:32:45 / cg"
- "Modified: / 14-09-2011 / 22:05:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 30-01-2013 / 17:58:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
checkWritePermissionOfDirectory:dir message:msg
@@ -549,10 +498,10 @@
"Modified: / 3.12.1998 / 15:16:55 / cg"
!
-commonClose: nativeContext
+commonClose: jstream
| fdobj fd stream |
- fdobj := (nativeContext receiver instVarNamed: #fd).
+ fdobj := (jstream instVarNamed: #fd).
fd := fdobj instVarNamed: #fd.
fd == -1 ifTrue:[
"Never opened or already closed"
@@ -578,12 +527,12 @@
fdobj instVarNamed:#fd put: -1.
"Created: / 10-08-2011 / 14:02:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-commonOpen: nativeContext forAppend:forAppend
- |fs fd fn nm dir stream fileNo readonly|
-
- fs := nativeContext receiver.
+ "Modified: / 30-01-2013 / 17:50:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+commonOpen: fs path: path forAppend:forAppend
+ | fd fn nm dir stream fileNo readonly|
+
fd := fs instVarNamed:'fd'.
(fd instVarNamed:'fd') ~~ -1 ifTrue:[
"/self halt:'file already open'.
@@ -591,8 +540,8 @@
^ self.
].
- nm := nativeContext argAt:1.
- nm := Java as_ST_String:nm.
+
+ nm := Java as_ST_String:path.
FileOpenTrace ifTrue:[
('JAVA: opening ' , nm) infoPrintCR.
@@ -630,7 +579,7 @@
readonly ifTrue:[
(fn exists and:[fn isReadable not]) ifTrue:[
- ^self throwFileNotFoundException: 'File is not readable'
+ ^JavaVM throwFileNotFoundException: 'File is not readable'
].
stream := fn readStream.
] ifFalse:[
@@ -638,10 +587,10 @@
"/ ^self throwFileNotFoundException: 'File does not exist'
"/ ].
fn isDirectory ifTrue:[
- ^self throwFileNotFoundException: 'File is directory'
+ ^JavaVM throwFileNotFoundException: 'File is directory'
].
(fn exists and:[fn isWritable not]) ifTrue:[
- ^self throwFileNotFoundException: 'File does not writable'
+ ^JavaVM throwFileNotFoundException: 'File does not writable'
].
forAppend ifTrue:[
stream := self commonOpenStreamUsing:[fn appendingWriteStream].
@@ -665,9 +614,7 @@
"Kludge for finalization..."
fs finalizationLobby registerChange: fs
- "Created: / 07-04-1998 / 19:14:09 / cg"
- "Modified: / 04-01-1999 / 14:34:42 / cg"
- "Modified: / 12-12-2012 / 23:43:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 30-01-2013 / 17:53:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
commonOpenStreamUsing: aBlock
@@ -7021,9 +6968,9 @@
<javanative: 'java/io/FileInputStream' name: 'close0()V'>
- ^self commonClose: self nativeContext
-
- "Modified: / 30-01-2013 / 14:13:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ ^self commonClose: this
+
+ "Modified: / 30-01-2013 / 17:50:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_io_FileInputStream_initIDs: this
@@ -7122,14 +7069,14 @@
"Modified (format): / 12-12-2012 / 23:53:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-_java_io_FileInputStream_readBytes: this _:a1 _: a2 _: a3
+_java_io_FileInputStream_readBytes: this _:bytes _: offset _: count
<javanative: 'java/io/FileInputStream' name: 'readBytes([BII)I'>
- ^ self anyStream_readBytes: self nativeContext
+ ^ self anyStream_read: this bytes: bytes offset: offset count: count.
"Modified: / 04-02-1998 / 15:23:08 / cg"
- "Modified: / 30-01-2013 / 14:13:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-01-2013 / 17:56:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_io_FileInputStream_skip: this _:a1 _: a2
@@ -7163,9 +7110,9 @@
<javanative: 'java/io/FileOutputStream' name: 'close0()V'>
- ^self commonClose: self nativeContext
-
- "Modified: / 30-01-2013 / 14:13:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ ^self commonClose: this
+
+ "Modified: / 30-01-2013 / 17:50:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_io_FileOutputStream_initIDs: this
@@ -7181,20 +7128,20 @@
<javanative: 'java/io/FileOutputStream' name: 'open(Ljava/lang/String;)V'>
- ^ self commonOpen: self nativeContext forAppend:false
+ ^ self commonOpen: this path: a1 forAppend:false
"Modified: / 07-04-1998 / 19:14:31 / cg"
- "Modified: / 30-01-2013 / 14:13:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-01-2013 / 17:53:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_io_FileOutputStream_openAppend: this _:a1
<javanative: 'java/io/FileOutputStream' name: 'openAppend(Ljava/lang/String;)V'>
- ^ self commonOpen: self nativeContext forAppend:true
+ ^ self commonOpen: this path: a1 forAppend:true
"Modified: / 07-04-1998 / 19:13:42 / cg"
- "Modified: / 30-01-2013 / 14:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-01-2013 / 17:53:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_io_FileOutputStream_write: this _:a1
@@ -7227,14 +7174,14 @@
"Modified: / 15-12-2012 / 16:31:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-_java_io_FileOutputStream_writeBytes: this _:a1 _: a2 _: a3
+_java_io_FileOutputStream_writeBytes: this _:bytes _: offset _: count
<javanative: 'java/io/FileOutputStream' name: 'writeBytes([BII)V'>
- ^ self anyStream_writeBytes: self nativeContext
+ ^ self anyStream_write: this bytes: bytes offset: offset count: count.
"Modified: / 04-02-1998 / 15:24:20 / cg"
- "Modified: / 30-01-2013 / 14:13:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-01-2013 / 17:58:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_io_FileSystem_getFileSystem: this
@@ -7318,9 +7265,9 @@
<javanative: 'java/io/RandomAccessFile' name: 'close0()V'>
- ^ self commonClose: self nativeContext
-
- "Modified: / 30-01-2013 / 14:17:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ ^ self commonClose: this
+
+ "Modified: / 30-01-2013 / 17:50:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_io_RandomAccessFile_getFilePointer: this
@@ -7486,14 +7433,14 @@
"Created: / 27.1.1999 / 19:01:15 / cg"
!
-_java_io_RandomAccessFile_readBytes: this _:a1 _: a2 _: a3
+_java_io_RandomAccessFile_readBytes: this _:bytes _: offset _: count
<javanative: 'java/io/RandomAccessFile' name: 'readBytes([BII)I'>
- ^ self anyStream_readBytes: self nativeContext
+ ^ self anyStream_read: this bytes: bytes offset: offset count: count.
"Modified: / 04-02-1998 / 15:23:27 / cg"
- "Modified: / 30-01-2013 / 14:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-01-2013 / 17:56:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_io_RandomAccessFile_seek: this _:a1 _: a2
@@ -7515,14 +7462,14 @@
"Modified (comment): / 06-07-2012 / 12:39:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-_java_io_RandomAccessFile_writeBytes: this _:a1 _: a2 _: a3
+_java_io_RandomAccessFile_writeBytes: this _:bytes _: offset _: count
<javanative: 'java/io/RandomAccessFile' name: 'writeBytes([BII)V'>
- ^ self anyStream_writeBytes: self nativeContext
+ ^ self anyStream_write: this bytes: bytes offset: offset count: count.
"Created: / 04-02-1998 / 15:24:35 / cg"
- "Modified: / 30-01-2013 / 14:14:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-01-2013 / 17:58:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_io_UnixFileSystem_canonicalize0: this _:a1
@@ -10519,9 +10466,9 @@
<javanative: 'java/net/PlainSocketImpl' name: 'socketClose0(Z)V'>
- ^self commonClose: self nativeContext
-
- "Modified: / 30-01-2013 / 14:16:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ ^self commonClose: this
+
+ "Modified: / 30-01-2013 / 17:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_net_PlainSocketImpl_socketConnect: this _:a1 _: a2 _: a3