Differences From Artifact [c4d6ff9c2a]:
- File
src/OFStream.m
— part of check-in
[4d9a641d87]
at
2012-09-19 23:02:02
on branch trunk
— Make async I/O possible without blocks.
Async connecting is still missing. (user: js, size: 28993) [annotate] [blame] [check-ins using]
To Artifact [1ba71f5d61]:
- File
src/OFStream.m
— part of check-in
[1cb8fee5c3]
at
2012-10-13 21:06:59
on branch trunk
— of_bswap* -> OF_BSWAP*.
This makes it clear that multiple evaluation of parameters is possible. (user: js, size: 28993) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
203 204 205 206 207 208 209 | - (uint16_t)readBigEndianInt16 { uint16_t ret; [self readIntoBuffer: (char*)&ret exactLength: 2]; | | | | | | | | | | | | | | | | | | | | | | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 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 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 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 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | - (uint16_t)readBigEndianInt16 { uint16_t ret; [self readIntoBuffer: (char*)&ret exactLength: 2]; return OF_BSWAP16_IF_LE(ret); } - (uint32_t)readBigEndianInt32 { uint32_t ret; [self readIntoBuffer: (char*)&ret exactLength: 4]; return OF_BSWAP32_IF_LE(ret); } - (uint64_t)readBigEndianInt64 { uint64_t ret; [self readIntoBuffer: (char*)&ret exactLength: 8]; return OF_BSWAP64_IF_LE(ret); } - (float)readBigEndianFloat { float ret; [self readIntoBuffer: (char*)&ret exactLength: 4]; return OF_BSWAP_FLOAT_IF_LE(ret); } - (double)readBigEndianDouble { double ret; [self readIntoBuffer: (char*)&ret exactLength: 8]; return OF_BSWAP_DOUBLE_IF_LE(ret); } - (size_t)readBigEndianInt16sIntoBuffer: (uint16_t*)buffer count: (size_t)nInt16s { size_t size = nInt16s * sizeof(uint16_t); [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt16s; i++) buffer[i] = OF_BSWAP16(buffer[i]); #endif return size; } - (size_t)readBigEndianInt32sIntoBuffer: (uint32_t*)buffer count: (size_t)nInt32s { size_t size = nInt32s * sizeof(uint32_t); [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt32s; i++) buffer[i] = OF_BSWAP32(buffer[i]); #endif return size; } - (size_t)readBigEndianInt64sIntoBuffer: (uint64_t*)buffer count: (size_t)nInt64s { size_t size = nInt64s * sizeof(uint64_t); [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt64s; i++) buffer[i] = OF_BSWAP64(buffer[i]); #endif return size; } - (size_t)readBigEndianFloatsIntoBuffer: (float*)buffer count: (size_t)nFloats { size_t size = nFloats * sizeof(float); [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_FLOAT_BIG_ENDIAN size_t i; for (i = 0; i < nFloats; i++) buffer[i] = OF_BSWAP_FLOAT(buffer[i]); #endif return size; } - (size_t)readBigEndianDoublesIntoBuffer: (double*)buffer count: (size_t)nDoubles { size_t size = nDoubles * sizeof(double); [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_FLOAT_BIG_ENDIAN size_t i; for (i = 0; i < nDoubles; i++) buffer[i] = OF_BSWAP_DOUBLE(buffer[i]); #endif return size; } - (uint16_t)readLittleEndianInt16 { uint16_t ret; [self readIntoBuffer: (char*)&ret exactLength: 2]; return OF_BSWAP16_IF_BE(ret); } - (uint32_t)readLittleEndianInt32 { uint32_t ret; [self readIntoBuffer: (char*)&ret exactLength: 4]; return OF_BSWAP32_IF_BE(ret); } - (uint64_t)readLittleEndianInt64 { uint64_t ret; [self readIntoBuffer: (char*)&ret exactLength: 8]; return OF_BSWAP64_IF_BE(ret); } - (float)readLittleEndianFloat { float ret; [self readIntoBuffer: (char*)&ret exactLength: 4]; return OF_BSWAP_FLOAT_IF_BE(ret); } - (double)readLittleEndianDouble { double ret; [self readIntoBuffer: (char*)&ret exactLength: 8]; return OF_BSWAP_DOUBLE_IF_BE(ret); } - (size_t)readLittleEndianInt16sIntoBuffer: (uint16_t*)buffer count: (size_t)nInt16s { size_t size = nInt16s * sizeof(uint16_t); [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt16s; i++) buffer[i] = OF_BSWAP16(buffer[i]); #endif return size; } - (size_t)readLittleEndianInt32sIntoBuffer: (uint32_t*)buffer count: (size_t)nInt32s { size_t size = nInt32s * sizeof(uint32_t); [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt32s; i++) buffer[i] = OF_BSWAP32(buffer[i]); #endif return size; } - (size_t)readLittleEndianInt64sIntoBuffer: (uint64_t*)buffer count: (size_t)nInt64s { size_t size = nInt64s * sizeof(uint64_t); [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN size_t i; for (i = 0; i < nInt64s; i++) buffer[i] = OF_BSWAP64(buffer[i]); #endif return size; } - (size_t)readLittleEndianFloatsIntoBuffer: (float*)buffer count: (size_t)nFloats { size_t size = nFloats * sizeof(float); [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_FLOAT_BIG_ENDIAN size_t i; for (i = 0; i < nFloats; i++) buffer[i] = OF_BSWAP_FLOAT(buffer[i]); #endif return size; } - (size_t)readLittleEndianDoublesIntoBuffer: (double*)buffer count: (size_t)nDoubles { size_t size = nDoubles * sizeof(double); [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_FLOAT_BIG_ENDIAN size_t i; for (i = 0; i < nDoubles; i++) buffer[i] = OF_BSWAP_DOUBLE(buffer[i]); #endif return size; } - (OFDataArray*)readDataArrayWithSize: (size_t)nItems { |
︙ | ︙ | |||
971 972 973 974 975 976 977 | { [self writeBuffer: (char*)&int8 length: 1]; } - (void)writeBigEndianInt16: (uint16_t)int16 { | | | | | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 | { [self writeBuffer: (char*)&int8 length: 1]; } - (void)writeBigEndianInt16: (uint16_t)int16 { int16 = OF_BSWAP16_IF_LE(int16); [self writeBuffer: (char*)&int16 length: 2]; } - (void)writeBigEndianInt32: (uint32_t)int32 { int32 = OF_BSWAP32_IF_LE(int32); [self writeBuffer: (char*)&int32 length: 4]; } - (void)writeBigEndianInt64: (uint64_t)int64 { int64 = OF_BSWAP64_IF_LE(int64); [self writeBuffer: (char*)&int64 length: 8]; } - (void)writeBigEndianFloat: (float)float_ { float_ = OF_BSWAP_FLOAT_IF_LE(float_); [self writeBuffer: (char*)&float_ length: 4]; } - (void)writeBigEndianDouble: (double)double_ { double_ = OF_BSWAP_DOUBLE_IF_LE(double_); [self writeBuffer: (char*)&double_ length: 8]; } - (size_t)writeBigEndianInt16s: (const uint16_t*)buffer count: (size_t)nInt16s |
︙ | ︙ | |||
1027 1028 1029 1030 1031 1032 1033 | tmp = [self allocMemoryWithSize: sizeof(uint16_t) count: nInt16s]; @try { size_t i; for (i = 0; i < nInt16s; i++) | | | 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 | tmp = [self allocMemoryWithSize: sizeof(uint16_t) count: nInt16s]; @try { size_t i; for (i = 0; i < nInt16s; i++) tmp[i] = OF_BSWAP16(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { [self freeMemory: tmp]; } #endif |
︙ | ︙ | |||
1057 1058 1059 1060 1061 1062 1063 | tmp = [self allocMemoryWithSize: sizeof(uint32_t) count: nInt32s]; @try { size_t i; for (i = 0; i < nInt32s; i++) | | | 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 | tmp = [self allocMemoryWithSize: sizeof(uint32_t) count: nInt32s]; @try { size_t i; for (i = 0; i < nInt32s; i++) tmp[i] = OF_BSWAP32(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { [self freeMemory: tmp]; } #endif |
︙ | ︙ | |||
1087 1088 1089 1090 1091 1092 1093 | tmp = [self allocMemoryWithSize: sizeof(uint64_t) count: nInt64s]; @try { size_t i; for (i = 0; i < nInt64s; i++) | | | 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | tmp = [self allocMemoryWithSize: sizeof(uint64_t) count: nInt64s]; @try { size_t i; for (i = 0; i < nInt64s; i++) tmp[i] = OF_BSWAP64(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { [self freeMemory: tmp]; } #endif |
︙ | ︙ | |||
1117 1118 1119 1120 1121 1122 1123 | tmp = [self allocMemoryWithSize: sizeof(float) count: nFloats]; @try { size_t i; for (i = 0; i < nFloats; i++) | | | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | tmp = [self allocMemoryWithSize: sizeof(float) count: nFloats]; @try { size_t i; for (i = 0; i < nFloats; i++) tmp[i] = OF_BSWAP_FLOAT(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { [self freeMemory: tmp]; } #endif |
︙ | ︙ | |||
1147 1148 1149 1150 1151 1152 1153 | tmp = [self allocMemoryWithSize: sizeof(double) count: nDoubles]; @try { size_t i; for (i = 0; i < nDoubles; i++) | | | | | | | | 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 | tmp = [self allocMemoryWithSize: sizeof(double) count: nDoubles]; @try { size_t i; for (i = 0; i < nDoubles; i++) tmp[i] = OF_BSWAP_DOUBLE(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { [self freeMemory: tmp]; } #endif return size; } - (void)writeLittleEndianInt16: (uint16_t)int16 { int16 = OF_BSWAP16_IF_BE(int16); [self writeBuffer: (char*)&int16 length: 2]; } - (void)writeLittleEndianInt32: (uint32_t)int32 { int32 = OF_BSWAP32_IF_BE(int32); [self writeBuffer: (char*)&int32 length: 4]; } - (void)writeLittleEndianInt64: (uint64_t)int64 { int64 = OF_BSWAP64_IF_BE(int64); [self writeBuffer: (char*)&int64 length: 8]; } - (void)writeLittleEndianFloat: (float)float_ { float_ = OF_BSWAP_FLOAT_IF_BE(float_); [self writeBuffer: (char*)&float_ length: 4]; } - (void)writeLittleEndianDouble: (double)double_ { double_ = OF_BSWAP_DOUBLE_IF_BE(double_); [self writeBuffer: (char*)&double_ length: 8]; } - (size_t)writeLittleEndianInt16s: (const uint16_t*)buffer count: (size_t)nInt16s |
︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 | tmp = [self allocMemoryWithSize: sizeof(uint16_t) count: nInt16s]; @try { size_t i; for (i = 0; i < nInt16s; i++) | | | 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 | tmp = [self allocMemoryWithSize: sizeof(uint16_t) count: nInt16s]; @try { size_t i; for (i = 0; i < nInt16s; i++) tmp[i] = OF_BSWAP16(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { [self freeMemory: tmp]; } #endif |
︙ | ︙ | |||
1247 1248 1249 1250 1251 1252 1253 | tmp = [self allocMemoryWithSize: sizeof(uint32_t) count: nInt32s]; @try { size_t i; for (i = 0; i < nInt32s; i++) | | | 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 | tmp = [self allocMemoryWithSize: sizeof(uint32_t) count: nInt32s]; @try { size_t i; for (i = 0; i < nInt32s; i++) tmp[i] = OF_BSWAP32(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { [self freeMemory: tmp]; } #endif |
︙ | ︙ | |||
1277 1278 1279 1280 1281 1282 1283 | tmp = [self allocMemoryWithSize: sizeof(uint64_t) count: nInt64s]; @try { size_t i; for (i = 0; i < nInt64s; i++) | | | 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 | tmp = [self allocMemoryWithSize: sizeof(uint64_t) count: nInt64s]; @try { size_t i; for (i = 0; i < nInt64s; i++) tmp[i] = OF_BSWAP64(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { [self freeMemory: tmp]; } #endif |
︙ | ︙ | |||
1307 1308 1309 1310 1311 1312 1313 | tmp = [self allocMemoryWithSize: sizeof(float) count: nFloats]; @try { size_t i; for (i = 0; i < nFloats; i++) | | | 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 | tmp = [self allocMemoryWithSize: sizeof(float) count: nFloats]; @try { size_t i; for (i = 0; i < nFloats; i++) tmp[i] = OF_BSWAP_FLOAT(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { [self freeMemory: tmp]; } #endif |
︙ | ︙ | |||
1337 1338 1339 1340 1341 1342 1343 | tmp = [self allocMemoryWithSize: sizeof(double) count: nDoubles]; @try { size_t i; for (i = 0; i < nDoubles; i++) | | | 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 | tmp = [self allocMemoryWithSize: sizeof(double) count: nDoubles]; @try { size_t i; for (i = 0; i < nDoubles; i++) tmp[i] = OF_BSWAP_DOUBLE(buffer[i]); [self writeBuffer: tmp length: size]; } @finally { [self freeMemory: tmp]; } #endif |
︙ | ︙ |