From: Quim Rovira Date: Wed, 17 Aug 2016 10:37:19 +0000 (+0200) Subject: Merge pull request #1 from avar/master X-Git-Tag: 0.002~14 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=00ae8d0fa1b1a86190cf9229db8e5d0d860c1871;hp=498a11cd399820ed3546a3d6721b3bc50592f023;p=io-compress-brotli.git Merge pull request #1 from avar/master Migrate 3 functions in the *.pm to *.xs --- diff --git a/Brotli.xs b/Brotli.xs index dff0a63..c28e36c 100644 --- a/Brotli.xs +++ b/Brotli.xs @@ -199,6 +199,85 @@ _mode(self, mode) OUTPUT: RETVAL +SV* +compress(self, in) + IO::Compress::Brotli self + SV* in + CODE: + ENTER; + SAVETMPS; + + PUSHMARK(SP); + XPUSHs(ST(0)); + XPUSHs(in); + XPUSHs(newSVuv(BROTLI_OPERATION_PROCESS)); + PUTBACK; + + call_method("_compress", G_SCALAR); + + SPAGAIN; + + RETVAL = POPs; + SvREFCNT_inc(RETVAL); + + PUTBACK; + FREETMPS; + LEAVE; + OUTPUT: + RETVAL + +SV* +flush(self) + IO::Compress::Brotli self + CODE: + ENTER; + SAVETMPS; + + PUSHMARK(SP); + XPUSHs(ST(0)); + XPUSHs(newSVpv("", 0)); + XPUSHs(newSVuv(BROTLI_OPERATION_FLUSH)); + PUTBACK; + + call_method("_compress", G_SCALAR); + + SPAGAIN; + + RETVAL = POPs; + SvREFCNT_inc(RETVAL); + + PUTBACK; + FREETMPS; + LEAVE; + OUTPUT: + RETVAL + +SV* +finish(self) + IO::Compress::Brotli self + CODE: + ENTER; + SAVETMPS; + + PUSHMARK(SP); + XPUSHs(ST(0)); + XPUSHs(newSVpv("", 0)); + XPUSHs(newSVuv(BROTLI_OPERATION_FINISH)); + PUTBACK; + + call_method("_compress", G_SCALAR); + + SPAGAIN; + + RETVAL = POPs; + SvREFCNT_inc(RETVAL); + + PUTBACK; + FREETMPS; + LEAVE; + OUTPUT: + RETVAL + SV* _compress(self, in, op) IO::Compress::Brotli self diff --git a/lib/IO/Compress/Brotli.pm b/lib/IO/Compress/Brotli.pm index 694a04b..a41c09b 100644 --- a/lib/IO/Compress/Brotli.pm +++ b/lib/IO/Compress/Brotli.pm @@ -23,25 +23,6 @@ sub mode { _mode($$self, $mode) } -use constant { - BROTLI_OPERATION_PROCESS => 0, - BROTLI_OPERATION_FLUSH => 1, - BROTLI_OPERATION_FINISH => 2 -}; -sub compress { - my ($self, $data) = @_; - $self->_compress($data, BROTLI_OPERATION_PROCESS ) -} - -sub flush { - my ($self) = @_; - $self->_compress('', BROTLI_OPERATION_FLUSH ) -} - -sub finish { - my ($self) = @_; - $self->_compress('', BROTLI_OPERATION_FINISH ) -} 1; __END__