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.2 by root, Sat Oct 26 10:41:12 2013 UTC vs.
Revision 1.3 by root, Sat Oct 26 11:08:34 2013 UTC

8#include <stdio.h> 8#include <stdio.h>
9#include <limits.h> 9#include <limits.h>
10#include <float.h> 10#include <float.h>
11 11
12#include "ecb.h" 12#include "ecb.h"
13
14#if defined(__BORLANDC__) || defined(_MSC_VER)
15# define snprintf _snprintf // C compilers have this in stdio.h
16#endif
17 13
18#define F_SHRINK 0x00000200UL 14#define F_SHRINK 0x00000200UL
19#define F_ALLOW_UNKNOWN 0x00002000UL 15#define F_ALLOW_UNKNOWN 0x00002000UL
20 16
21#define INIT_SIZE 32 // initial scalar size to be allocated 17#define INIT_SIZE 32 // initial scalar size to be allocated
781fail: 777fail:
782 return &PL_sv_undef; 778 return &PL_sv_undef;
783} 779}
784 780
785static SV * 781static SV *
782decode_tagged (dec_t *dec)
783{
784 UV tag = decode_uint (dec);
785 SV *sv = decode_sv (dec);
786
787 if (tag == 55799) // 2.4.5 Self-Describe CBOR
788 return sv;
789
790 AV *av = newAV ();
791 av_push (av, newSVuv (tag));
792 av_push (av, sv);
793 return newRV_noinc ((SV *)av);
794}
795
796static SV *
786decode_sv (dec_t *dec) 797decode_sv (dec_t *dec)
787{ 798{
788 WANT (1); 799 WANT (1);
789 800
790 switch (*dec->cur >> 5) 801 switch (*dec->cur >> 5)
801 case 4: // array 812 case 4: // array
802 return decode_av (dec); 813 return decode_av (dec);
803 case 5: // map 814 case 5: // map
804 return decode_hv (dec); 815 return decode_hv (dec);
805 case 6: // tag 816 case 6: // tag
806 abort (); 817 return decode_tagged (dec);
807 break;
808 case 7: // misc 818 case 7: // misc
809 switch (*dec->cur++ & 31) 819 switch (*dec->cur++ & 31)
810 { 820 {
811 case 20: 821 case 20:
812#if CBOR_SLOW 822#if CBOR_SLOW

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines