ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/XS.xs
(Generate patch)

Comparing CBOR-XS/XS.xs (file contents):
Revision 1.33 by root, Sat Nov 30 15:23:59 2013 UTC vs.
Revision 1.34 by root, Sat Nov 30 16:19:59 2013 UTC

342 HV *tagged_stash = !CBOR_SLOW || cbor_tagged_stash 342 HV *tagged_stash = !CBOR_SLOW || cbor_tagged_stash
343 ? cbor_tagged_stash 343 ? cbor_tagged_stash
344 : gv_stashpv ("CBOR::XS::Tagged" , 1); 344 : gv_stashpv ("CBOR::XS::Tagged" , 1);
345 345
346 HV *stash = SvSTASH (sv); 346 HV *stash = SvSTASH (sv);
347 GV *method;
348 347
349 if (stash == boolean_stash) 348 if (stash == boolean_stash)
349 {
350 encode_ch (enc, SvIV (sv) ? 0xe0 | 21 : 0xe0 | 20); 350 encode_ch (enc, SvIV (sv) ? 0xe0 | 21 : 0xe0 | 20);
351 return;
352 }
351 else if (stash == error_stash) 353 else if (stash == error_stash)
354 {
352 encode_ch (enc, 0xe0 | 23); 355 encode_ch (enc, 0xe0 | 23);
356 return;
357 }
353 else if (stash == tagged_stash) 358 else if (stash == tagged_stash)
354 { 359 {
355 if (svt != SVt_PVAV) 360 if (svt != SVt_PVAV)
356 croak ("encountered CBOR::XS::Tagged object that isn't an array"); 361 croak ("encountered CBOR::XS::Tagged object that isn't an array");
357 362
358 encode_uint (enc, 0xc0, SvUV (*av_fetch ((AV *)sv, 0, 1))); 363 encode_uint (enc, 0xc0, SvUV (*av_fetch ((AV *)sv, 0, 1)));
359 encode_sv (enc, *av_fetch ((AV *)sv, 1, 1)); 364 encode_sv (enc, *av_fetch ((AV *)sv, 1, 1));
365
366 return;
367 }
368 }
369
370 if (ecb_expect_false (SvREFCNT (sv) > 1)
371 && ecb_expect_false (enc->cbor.flags & F_ALLOW_SHARING))
372 {
373 if (!enc->shareable)
374 enc->shareable = (HV *)sv_2mortal ((SV *)newHV ());
375
376 SV **svp = hv_fetch (enc->shareable, (char *)&sv, sizeof (sv), 1);
377
378 if (SvOK (*svp))
360 } 379 {
380 encode_tag (enc, CBOR_TAG_VALUE_SHAREDREF);
381 encode_uint (enc, 0x00, SvUV (*svp));
382 return;
383 }
384 else
385 {
386 sv_setuv (*svp, enc->shareable_idx);
387 ++enc->shareable_idx;
388 encode_tag (enc, CBOR_TAG_VALUE_SHAREABLE);
389 }
390 }
391
392 if (ecb_expect_false (SvOBJECT (sv)))
393 {
394 HV *stash = SvSTASH (sv);
395 GV *method;
396
361 else if ((method = gv_fetchmethod_autoload (stash, "TO_CBOR", 0))) 397 if ((method = gv_fetchmethod_autoload (stash, "TO_CBOR", 0)))
362 { 398 {
363 dSP; 399 dSP;
364 400
365 ENTER; SAVETMPS; PUSHMARK (SP); 401 ENTER; SAVETMPS; PUSHMARK (SP);
366 // we re-bless the reference to get overload and other niceties right 402 // we re-bless the reference to get overload and other niceties right
418 encode_hv (enc, (HV *)sv); 454 encode_hv (enc, (HV *)sv);
419 else if (svt == SVt_PVAV) 455 else if (svt == SVt_PVAV)
420 encode_av (enc, (AV *)sv); 456 encode_av (enc, (AV *)sv);
421 else 457 else
422 { 458 {
423 if (ecb_expect_false (SvREFCNT (sv) > 1)
424 && ecb_expect_false (enc->cbor.flags & F_ALLOW_SHARING))
425 {
426 if (!enc->shareable)
427 enc->shareable = (HV *)sv_2mortal ((SV *)newHV ());
428
429 SV **svp = hv_fetch (enc->shareable, (char *)&sv, sizeof (sv), 1);
430
431 if (SvOK (*svp))
432 {
433 encode_tag (enc, CBOR_TAG_VALUE_SHAREDREF);
434 encode_uint (enc, 0x00, SvUV (*svp));
435 return;
436 }
437 else
438 {
439 sv_setuv (*svp, enc->shareable_idx);
440 ++enc->shareable_idx;
441 encode_tag (enc, CBOR_TAG_VALUE_SHAREABLE);
442 }
443 }
444
445 encode_tag (enc, CBOR_TAG_INDIRECTION); 459 encode_tag (enc, CBOR_TAG_INDIRECTION);
446 encode_sv (enc, sv); 460 encode_sv (enc, sv);
447 } 461 }
448} 462}
449 463
600 | ((UV)dec->cur[-1]); 614 | ((UV)dec->cur[-1]);
601 615
602 case 27: 616 case 27:
603 WANT (9); 617 WANT (9);
604 dec->cur += 9; 618 dec->cur += 9;
619
620 return
621#if UVSIZE < 8
622 0
623#else
605 return (((UV)dec->cur[-8]) << 56) 624 (((UV)dec->cur[-8]) << 56)
606 | (((UV)dec->cur[-7]) << 48) 625 | (((UV)dec->cur[-7]) << 48)
607 | (((UV)dec->cur[-6]) << 40) 626 | (((UV)dec->cur[-6]) << 40)
608 | (((UV)dec->cur[-5]) << 32) 627 | (((UV)dec->cur[-5]) << 32)
628#endif
609 | (((UV)dec->cur[-4]) << 24) 629 | (((UV)dec->cur[-4]) << 24)
610 | (((UV)dec->cur[-3]) << 16) 630 | (((UV)dec->cur[-3]) << 16)
611 | (((UV)dec->cur[-2]) << 8) 631 | (((UV)dec->cur[-2]) << 8)
612 | ((UV)dec->cur[-1]); 632 | ((UV)dec->cur[-1]);
613 633

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines