Differences From Artifact [c84f6d8cdf]:
- File
src/OFDataArray+MessagePackValue.m
— part of check-in
[cba771824e]
at
2013-06-19 19:14:11
on branch trunk
— Implement the new MessagePack specification.
No support for extensions yet.
This obsoletes BinaryPack. (user: js, size: 8666) [annotate] [blame] [check-ins using]
To Artifact [b3b35d004c]:
- File src/OFDataArray+MessagePackValue.m — part of check-in [5ec11e8b56] at 2013-06-20 08:13:46 on branch trunk — Add support for MessagePack extensions. (user: js, size: 11566) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFDataArray+MessagePackValue.h" #import "OFNumber.h" #import "OFNull.h" #import "OFDataArray.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFInvalidFormatException.h" #import "autorelease.h" #import "macros.h" int _OFDataArray_MessagePackValue_reference; | > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #import "OFDataArray+MessagePackValue.h" #import "OFNumber.h" #import "OFNull.h" #import "OFDataArray.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFMessagePackExtension.h" #import "OFInvalidFormatException.h" #import "autorelease.h" #import "macros.h" int _OFDataArray_MessagePackValue_reference; |
︙ | ︙ | |||
137 138 139 140 141 142 143 144 145 146 147 148 149 150 | return pos; } static size_t parse_object(const uint8_t *buffer, size_t length, id *object) { size_t i, count; if (length < 1) goto error; /* positive fixint */ if ((buffer[0] & 0x80) == 0) { *object = [OFNumber numberWithUInt8: buffer[0] & 0x7F]; | > > | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | return pos; } static size_t parse_object(const uint8_t *buffer, size_t length, id *object) { size_t i, count; int8_t type; OFDataArray *data; if (length < 1) goto error; /* positive fixint */ if ((buffer[0] & 0x80) == 0) { *object = [OFNumber numberWithUInt8: buffer[0] & 0x7F]; |
︙ | ︙ | |||
280 281 282 283 284 285 286 | goto error; count = buffer[1]; if (length < count + 2) goto error; | | < | < | > | > > > > > > > > > > > > > > > > | | > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 485 486 487 488 489 490 491 492 493 494 495 496 | goto error; count = buffer[1]; if (length < count + 2) goto error; *object = [OFDataArray dataArrayWithCapacity: count]; [*object addItems: buffer + 2 count: count]; return count + 2; case 0xC5: /* bin 16 */ if (length < 3) goto error; count = read_uint16(buffer + 1); if (length < count + 3) goto error; *object = [OFDataArray dataArrayWithCapacity: count]; [*object addItems: buffer + 3 count: count]; return count + 3; case 0xC6: /* bin 32 */ if (length < 5) goto error; count = read_uint32(buffer + 1); if (length < count + 5) goto error; *object = [OFDataArray dataArrayWithCapacity: count]; [*object addItems: buffer + 5 count: count]; return count + 5; /* Extensions */ case 0xC7: /* ext 8 */ if (length < 3) goto error; count = buffer[1]; if (length < count + 3) goto error; type = buffer[2]; data = [[OFDataArray alloc] initWithCapacity: count]; @try { [data addItems: buffer + 3 count: count]; *object = [OFMessagePackExtension extensionWithType: type data: data]; } @finally { [data release]; } return count + 3; case 0xC8: /* ext 16 */ if (length < 4) goto error; count = read_uint16(buffer + 1); if (length < count + 4) goto error; type = buffer[3]; data = [[OFDataArray alloc] initWithCapacity: count]; @try { [data addItems: buffer + 4 count: count]; *object = [OFMessagePackExtension extensionWithType: type data: data]; } @finally { [data release]; } return count + 4; case 0xC9: /* ext 32 */ if (length < 6) goto error; count = read_uint32(buffer + 1); if (length < count + 6) goto error; type = buffer[5]; data = [[OFDataArray alloc] initWithCapacity: count]; @try { [data addItems: buffer + 6 count: count]; *object = [OFMessagePackExtension extensionWithType: type data: data]; } @finally { [data release]; } return count + 6; case 0xD4: /* fixext 1 */ if (length < 3) goto error; type = buffer[1]; data = [[OFDataArray alloc] initWithCapacity: 1]; @try { [data addItem: buffer + 2]; *object = [OFMessagePackExtension extensionWithType: type data: data]; } @finally { [data release]; } return 3; case 0xD5: /* fixext 2 */ if (length < 4) goto error; type = buffer[1]; data = [[OFDataArray alloc] initWithCapacity: 2]; @try { [data addItems: buffer + 2 count: 2]; *object = [OFMessagePackExtension extensionWithType: type data: data]; } @finally { [data release]; } return 4; case 0xD6: /* fixtext 4 */ if (length < 6) goto error; type = buffer[1]; data = [[OFDataArray alloc] initWithCapacity: 4]; @try { [data addItems: buffer + 2 count: 4]; *object = [OFMessagePackExtension extensionWithType: type data: data]; } @finally { [data release]; } return 6; case 0xD7: /* fixtext 8 */ if (length < 10) goto error; type = buffer[1]; data = [[OFDataArray alloc] initWithCapacity: 8]; @try { [data addItems: buffer + 2 count: 8]; *object = [OFMessagePackExtension extensionWithType: type data: data]; } @finally { [data release]; } return 10; case 0xD8: /* fixext 16 */ if (length < 18) goto error; type = buffer[1]; data = [[OFDataArray alloc] initWithCapacity: 16]; @try { [data addItems: buffer + 2 count: 16]; *object = [OFMessagePackExtension extensionWithType: type data: data]; } @finally { [data release]; } return 18; /* Strings */ case 0xD9: /* str 8 */ if (length < 2) goto error; count = buffer[1]; |
︙ | ︙ |