From: Vincent Pit Date: Fri, 1 Jan 2010 16:52:28 +0000 (+0100) Subject: A minimial documentation X-Git-Tag: v0.01~22 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=dcefaa0f0b52b7ec82ad4fd5547d320a419ca1a9;p=perl%2Fmodules%2FSub-Op.git A minimial documentation --- diff --git a/Makefile.PL b/Makefile.PL index 35a3059..248c76f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -60,7 +60,7 @@ WriteMakefile( AUTHOR => 'Vincent Pit ', LICENSE => 'perl', VERSION_FROM => $file, -# ABSTRACT_FROM => $file, + ABSTRACT_FROM => $file, PL_FILES => {}, PREREQ_PM => \%PREREQ_PM, MIN_PERL_VERSION => 5.010, diff --git a/lib/Sub/Op.pm b/lib/Sub/Op.pm index 94cfe95..dbcdcd2 100644 --- a/lib/Sub/Op.pm +++ b/lib/Sub/Op.pm @@ -5,6 +5,16 @@ use 5.010; use strict; use warnings; +=head1 NAME + +Sub::Op - Install subroutines as opcodes. + +=head1 VERSION + +Version 0.01 + +=cut + our ($VERSION, @ISA); sub dl_load_flags { 0x01 } @@ -16,6 +26,74 @@ BEGIN { __PACKAGE__->bootstrap($VERSION); } +=head1 SYNOPSIS + +In your XS file : + + #include "sub_op.h" + + STATIC OP *scalar_util_reftype(pTHX) { + dSP; + dMARK; + SV *sv = POPs; + if (SvMAGICAL(sv)) + mg_get(sv); + if (SvROK(sv)) + PUSHs(sv_reftype(SvRV(sv), 0)); + else + PUSHs(&PL_sv_undef); + RETURN; + } + + MODULE = Scalar::Util::Ops PACKAGE = Scalar::Util::Ops + + BOOT: + { + sub_op_keyword k; + k.name = "reftype"; + k.len = sizeof("reftype")-1; + k.check = 0; + k.pp = scalar_util_reftype; + sub_op_register(aTHX_ &k); + } + +In your Perl module file : + + package Scalar::Util::Ops; + + use strict; + use warnings; + + our ($VERSION, @ISA); + + use Sub::Op; # Before loading our own shared library + + BEGIN { + $VERSION = '0.01'; + require DynaLoader; + push @ISA, 'DynaLoader'; + __PACKAGE__->bootstrap($VERSION); + } + + sub import { Sub::Op::enable(reftype => scalar caller) } + + sub unimport { Sub::Op::disable(reftype => scalar caller) } + + 1; + +In your F : + + use ExtUtils::Depends; + + my $ed = ExtUtils::Depends->new('Scalar::Util::Ops' => 'Sub::Op'); + + WriteMakefile( + $ed->get_makefile_vars, + ... + ); + +=cut + use B::Hooks::EndOfScope; use Variable::Magic 0.08; @@ -198,4 +276,46 @@ sub _inject { BEGIN { _monkeypatch() } +=head1 DEPENDENCIES + +L 5.10. + +L, L. + +L. + +=head1 SEE ALSO + +L. + +L. + +=head1 AUTHOR + +Vincent Pit, C<< >>, L. + +You can contact me by mail or on C (vincent). + +=head1 BUGS + +Please report any bugs or feature requests to C, or through the web interface at L. +I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. + +=head1 SUPPORT + +You can find documentation for this module with the perldoc command. + + perldoc Sub::Op + +Tests code coverage report is available at L. + +=head1 COPYRIGHT & LICENSE + +Copyright 2010 Vincent Pit, all rights reserved. + +This program is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + +=cut + 1; # End of Sub::Op