ExternalStream.st
branchjv
changeset 18366 a6e62e167c32
parent 18334 3e18bee23c3a
parent 18364 a693511a7c46
child 18374 122c2dc2d0a5
--- a/ExternalStream.st	Sat May 16 06:48:37 2015 +0200
+++ b/ExternalStream.st	Mon May 18 07:10:20 2015 +0100
@@ -3591,6 +3591,20 @@
 
     |error|
 %{
+#ifdef __SCHTEAM__
+    STObject handle = self.instVarAt(I_handle);
+
+    if (handle != STObject.Nil) {
+	STObject next;
+
+	next = handle.nextByte();
+	if (next != STObject.EOF) {
+	    self.instVarAt_put(I_position, STObject.Nil);
+	    return __c__._RETURN( next );
+	}
+	self.instVarAt_put(I_hitEOF, STObject.True);
+    }
+#else
     FILEPOINTER f;
     unsigned char byte;
     int ret, _buffered;
@@ -3631,6 +3645,7 @@
 	    }
 	}
     }
+#endif /* not SCHTEAM */
 %}.
     hitEOF ifTrue:[^ self pastEndRead].
     error notNil ifTrue:[
@@ -4892,6 +4907,24 @@
 
     |c error|
 %{
+#ifdef __SCHTEAM__
+    STObject handle = self.instVarAt(I_handle);
+
+    if (handle != STObject.Nil) {
+	STObject next;
+
+	if (self.instVarAt(I_binary) == STObject.True) {
+	    next = handle.nextByte();
+	} else {
+	    next = handle.nextChar();
+	}
+	if (next != STObject.EOF) {
+	    self.instVarAt_put(I_position, STObject.Nil);
+	    return __c__._RETURN( next );
+	}
+	self.instVarAt_put(I_hitEOF, STObject.True);
+    }
+#else
     FILEPOINTER f;
     int ret, _buffered;
     OBJ pos, fp;
@@ -4931,9 +4964,9 @@
 
 	    __INST(position) = nil;
 	    if ((ret < 0)
-#ifdef ECONNRESET
+# ifdef ECONNRESET
 		&& (__threadErrno != ECONNRESET)
-#endif
+# endif
 	    ){
 		error = __mkSmallInteger(__threadErrno);
 	    } else /* ret == 0 */ {
@@ -4941,6 +4974,7 @@
 	    }
 	}
     }
+#endif /* not SCHTEAM */
 %}.
     hitEOF == true ifTrue:[^ self pastEndRead].
     error notNil ifTrue:[
@@ -5472,19 +5506,19 @@
     wasBlocked := OperatingSystem blockInterrupts.
     inputSema := Semaphore new name:'readWait'.
     [
-        timeoutOrNil notNil ifTrue:[
-            Processor signal:inputSema afterMilliseconds:timeoutOrNil.
-        ].
-        Processor signal:inputSema onInput:fd.
-        Processor activeProcess state:#ioWait.
-        inputSema wait.
-        hasTimedout := timeoutOrNil notNil and:[(OperatingSystem readCheck:fd) not].
+	timeoutOrNil notNil ifTrue:[
+	    Processor signal:inputSema afterMilliseconds:timeoutOrNil.
+	].
+	Processor signal:inputSema onInput:fd.
+	Processor activeProcess state:#ioWait.
+	inputSema wait.
+	hasTimedout := timeoutOrNil notNil and:[(OperatingSystem readCheck:fd) not].
     ] ifCurtailed:[
-        Processor disableSemaphore:inputSema.
-        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+	Processor disableSemaphore:inputSema.
+	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
     ].
     timeoutOrNil notNil ifTrue:[
-        Processor disableSemaphore:inputSema.
+	Processor disableSemaphore:inputSema.
     ].
     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
     ^ hasTimedout
@@ -5693,6 +5727,16 @@
 
     |error|
 %{
+#ifdef __SCHTEAM__
+    STObject handle = self.instVarAt(I_handle);
+
+    if ((handle != STObject.Nil)
+     && (aCharacter.isSTCharacter())) {
+	handle.writeChar( aCharacter );
+	self.instVarAt_put(I_position, STObject.Nil);
+	return __c__._RETURN_self();
+    }
+#else
     FILEPOINTER f;
     unsigned codePoint;
     unsigned char c;
@@ -5747,11 +5791,11 @@
 			if (_buffered = (__INST(buffered) == true)) {
 			    __WRITING__(f)
 			}
-#ifdef WIN32
+# ifdef WIN32
 			if ((f == __win32_stdout()) || (f == __win32_stderr())) {
 			    cnt = __win32_fwrite(buff, 1, nBytes, f);
 			} else
-#endif
+# endif
 			{
 			    __WRITEBYTES__(cnt, f, buff, nBytes, _buffered, __INST(handleType));
 			}
@@ -5779,6 +5823,7 @@
 	}
     }
 out: ;
