Differences From Artifact [7f1468fef3]:
- File
src/OFStdIOStream.m
— part of check-in
[fe2cbe0021]
at
2018-04-22 16:13:04
on branch trunk
— runtime: Define BOOL to be the same as bool
As we define the ABI, we can just replace BOOL with bool everywhere,
including in ObjFW itself. For the Apple platforms where BOOL and bool
are different, this is not a problem as BOOL and bool are passed and
returned the same way in the ABI.This still defines BOOL to bool for compatibility, except on AmigaOS and
Wii, which both have its own BOOL type. (user: js, size: 6965) [annotate] [blame] [check-ins using]
To Artifact [6647a44cbe]:
- File src/OFStdIOStream.m — part of check-in [b16fc262c0] at 2018-04-23 22:19:10 on branch trunk — Use more native AmigaOS APIs on AmigaOS 3 (user: js, size: 7023) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
37 38 39 40 41 42 43 | #endif #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" | | > > > | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #endif #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_AMIGAOS # ifdef OF_AMIGAOS3 # define INTUITION_CLASSES_H # endif # include <proto/exec.h> #endif /* References for static linking */ #ifdef OF_WINDOWS void _reference_to_OFStdIOStream_Win32Console(void) { [OFStdIOStream_Win32Console class]; } #endif OFStdIOStream *of_stdin = nil; OFStdIOStream *of_stdout = nil; OFStdIOStream *of_stderr = nil; #ifdef OF_AMIGAOS OF_DESTRUCTOR() { [of_stdin dealloc]; [of_stdout dealloc]; [of_stderr dealloc]; } #endif |
︙ | ︙ | |||
94 95 96 97 98 99 100 | objc_autoreleasePoolPop(pool); } @implementation OFStdIOStream #ifndef OF_WINDOWS + (void)load { | | | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | objc_autoreleasePoolPop(pool); } @implementation OFStdIOStream #ifndef OF_WINDOWS + (void)load { # ifndef OF_AMIGAOS of_stdin = [[OFStdIOStream alloc] of_initWithFileDescriptor: 0]; of_stdout = [[OFStdIOStream alloc] of_initWithFileDescriptor: 1]; of_stderr = [[OFStdIOStream alloc] of_initWithFileDescriptor: 2]; # else BPTR input = Input(), output = Output(); BPTR error = ((struct Process *)FindTask(NULL))->pr_CES; bool inputClosable = false, outputClosable = false, |
︙ | ︙ | |||
134 135 136 137 138 139 140 | #endif - (instancetype)init { OF_INVALID_INIT_METHOD } | | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | #endif - (instancetype)init { OF_INVALID_INIT_METHOD } #ifndef OF_AMIGAOS - (instancetype)of_initWithFileDescriptor: (int)fd { self = [super init]; _fd = fd; return self; |
︙ | ︙ | |||
165 166 167 168 169 170 171 | [self close]; [super dealloc]; } - (bool)lowlevelIsAtEndOfStream { | | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | [self close]; [super dealloc]; } - (bool)lowlevelIsAtEndOfStream { #ifndef OF_AMIGAOS if (_fd == -1) #else if (_handle == 0) #endif @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; #ifndef OF_AMIGAOS if (_fd == -1) @throw [OFNotOpenException exceptionWithObject: self]; # ifndef OF_WINDOWS if ((ret = read(_fd, buffer, length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length |
︙ | ︙ | |||
220 221 222 223 224 225 226 | return ret; } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | return ret; } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { #ifndef OF_AMIGAOS if (_fd == -1) @throw [OFNotOpenException exceptionWithObject: self]; # ifndef OF_WINDOWS ssize_t bytesWritten; if (length > SSIZE_MAX) |
︙ | ︙ | |||
266 267 268 269 270 271 272 | bytesWritten: 0 errNo: EIO]; #endif return (size_t)bytesWritten; } | | | | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | bytesWritten: 0 errNo: EIO]; #endif return (size_t)bytesWritten; } #if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) - (int)fileDescriptorForReading { return _fd; } - (int)fileDescriptorForWriting { return _fd; } #endif - (void)close { #ifndef OF_AMIGAOS if (_fd != -1) close(_fd); _fd = -1; #else if (_closable && _handle != 0) Close(_handle); |
︙ | ︙ | |||
316 317 318 319 320 321 322 | - (unsigned int)retainCount { return OF_RETAIN_COUNT_MAX; } - (int)columns { | | | | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | - (unsigned int)retainCount { return OF_RETAIN_COUNT_MAX; } - (int)columns { #if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_AMIGAOS) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; return ws.ws_col; #else return -1; #endif } - (int)rows { #if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_AMIGAOS) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; return ws.ws_row; #else return -1; #endif } @end |