mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 13:02:13 +01:00
perl: added argument check
This commit is contained in:
parent
45321baa66
commit
0b3db48976
@ -136,7 +136,9 @@ static void _msgpack_pack_sv(enc_t *enc, SV* val) {
|
|||||||
|
|
||||||
XS(xs_pack) {
|
XS(xs_pack) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
PERL_UNUSED_VAR(items); /* TODO: check argument count */
|
if (items != 2) {
|
||||||
|
Perl_croak(aTHX_ "Usage: Data::MessagePack->pack($dat)");
|
||||||
|
}
|
||||||
|
|
||||||
SV* val = ST(1);
|
SV* val = ST(1);
|
||||||
|
|
||||||
|
@ -177,6 +177,10 @@ static void _reset(SV* self) {
|
|||||||
|
|
||||||
XS(xs_unpacker_new) {
|
XS(xs_unpacker_new) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
|
if (items != 1) {
|
||||||
|
Perl_croak(aTHX_ "Usage: Data::MessagePack::Unpacker->new()");
|
||||||
|
}
|
||||||
|
|
||||||
SV* self = sv_newmortal();
|
SV* self = sv_newmortal();
|
||||||
msgpack_unpack_t *mp;
|
msgpack_unpack_t *mp;
|
||||||
|
|
||||||
@ -218,17 +222,27 @@ static SV* _execute_impl(SV* self, SV* data, UV off, I32 limit) {
|
|||||||
|
|
||||||
XS(xs_unpacker_execute) {
|
XS(xs_unpacker_execute) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
|
if (items != 3) {
|
||||||
|
Perl_croak(aTHX_ "Usage: $unpacker->execute_limit(data, off)");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
SV* self = ST(0);
|
SV* self = ST(0);
|
||||||
SV* data = ST(1);
|
SV* data = ST(1);
|
||||||
IV off = SvIV(ST(2));
|
IV off = SvIV(ST(2));
|
||||||
|
|
||||||
ST(0) = _execute_impl(self, data, off, sv_len(data));
|
ST(0) = _execute_impl(self, data, off, sv_len(data));
|
||||||
|
}
|
||||||
|
|
||||||
XSRETURN(1);
|
XSRETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
XS(xs_unpacker_execute_limit) {
|
XS(xs_unpacker_execute_limit) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
|
if (items != 4) {
|
||||||
|
Perl_croak(aTHX_ "Usage: $unpacker->execute_limit(data, off, limit)");
|
||||||
|
}
|
||||||
|
|
||||||
SV* self = ST(0);
|
SV* self = ST(0);
|
||||||
SV* data = ST(1);
|
SV* data = ST(1);
|
||||||
IV off = SvIV(ST(2));
|
IV off = SvIV(ST(2));
|
||||||
@ -241,6 +255,9 @@ XS(xs_unpacker_execute_limit) {
|
|||||||
|
|
||||||
XS(xs_unpacker_is_finished) {
|
XS(xs_unpacker_is_finished) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
|
if (items != 1) {
|
||||||
|
Perl_croak(aTHX_ "Usage: $unpacker->is_finished()");
|
||||||
|
}
|
||||||
|
|
||||||
UNPACKER(ST(0), mp);
|
UNPACKER(ST(0), mp);
|
||||||
ST(0) = (mp->user.finished) ? &PL_sv_yes : &PL_sv_no;
|
ST(0) = (mp->user.finished) ? &PL_sv_yes : &PL_sv_no;
|
||||||
@ -250,6 +267,9 @@ XS(xs_unpacker_is_finished) {
|
|||||||
|
|
||||||
XS(xs_unpacker_data) {
|
XS(xs_unpacker_data) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
|
if (items != 1) {
|
||||||
|
Perl_croak(aTHX_ "Usage: $unpacker->data()");
|
||||||
|
}
|
||||||
|
|
||||||
UNPACKER(ST(0), mp);
|
UNPACKER(ST(0), mp);
|
||||||
ST(0) = template_data(mp);
|
ST(0) = template_data(mp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user