+#endif /* not SCHTEAM */
 %}.
     error notNil ifTrue:[
 	lastErrorNumber := error.
@@ -5812,6 +5857,16 @@
 
     |error|
 %{
+#ifdef __SCHTEAM__
+    STObject handle = self.instVarAt(I_handle);
+
+    if ((handle != STObject.Nil)
+     && (aCollection.isSTString())) {
+	handle.writeCharacters( aCollection.asSTString().characters );
+	self.instVarAt_put(I_position, STObject.Nil);
+	return __c__._RETURN_self();
+    }
+#else
     FILEPOINTER f;
     INT len, cnt;
     OBJ fp;
@@ -5908,21 +5963,21 @@
 		    }
 
 		    len = dp - buf;
-#ifdef WIN32
+# ifdef WIN32
 		    if ((f == __win32_stdout()) || (f == __win32_stderr())) {
 			cnt = __win32_fwrite(buf, 1, len, f);
 		    } else
-#endif
+# endif
 		    {
 			__WRITEBYTES__(cnt, f, buf, len, _buffered, __INST(handleType));
 		    }
 		    free(buf);
 		} else  {  // No EOL conversion needed
-#ifdef WIN32
+# ifdef WIN32
 		    if ((f == __win32_stdout()) || (f == __win32_stderr())) {
 			cnt = __win32_fwrite(stringP, 1, len, f);
 		    } else
-#endif
+# endif
 		    {
 			o_offs = stringP - (char *)__InstPtr(aCollection);
 			__WRITEBYTES_OBJ__(cnt, f, aCollection, o_offs, len, _buffered, __INST(handleType));
@@ -5940,11 +5995,11 @@
 			len = __byteArraySize(aCollection) - offs;
 		    } else
 			goto out;
-#ifdef WIN32
+# ifdef WIN32
 		    if ((f == __win32_stdout()) || (f == __win32_stderr())) {
 			cnt = __win32_fwrite(__stringVal(aCollection), 1, len, f);
 		    } else
-#endif
+# endif
 		    {
 			o_offs = (char *)(__ByteArrayInstPtr(aCollection)->ba_element) - (char *)__InstPtr(aCollection);
 			o_offs += offs;
@@ -5971,6 +6026,7 @@
 	}
     }
 out: ;
+#endif /* not SCHTEAM */
 %}.
     error notNil ifTrue:[
 	lastErrorNumber := error.
@@ -6210,13 +6266,19 @@
 
 %{
 #ifdef __SCHTEAM__
-    char[] chars;
     byte[] bytes;
     STObject handle = self.instVarAt(I_handle);
 
     if (anObject.isSTString()) {
-	chars = anObject.asSTString().characters;
+	char[] chars = anObject.asSTString().characters;
 	handle.writeCharacters(chars, start.intValue(), count.intValue());
+	self.instVarAt_put(I_position, STObject.Nil);
+	return context._RETURN(count);
+    }
+    if (anObject.isSymbol()) {
+	java.lang.String chars = anObject.asSTSymbol().characters;
+	handle.writeString(chars, start.intValue(), count.intValue());
+	self.instVarAt_put(I_position, STObject.Nil);
 	return context._RETURN(count);
     }
 #else
@@ -6485,11 +6547,11 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.418 2015-05-08 01:06:30 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.419 2015-05-18 00:16:20 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.418 2015-05-08 01:06:30 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.419 2015-05-18 00:16:20 cg Exp $'
 ! !