… | |
… | |
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 | // compatibility with perl <5.18 |
|
|
15 | #ifndef HvNAMELEN_get |
|
|
16 | # define HvNAMELEN_get(hv) strlen (HvNAME (hv)) |
|
|
17 | #endif |
|
|
18 | #ifndef HvNAMELEN |
|
|
19 | # define HvNAMELEN(hv) HvNAMELEN_get (hv) |
|
|
20 | #endif |
|
|
21 | #ifndef HvNAMEUTF8 |
|
|
22 | # define HvNAMEUTF8(hv) 0 |
|
|
23 | #endif |
13 | |
24 | |
14 | // known tags |
25 | // known tags |
15 | enum cbor_tag |
26 | enum cbor_tag |
16 | { |
27 | { |
17 | // inofficial extensions (pending iana registration) |
28 | // inofficial extensions (pending iana registration) |
… | |
… | |
980 | CODE: |
991 | CODE: |
981 | RETVAL = self->max_size; |
992 | RETVAL = self->max_size; |
982 | OUTPUT: |
993 | OUTPUT: |
983 | RETVAL |
994 | RETVAL |
984 | |
995 | |
985 | #if 0 //TODO |
|
|
986 | |
|
|
987 | void filter_cbor_object (CBOR *self, SV *cb = &PL_sv_undef) |
|
|
988 | PPCODE: |
|
|
989 | { |
|
|
990 | SvREFCNT_dec (self->cb_object); |
|
|
991 | self->cb_object = SvOK (cb) ? newSVsv (cb) : 0; |
|
|
992 | |
|
|
993 | XPUSHs (ST (0)); |
|
|
994 | } |
|
|
995 | |
|
|
996 | void filter_cbor_single_key_object (CBOR *self, SV *key, SV *cb = &PL_sv_undef) |
|
|
997 | PPCODE: |
|
|
998 | { |
|
|
999 | if (!self->cb_sk_object) |
|
|
1000 | self->cb_sk_object = newHV (); |
|
|
1001 | |
|
|
1002 | if (SvOK (cb)) |
|
|
1003 | hv_store_ent (self->cb_sk_object, key, newSVsv (cb), 0); |
|
|
1004 | else |
|
|
1005 | { |
|
|
1006 | hv_delete_ent (self->cb_sk_object, key, G_DISCARD, 0); |
|
|
1007 | |
|
|
1008 | if (!HvKEYS (self->cb_sk_object)) |
|
|
1009 | { |
|
|
1010 | SvREFCNT_dec (self->cb_sk_object); |
|
|
1011 | self->cb_sk_object = 0; |
|
|
1012 | } |
|
|
1013 | } |
|
|
1014 | |
|
|
1015 | XPUSHs (ST (0)); |
|
|
1016 | } |
|
|
1017 | |
|
|
1018 | #endif |
|
|
1019 | |
|
|
1020 | void encode (CBOR *self, SV *scalar) |
996 | void encode (CBOR *self, SV *scalar) |
1021 | PPCODE: |
997 | PPCODE: |
1022 | PUTBACK; scalar = encode_cbor (scalar, self); SPAGAIN; |
998 | PUTBACK; scalar = encode_cbor (scalar, self); SPAGAIN; |
1023 | XPUSHs (scalar); |
999 | XPUSHs (scalar); |
1024 | |
1000 | |
… | |
… | |
1036 | EXTEND (SP, 2); |
1012 | EXTEND (SP, 2); |
1037 | PUSHs (sv); |
1013 | PUSHs (sv); |
1038 | PUSHs (sv_2mortal (newSVuv (offset - SvPVX (cborstr)))); |
1014 | PUSHs (sv_2mortal (newSVuv (offset - SvPVX (cborstr)))); |
1039 | } |
1015 | } |
1040 | |
1016 | |
1041 | #if 0 |
|
|
1042 | |
|
|
1043 | void DESTROY (CBOR *self) |
|
|
1044 | CODE: |
|
|
1045 | SvREFCNT_dec (self->cb_sk_object); |
|
|
1046 | SvREFCNT_dec (self->cb_object); |
|
|
1047 | |
|
|
1048 | #endif |
|
|
1049 | |
|
|
1050 | PROTOTYPES: ENABLE |
1017 | PROTOTYPES: ENABLE |
1051 | |
1018 | |
1052 | void encode_cbor (SV *scalar) |
1019 | void encode_cbor (SV *scalar) |
1053 | PPCODE: |
1020 | PPCODE: |
1054 | { |
1021 | { |