… | |
… | |
19 | # define HvNAMELEN(hv) HvNAMELEN_get (hv) |
19 | # define HvNAMELEN(hv) HvNAMELEN_get (hv) |
20 | #endif |
20 | #endif |
21 | #ifndef HvNAMEUTF8 |
21 | #ifndef HvNAMEUTF8 |
22 | # define HvNAMEUTF8(hv) 0 |
22 | # define HvNAMEUTF8(hv) 0 |
23 | #endif |
23 | #endif |
|
|
24 | #ifndef SvREFCNT_dec_NN |
|
|
25 | # define SvREFCNT_dec_NN(sv) SvREFCNT_dec (sv) |
|
|
26 | #endif |
24 | |
27 | |
25 | // known tags |
28 | // known tags |
26 | enum cbor_tag |
29 | enum cbor_tag |
27 | { |
30 | { |
28 | // inofficial extensions (pending iana registration) |
31 | // extensions |
|
|
32 | CBOR_TAG_STRINGREF = 25, // http://cbor.schmorp.de/stringref |
29 | CBOR_TAG_PERL_OBJECT = 24, // http://cbor.schmorp.de/perl-object |
33 | CBOR_TAG_PERL_OBJECT = 26, // http://cbor.schmorp.de/perl-object |
30 | CBOR_TAG_GENERIC_OBJECT = 25, // http://cbor.schmorp.de/generic-object |
34 | CBOR_TAG_GENERIC_OBJECT = 27, // http://cbor.schmorp.de/generic-object |
31 | CBOR_TAG_VALUE_SHAREABLE = 26, // http://cbor.schmorp.de/value-sharing |
35 | CBOR_TAG_VALUE_SHAREABLE = 28, // http://cbor.schmorp.de/value-sharing |
32 | CBOR_TAG_VALUE_SHAREDREF = 27, // http://cbor.schmorp.de/value-sharing |
36 | CBOR_TAG_VALUE_SHAREDREF = 29, // http://cbor.schmorp.de/value-sharing |
33 | CBOR_TAG_STRINGREF_NAMESPACE = 65537, // http://cbor.schmorp.de/stringref |
37 | CBOR_TAG_STRINGREF_NAMESPACE = 256, // http://cbor.schmorp.de/stringref |
34 | CBOR_TAG_STRINGREF = 28, // http://cbor.schmorp.de/stringref |
|
|
35 | CBOR_TAG_INDIRECTION = 22098, // http://cbor.schmorp.de/indirection |
38 | CBOR_TAG_INDIRECTION = 22098, // http://cbor.schmorp.de/indirection |
36 | |
39 | |
37 | // rfc7049 |
40 | // rfc7049 |
38 | CBOR_TAG_DATETIME = 0, // rfc4287, utf-8 |
41 | CBOR_TAG_DATETIME = 0, // rfc4287, utf-8 |
39 | CBOR_TAG_TIMESTAMP = 1, // unix timestamp, any |
42 | CBOR_TAG_TIMESTAMP = 1, // unix timestamp, any |
… | |
… | |
54 | CBOR_TAG_MIME = 36, // mime message rfc2045, utf-8 |
57 | CBOR_TAG_MIME = 36, // mime message rfc2045, utf-8 |
55 | |
58 | |
56 | CBOR_TAG_MAGIC = 55799 // self-describe cbor |
59 | CBOR_TAG_MAGIC = 55799 // self-describe cbor |
57 | }; |
60 | }; |
58 | |
61 | |
59 | #define F_SHRINK 0x00000001UL |
62 | #define F_SHRINK 0x00000001UL |
60 | #define F_ALLOW_UNKNOWN 0x00000002UL |
63 | #define F_ALLOW_UNKNOWN 0x00000002UL |
61 | #define F_ALLOW_SHARING 0x00000004UL //TODO |
64 | #define F_ALLOW_SHARING 0x00000004UL |
62 | #define F_DEDUP_STRINGS 0x00000008UL //TODO |
65 | #define F_PACK_STRINGS 0x00000008UL |
63 | |
66 | |
64 | #define INIT_SIZE 32 // initial scalar size to be allocated |
67 | #define INIT_SIZE 32 // initial scalar size to be allocated |
65 | |
68 | |
66 | #define SB do { |
69 | #define SB do { |
67 | #define SE } while (0) |
70 | #define SE } while (0) |
… | |
… | |
79 | # define CBOR_SLOW 0 |
82 | # define CBOR_SLOW 0 |
80 | # define CBOR_STASH cbor_stash |
83 | # define CBOR_STASH cbor_stash |
81 | #endif |
84 | #endif |
82 | |
85 | |
83 | static HV *cbor_stash, *types_boolean_stash, *types_error_stash, *cbor_tagged_stash; // CBOR::XS:: |
86 | static HV *cbor_stash, *types_boolean_stash, *types_error_stash, *cbor_tagged_stash; // CBOR::XS:: |
84 | static SV *types_true, *types_false, *types_error, *sv_cbor; |
87 | static SV *types_true, *types_false, *types_error, *sv_cbor, *default_filter; |
85 | |
88 | |
86 | typedef struct { |
89 | typedef struct { |
87 | U32 flags; |
90 | U32 flags; |
88 | U32 max_depth; |
91 | U32 max_depth; |
89 | STRLEN max_size; |
92 | STRLEN max_size; |
|
|
93 | SV *filter; |
90 | } CBOR; |
94 | } CBOR; |
91 | |
95 | |
92 | ecb_inline void |
96 | ecb_inline void |
93 | cbor_init (CBOR *cbor) |
97 | cbor_init (CBOR *cbor) |
94 | { |
98 | { |
95 | Zero (cbor, 1, CBOR); |
99 | Zero (cbor, 1, CBOR); |
96 | cbor->max_depth = 512; |
100 | cbor->max_depth = 512; |
|
|
101 | } |
|
|
102 | |
|
|
103 | ecb_inline void |
|
|
104 | cbor_free (CBOR *cbor) |
|
|
105 | { |
|
|
106 | SvREFCNT_dec (cbor->filter); |
97 | } |
107 | } |
98 | |
108 | |
99 | ///////////////////////////////////////////////////////////////////////////// |
109 | ///////////////////////////////////////////////////////////////////////////// |
100 | // utility functions |
110 | // utility functions |
101 | |
111 | |
… | |
… | |
131 | { |
141 | { |
132 | return idx > 23 |
142 | return idx > 23 |
133 | ? idx > 0xffU |
143 | ? idx > 0xffU |
134 | ? idx > 0xffffU |
144 | ? idx > 0xffffU |
135 | ? idx > 0xffffffffU |
145 | ? idx > 0xffffffffU |
|
|
146 | ? 11 |
136 | ? 7 |
147 | : 7 |
137 | : 6 |
|
|
138 | : 5 |
148 | : 5 |
139 | : 4 |
149 | : 4 |
140 | : 3; |
150 | : 3; |
141 | } |
151 | } |
142 | |
152 | |
… | |
… | |
179 | static void |
189 | static void |
180 | encode_uint (enc_t *enc, int major, UV len) |
190 | encode_uint (enc_t *enc, int major, UV len) |
181 | { |
191 | { |
182 | need (enc, 9); |
192 | need (enc, 9); |
183 | |
193 | |
184 | if (len < 24) |
194 | if (ecb_expect_true (len < 24)) |
185 | *enc->cur++ = major | len; |
195 | *enc->cur++ = major | len; |
186 | else if (len <= 0xff) |
196 | else if (ecb_expect_true (len <= 0xff)) |
187 | { |
197 | { |
188 | *enc->cur++ = major | 24; |
198 | *enc->cur++ = major | 24; |
189 | *enc->cur++ = len; |
199 | *enc->cur++ = len; |
190 | } |
200 | } |
191 | else if (len <= 0xffff) |
201 | else if (len <= 0xffff) |
… | |
… | |
220 | encode_tag (enc_t *enc, UV tag) |
230 | encode_tag (enc_t *enc, UV tag) |
221 | { |
231 | { |
222 | encode_uint (enc, 0xc0, tag); |
232 | encode_uint (enc, 0xc0, tag); |
223 | } |
233 | } |
224 | |
234 | |
|
|
235 | ecb_inline void |
|
|
236 | encode_str (enc_t *enc, int utf8, char *str, STRLEN len) |
|
|
237 | { |
|
|
238 | encode_uint (enc, utf8 ? 0x60 : 0x40, len); |
|
|
239 | need (enc, len); |
|
|
240 | memcpy (enc->cur, str, len); |
|
|
241 | enc->cur += len; |
|
|
242 | } |
|
|
243 | |
225 | static void |
244 | static void |
226 | encode_str (enc_t *enc, int utf8, char *str, STRLEN len) |
245 | encode_strref (enc_t *enc, int utf8, char *str, STRLEN len) |
227 | { |
246 | { |
228 | if (ecb_expect_false (enc->cbor.flags & F_DEDUP_STRINGS)) |
247 | if (ecb_expect_false (enc->cbor.flags & F_PACK_STRINGS)) |
229 | { |
248 | { |
230 | SV **svp = hv_fetch (enc->stringref[utf8], str, len, 1); |
249 | SV **svp = hv_fetch (enc->stringref[!!utf8], str, len, 1); |
231 | |
250 | |
232 | if (SvOK (*svp)) |
251 | if (SvOK (*svp)) |
233 | { |
252 | { |
234 | // already registered, use stringref |
253 | // already registered, use stringref |
235 | encode_tag (enc, CBOR_TAG_STRINGREF); |
254 | encode_tag (enc, CBOR_TAG_STRINGREF); |
… | |
… | |
242 | sv_setuv (*svp, enc->stringref_idx); |
261 | sv_setuv (*svp, enc->stringref_idx); |
243 | ++enc->stringref_idx; |
262 | ++enc->stringref_idx; |
244 | } |
263 | } |
245 | } |
264 | } |
246 | |
265 | |
247 | encode_uint (enc, utf8 ? 0x60 : 0x40, len); |
266 | encode_str (enc, utf8, str, len); |
248 | need (enc, len); |
|
|
249 | memcpy (enc->cur, str, len); |
|
|
250 | enc->cur += len; |
|
|
251 | } |
267 | } |
252 | |
268 | |
253 | static void encode_sv (enc_t *enc, SV *sv); |
269 | static void encode_sv (enc_t *enc, SV *sv); |
254 | |
270 | |
255 | static void |
271 | static void |
… | |
… | |
269 | SV **svp = av_fetch (av, i, 0); |
285 | SV **svp = av_fetch (av, i, 0); |
270 | encode_sv (enc, svp ? *svp : &PL_sv_undef); |
286 | encode_sv (enc, svp ? *svp : &PL_sv_undef); |
271 | } |
287 | } |
272 | |
288 | |
273 | --enc->depth; |
289 | --enc->depth; |
274 | } |
|
|
275 | |
|
|
276 | ecb_inline void |
|
|
277 | encode_he (enc_t *enc, HE *he) |
|
|
278 | { |
|
|
279 | } |
290 | } |
280 | |
291 | |
281 | static void |
292 | static void |
282 | encode_hv (enc_t *enc, HV *hv) |
293 | encode_hv (enc_t *enc, HV *hv) |
283 | { |
294 | { |
… | |
… | |
299 | while ((he = hv_iternext (hv))) |
310 | while ((he = hv_iternext (hv))) |
300 | { |
311 | { |
301 | if (HeKLEN (he) == HEf_SVKEY) |
312 | if (HeKLEN (he) == HEf_SVKEY) |
302 | encode_sv (enc, HeSVKEY (he)); |
313 | encode_sv (enc, HeSVKEY (he)); |
303 | else |
314 | else |
304 | encode_str (enc, HeKUTF8 (he), HeKEY (he), HeKLEN (he)); |
315 | encode_strref (enc, HeKUTF8 (he), HeKEY (he), HeKLEN (he)); |
305 | |
316 | |
306 | encode_sv (enc, ecb_expect_false (mg) ? hv_iterval (hv, he) : HeVAL (he)); |
317 | encode_sv (enc, ecb_expect_false (mg) ? hv_iterval (hv, he) : HeVAL (he)); |
307 | } |
318 | } |
308 | |
319 | |
309 | if (mg) |
320 | if (mg) |
… | |
… | |
410 | if (count == 1 && SvROK (TOPs) && SvRV (TOPs) == sv) |
421 | if (count == 1 && SvROK (TOPs) && SvRV (TOPs) == sv) |
411 | croak ("%s::FREEZE(CBOR) method returned same object as was passed instead of a new one", HvNAME (stash)); |
422 | croak ("%s::FREEZE(CBOR) method returned same object as was passed instead of a new one", HvNAME (stash)); |
412 | |
423 | |
413 | encode_tag (enc, CBOR_TAG_PERL_OBJECT); |
424 | encode_tag (enc, CBOR_TAG_PERL_OBJECT); |
414 | encode_uint (enc, 0x80, count + 1); |
425 | encode_uint (enc, 0x80, count + 1); |
415 | encode_str (enc, HvNAMEUTF8 (stash), HvNAME (stash), HvNAMELEN (stash)); |
426 | encode_strref (enc, HvNAMEUTF8 (stash), HvNAME (stash), HvNAMELEN (stash)); |
416 | |
427 | |
417 | while (count) |
428 | while (count) |
418 | encode_sv (enc, SP[1 - count--]); |
429 | encode_sv (enc, SP[1 - count--]); |
419 | |
430 | |
420 | PUTBACK; |
431 | PUTBACK; |
… | |
… | |
479 | |
490 | |
480 | if (SvPOKp (sv)) |
491 | if (SvPOKp (sv)) |
481 | { |
492 | { |
482 | STRLEN len; |
493 | STRLEN len; |
483 | char *str = SvPV (sv, len); |
494 | char *str = SvPV (sv, len); |
484 | encode_str (enc, SvUTF8 (sv), str, len); |
495 | encode_strref (enc, SvUTF8 (sv), str, len); |
485 | } |
496 | } |
486 | else if (SvNOKp (sv)) |
497 | else if (SvNOKp (sv)) |
487 | encode_nv (enc, sv); |
498 | encode_nv (enc, sv); |
488 | else if (SvIOKp (sv)) |
499 | else if (SvIOKp (sv)) |
489 | { |
500 | { |
… | |
… | |
515 | enc.cur = SvPVX (enc.sv); |
526 | enc.cur = SvPVX (enc.sv); |
516 | enc.end = SvEND (enc.sv); |
527 | enc.end = SvEND (enc.sv); |
517 | |
528 | |
518 | SvPOK_only (enc.sv); |
529 | SvPOK_only (enc.sv); |
519 | |
530 | |
520 | if (cbor->flags & F_DEDUP_STRINGS) |
531 | if (cbor->flags & F_PACK_STRINGS) |
521 | { |
532 | { |
522 | encode_tag (&enc, CBOR_TAG_STRINGREF_NAMESPACE); |
533 | encode_tag (&enc, CBOR_TAG_STRINGREF_NAMESPACE); |
523 | enc.stringref[0]= (HV *)sv_2mortal ((SV *)newHV ()); |
534 | enc.stringref[0]= (HV *)sv_2mortal ((SV *)newHV ()); |
524 | enc.stringref[1]= (HV *)sv_2mortal ((SV *)newHV ()); |
535 | enc.stringref[1]= (HV *)sv_2mortal ((SV *)newHV ()); |
525 | } |
536 | } |
… | |
… | |
547 | CBOR cbor; |
558 | CBOR cbor; |
548 | U32 depth; // recursion depth |
559 | U32 depth; // recursion depth |
549 | U32 maxdepth; // recursion depth limit |
560 | U32 maxdepth; // recursion depth limit |
550 | AV *shareable; |
561 | AV *shareable; |
551 | AV *stringref; |
562 | AV *stringref; |
|
|
563 | SV *decode_tagged; |
552 | } dec_t; |
564 | } dec_t; |
553 | |
565 | |
554 | #define ERR(reason) SB if (!dec->err) dec->err = reason; goto fail; SE |
566 | #define ERR(reason) SB if (!dec->err) dec->err = reason; goto fail; SE |
555 | |
567 | |
556 | #define WANT(len) if (ecb_expect_false (dec->cur + len > dec->end)) ERR ("unexpected end of CBOR data") |
568 | #define WANT(len) if (ecb_expect_false (dec->cur + len > dec->end)) ERR ("unexpected end of CBOR data") |
… | |
… | |
656 | decode_he (dec_t *dec, HV *hv) |
668 | decode_he (dec_t *dec, HV *hv) |
657 | { |
669 | { |
658 | // for speed reasons, we specialcase single-string |
670 | // for speed reasons, we specialcase single-string |
659 | // byte or utf-8 strings as keys, but only when !stringref |
671 | // byte or utf-8 strings as keys, but only when !stringref |
660 | |
672 | |
661 | if (expect_true (!dec->stringref)) |
673 | if (ecb_expect_true (!dec->stringref)) |
662 | if (*dec->cur >= 0x40 && *dec->cur <= 0x40 + 27) |
674 | if (*dec->cur >= 0x40 && *dec->cur <= 0x40 + 27) |
663 | { |
675 | { |
664 | I32 len = decode_uint (dec); |
676 | I32 len = decode_uint (dec); |
665 | char *key = (char *)dec->cur; |
677 | char *key = (char *)dec->cur; |
666 | |
678 | |
… | |
… | |
766 | STRLEN len = decode_uint (dec); |
778 | STRLEN len = decode_uint (dec); |
767 | |
779 | |
768 | WANT (len); |
780 | WANT (len); |
769 | sv = newSVpvn (dec->cur, len); |
781 | sv = newSVpvn (dec->cur, len); |
770 | dec->cur += len; |
782 | dec->cur += len; |
|
|
783 | |
|
|
784 | if (ecb_expect_false (dec->stringref) |
|
|
785 | && SvCUR (sv) >= minimum_string_length (AvFILLp (dec->stringref) + 1)) |
|
|
786 | av_push (dec->stringref, SvREFCNT_inc_NN (sv)); |
771 | } |
787 | } |
772 | |
788 | |
773 | if (utf8) |
789 | if (utf8) |
774 | SvUTF8_on (sv); |
790 | SvUTF8_on (sv); |
775 | |
|
|
776 | if (ecb_expect_false (dec->stringref) |
|
|
777 | && SvCUR (sv) >= minimum_string_length (AvFILLp (dec->stringref) + 1)) |
|
|
778 | av_push (dec->stringref, SvREFCNT_inc_NN (sv)); |
|
|
779 | |
791 | |
780 | return sv; |
792 | return sv; |
781 | |
793 | |
782 | fail: |
794 | fail: |
783 | SvREFCNT_dec (sv); |
795 | SvREFCNT_dec (sv); |
… | |
… | |
910 | |
922 | |
911 | default: |
923 | default: |
912 | { |
924 | { |
913 | sv = decode_sv (dec); |
925 | sv = decode_sv (dec); |
914 | |
926 | |
|
|
927 | dSP; |
|
|
928 | ENTER; SAVETMPS; PUSHMARK (SP); |
|
|
929 | EXTEND (SP, 2); |
|
|
930 | PUSHs (newSVuv (tag)); |
|
|
931 | PUSHs (sv); |
|
|
932 | |
|
|
933 | PUTBACK; |
|
|
934 | int count = call_sv (dec->cbor.filter ? dec->cbor.filter : default_filter, G_ARRAY | G_EVAL); |
|
|
935 | SPAGAIN; |
|
|
936 | |
|
|
937 | if (SvTRUE (ERRSV)) |
|
|
938 | { |
|
|
939 | FREETMPS; LEAVE; |
|
|
940 | ERR (SvPVutf8_nolen (sv_2mortal (SvREFCNT_inc (ERRSV)))); |
|
|
941 | } |
|
|
942 | |
|
|
943 | if (count) |
|
|
944 | { |
|
|
945 | SvREFCNT_dec (sv); |
|
|
946 | sv = SvREFCNT_inc (POPs); |
|
|
947 | } |
|
|
948 | else |
|
|
949 | { |
915 | AV *av = newAV (); |
950 | AV *av = newAV (); |
916 | av_push (av, newSVuv (tag)); |
951 | av_push (av, newSVuv (tag)); |
917 | av_push (av, sv); |
952 | av_push (av, sv); |
918 | |
953 | |
919 | HV *tagged_stash = !CBOR_SLOW || cbor_tagged_stash |
954 | HV *tagged_stash = !CBOR_SLOW || cbor_tagged_stash |
920 | ? cbor_tagged_stash |
955 | ? cbor_tagged_stash |
921 | : gv_stashpv ("CBOR::XS::Tagged" , 1); |
956 | : gv_stashpv ("CBOR::XS::Tagged" , 1); |
922 | |
|
|
923 | sv = sv_bless (newRV_noinc ((SV *)av), tagged_stash); |
957 | sv = sv_bless (newRV_noinc ((SV *)av), tagged_stash); |
|
|
958 | } |
|
|
959 | |
|
|
960 | PUTBACK; |
|
|
961 | |
|
|
962 | FREETMPS; LEAVE; |
924 | } |
963 | } |
925 | break; |
964 | break; |
926 | } |
965 | } |
927 | |
966 | |
928 | return sv; |
967 | return sv; |
… | |
… | |
1074 | |
1113 | |
1075 | types_true = get_bool ("Types::Serialiser::true" ); |
1114 | types_true = get_bool ("Types::Serialiser::true" ); |
1076 | types_false = get_bool ("Types::Serialiser::false"); |
1115 | types_false = get_bool ("Types::Serialiser::false"); |
1077 | types_error = get_bool ("Types::Serialiser::error"); |
1116 | types_error = get_bool ("Types::Serialiser::error"); |
1078 | |
1117 | |
|
|
1118 | default_filter = newSVpv ("CBOR::XS::default_filter", 0); |
|
|
1119 | |
1079 | sv_cbor = newSVpv ("CBOR", 0); |
1120 | sv_cbor = newSVpv ("CBOR", 0); |
1080 | SvREADONLY_on (sv_cbor); |
1121 | SvREADONLY_on (sv_cbor); |
1081 | } |
1122 | } |
1082 | |
1123 | |
1083 | PROTOTYPES: DISABLE |
1124 | PROTOTYPES: DISABLE |
… | |
… | |
1104 | void shrink (CBOR *self, int enable = 1) |
1145 | void shrink (CBOR *self, int enable = 1) |
1105 | ALIAS: |
1146 | ALIAS: |
1106 | shrink = F_SHRINK |
1147 | shrink = F_SHRINK |
1107 | allow_unknown = F_ALLOW_UNKNOWN |
1148 | allow_unknown = F_ALLOW_UNKNOWN |
1108 | allow_sharing = F_ALLOW_SHARING |
1149 | allow_sharing = F_ALLOW_SHARING |
1109 | dedup_strings = F_DEDUP_STRINGS |
1150 | pack_strings = F_PACK_STRINGS |
1110 | PPCODE: |
1151 | PPCODE: |
1111 | { |
1152 | { |
1112 | if (enable) |
1153 | if (enable) |
1113 | self->flags |= ix; |
1154 | self->flags |= ix; |
1114 | else |
1155 | else |
… | |
… | |
1120 | void get_shrink (CBOR *self) |
1161 | void get_shrink (CBOR *self) |
1121 | ALIAS: |
1162 | ALIAS: |
1122 | get_shrink = F_SHRINK |
1163 | get_shrink = F_SHRINK |
1123 | get_allow_unknown = F_ALLOW_UNKNOWN |
1164 | get_allow_unknown = F_ALLOW_UNKNOWN |
1124 | get_allow_sharing = F_ALLOW_SHARING |
1165 | get_allow_sharing = F_ALLOW_SHARING |
1125 | get_dedup_strings = F_DEDUP_STRINGS |
1166 | get_pack_strings = F_PACK_STRINGS |
1126 | PPCODE: |
1167 | PPCODE: |
1127 | XPUSHs (boolSV (self->flags & ix)); |
1168 | XPUSHs (boolSV (self->flags & ix)); |
1128 | |
1169 | |
1129 | void max_depth (CBOR *self, U32 max_depth = 0x80000000UL) |
1170 | void max_depth (CBOR *self, U32 max_depth = 0x80000000UL) |
1130 | PPCODE: |
1171 | PPCODE: |
… | |
… | |
1143 | XPUSHs (ST (0)); |
1184 | XPUSHs (ST (0)); |
1144 | |
1185 | |
1145 | int get_max_size (CBOR *self) |
1186 | int get_max_size (CBOR *self) |
1146 | CODE: |
1187 | CODE: |
1147 | RETVAL = self->max_size; |
1188 | RETVAL = self->max_size; |
|
|
1189 | OUTPUT: |
|
|
1190 | RETVAL |
|
|
1191 | |
|
|
1192 | void filter (CBOR *self, SV *filter = 0) |
|
|
1193 | PPCODE: |
|
|
1194 | SvREFCNT_dec (self->filter); |
|
|
1195 | self->filter = filter ? newSVsv (filter) : filter; |
|
|
1196 | XPUSHs (ST (0)); |
|
|
1197 | |
|
|
1198 | SV *get_filter (CBOR *self) |
|
|
1199 | CODE: |
|
|
1200 | RETVAL = self->filter ? self->filter : NEWSV (0, 0); |
1148 | OUTPUT: |
1201 | OUTPUT: |
1149 | RETVAL |
1202 | RETVAL |
1150 | |
1203 | |
1151 | void encode (CBOR *self, SV *scalar) |
1204 | void encode (CBOR *self, SV *scalar) |
1152 | PPCODE: |
1205 | PPCODE: |
… | |
… | |
1167 | EXTEND (SP, 2); |
1220 | EXTEND (SP, 2); |
1168 | PUSHs (sv); |
1221 | PUSHs (sv); |
1169 | PUSHs (sv_2mortal (newSVuv (offset - SvPVX (cborstr)))); |
1222 | PUSHs (sv_2mortal (newSVuv (offset - SvPVX (cborstr)))); |
1170 | } |
1223 | } |
1171 | |
1224 | |
|
|
1225 | void DESTROY (CBOR *self) |
|
|
1226 | PPCODE: |
|
|
1227 | cbor_free (self); |
|
|
1228 | |
1172 | PROTOTYPES: ENABLE |
1229 | PROTOTYPES: ENABLE |
1173 | |
1230 | |
1174 | void encode_cbor (SV *scalar) |
1231 | void encode_cbor (SV *scalar) |
1175 | PPCODE: |
1232 | PPCODE: |
1176 | { |
1233 | { |