NPExtStr.st
changeset 2965 c5d6d02b0e8c
parent 2896 be30640b9012
child 3173 664f2ffa7493
equal deleted inserted replaced
2964:ce8a6e9898c4 2965:c5d6d02b0e8c
    66 ! !
    66 ! !
    67 
    67 
    68 !NonPositionableExternalStream class methodsFor:'instance creation'!
    68 !NonPositionableExternalStream class methodsFor:'instance creation'!
    69 
    69 
    70 forStderr
    70 forStderr
       
    71     "{ Pragma: +optSpace }"
       
    72 
    71     "return a NonPositionableExternalStream object for writing to
    73     "return a NonPositionableExternalStream object for writing to
    72      Unixes standard error output file descriptor"
    74      Unixes standard error output file descriptor"
    73 
    75 
    74     StdErrorStream isNil ifTrue:[
    76     StdErrorStream isNil ifTrue:[
    75 	StdErrorStream := self basicNew initializeForStderr
    77 	StdErrorStream := self basicNew initializeForStderr
    76     ].
    78     ].
    77     ^ StdErrorStream
    79     ^ StdErrorStream
    78 !
    80 !
    79 
    81 
    80 forStdin
    82 forStdin
       
    83     "{ Pragma: +optSpace }"
       
    84 
    81     "return a NonPositionableExternalStream object for reading from
    85     "return a NonPositionableExternalStream object for reading from
    82      Unixes standard input file descriptor"
    86      Unixes standard input file descriptor"
    83 
    87 
    84     StdInStream isNil ifTrue:[
    88     StdInStream isNil ifTrue:[
    85 	StdInStream := self basicNew initializeForStdin
    89 	StdInStream := self basicNew initializeForStdin
    86     ].
    90     ].
    87     ^ StdInStream
    91     ^ StdInStream
    88 !
    92 !
    89 
    93 
    90 forStdout
    94 forStdout
       
    95     "{ Pragma: +optSpace }"
       
    96 
    91     "return a NonPositionableExternalStream object for writing to
    97     "return a NonPositionableExternalStream object for writing to
    92      Unixes standard output file descriptor"
    98      Unixes standard output file descriptor"
    93 
    99 
    94     StdOutStream isNil ifTrue:[
   100     StdOutStream isNil ifTrue:[
    95 	StdOutStream := self basicNew initializeForStdout
   101 	StdOutStream := self basicNew initializeForStdout
    98 ! !
   104 ! !
    99 
   105 
   100 !NonPositionableExternalStream methodsFor:'error handling'!
   106 !NonPositionableExternalStream methodsFor:'error handling'!
   101 
   107 
   102 positionError
   108 positionError
       
   109     "{ Pragma: +optSpace }"
       
   110 
   103     "notify that this stream has no concept of a position"
   111     "notify that this stream has no concept of a position"
   104 
   112 
   105     ^ PositionErrorSignal raiseRequestWith:self in:thisContext sender
   113     ^ PositionErrorSignal raiseRequestWith:self in:thisContext sender
   106 ! !
   114 ! !
   107 
   115 
   108 !NonPositionableExternalStream methodsFor:'positioning'!
   116 !NonPositionableExternalStream methodsFor:'positioning'!
   109 
   117 
   110 position
   118 position
       
   119     "{ Pragma: +optSpace }"
       
   120 
   111     "catch position - there is none here"
   121     "catch position - there is none here"
   112 
   122 
   113     ^ self positionError
   123     ^ self positionError
   114 !
   124 !
   115 
   125 
   116 position:aPosition
   126 position:aPosition
       
   127     "{ Pragma: +optSpace }"
       
   128 
   117     "catch position - there is none here"
   129     "catch position - there is none here"
   118 
   130 
   119     ^ self positionError
   131     ^ self positionError
   120 !
   132 !
   121 
   133 
   130 ! !
   142 ! !
   131 
   143 
   132 !NonPositionableExternalStream methodsFor:'printing & storing'!
   144 !NonPositionableExternalStream methodsFor:'printing & storing'!
   133 
   145 
   134 printOn:aStream
   146 printOn:aStream
       
   147     "{ Pragma: +optSpace }"
       
   148 
   135     "append a printed representation of the receiver on aStream"
   149     "append a printed representation of the receiver on aStream"
   136 
   150 
       
   151     |myName|
       
   152 
   137     self == Stdin ifTrue:[
   153     self == Stdin ifTrue:[
   138 	aStream nextPutAll:'Stdin'.
   154 	myName := 'Stdin'.
       
   155     ] ifFalse:[
       
   156         self == Stdout ifTrue:[
       
   157 	    myName := 'Stdout'.
       
   158         ] ifFalse:[
       
   159             self == Stderr ifTrue:[
       
   160 	        myName := 'Stderr'.
       
   161 	    ]
       
   162 	]
       
   163     ].
       
   164 
       
   165     myName notNil ifTrue:[
       
   166 	aStream nextPutAll:myName.
   139 	^ self
   167 	^ self
   140     ].
   168     ].
   141     self == Stdout ifTrue:[
       
   142 	aStream nextPutAll:'Stdout'.
       
   143 	^ self
       
   144     ].
       
   145     self == Stderr ifTrue:[
       
   146 	aStream nextPutAll:'Stderr'.
       
   147 	^ self
       
   148     ].
       
   149     super printOn:aStream
   169     super printOn:aStream
   150 !
   170 !
   151 
   171 
   152 storeOn:aStream
   172 storeOn:aStream
       
   173     "{ Pragma: +optSpace }"
       
   174 
   153     "append a printed representation of the receiver on aStream, from
   175     "append a printed representation of the receiver on aStream, from
   154      which the receiver can be reconstructed."
   176      which the receiver can be reconstructed."
   155 
   177 
   156     ((self == Stdin)
   178     ((self == Stdin)
   157     or:[self == Stdout
   179     or:[self == Stdout
   162 ! !
   184 ! !
   163 
   185 
   164 !NonPositionableExternalStream methodsFor:'private'!
   186 !NonPositionableExternalStream methodsFor:'private'!
   165 
   187 
   166 initializeForStderr
   188 initializeForStderr
       
   189     "{ Pragma: +optSpace }"
       
   190 
   167     "setup for writing to stderr"
   191     "setup for writing to stderr"
   168 
   192 
   169     mode := #readwrite.
   193     mode := #readwrite.
   170     buffered := false.
   194     buffered := false.
   171 %{
   195 %{
   174     __INST(filePointer) = fp = __MKOBJ(stderr); __STORE(self, fp);
   198     __INST(filePointer) = fp = __MKOBJ(stderr); __STORE(self, fp);
   175 %}
   199 %}
   176 !
   200 !
   177 
   201 
   178 initializeForStdin
   202 initializeForStdin
       
   203     "{ Pragma: +optSpace }"
       
   204 
   179     "setup for reading stdin"
   205     "setup for reading stdin"
   180 
   206 
   181     mode := #readonly.
   207     mode := #readonly.
   182     buffered := true.
   208     buffered := true.
   183 %{
   209 %{
   186     __INST(filePointer) = fp = __MKOBJ(stdin); __STORE(self, fp);
   212     __INST(filePointer) = fp = __MKOBJ(stdin); __STORE(self, fp);
   187 %}
   213 %}
   188 !
   214 !
   189 
   215 
   190 initializeForStdout
   216 initializeForStdout
       
   217     "{ Pragma: +optSpace }"
       
   218 
   191     "setup for writing to stdout"
   219     "setup for writing to stdout"
   192 
   220 
   193     mode := #readwrite.
   221     mode := #readwrite.
   194     buffered := false.
   222     buffered := false.
   195 %{
   223 %{
   198     __INST(filePointer) = fp = __MKOBJ(stdout); __STORE(self, fp);
   226     __INST(filePointer) = fp = __MKOBJ(stdout); __STORE(self, fp);
   199 %}
   227 %}
   200 !
   228 !
   201 
   229 
   202 reOpen
   230 reOpen
       
   231     "{ Pragma: +optSpace }"
       
   232 
   203     "reopen the stream after an image restart.
   233     "reopen the stream after an image restart.
   204      If I am one of the standard streams, reopen is easy"
   234      If I am one of the standard streams, reopen is easy"
   205 
   235 
   206     (self == StdInStream) ifTrue:[
   236     (self == StdInStream) ifTrue:[
   207 	^ self initializeForStdin
   237 	^ self initializeForStdin
   224 ! !
   254 ! !
   225 
   255 
   226 !NonPositionableExternalStream class methodsFor:'documentation'!
   256 !NonPositionableExternalStream class methodsFor:'documentation'!
   227 
   257 
   228 version
   258 version
   229     ^ '$Header: /cvs/stx/stx/libbasic/Attic/NPExtStr.st,v 1.29 1997-09-04 21:02:52 cg Exp $'
   259     ^ '$Header: /cvs/stx/stx/libbasic/Attic/NPExtStr.st,v 1.30 1997-09-22 19:04:17 cg Exp $'
   230 ! !
   260 ! !