From 818958abaf7ad4f86101f88e74caf688b23be9a3 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 10 Jul 2013 14:17:52 -0400 Subject: initial (non-working) implementation --- Lexical.xs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Lexical.xs (limited to 'Lexical.xs') diff --git a/Lexical.xs b/Lexical.xs new file mode 100644 index 0000000..1ae3923 --- /dev/null +++ b/Lexical.xs @@ -0,0 +1,26 @@ +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +MODULE = Exporter::Lexical PACKAGE = Exporter::Lexical + +PROTOTYPES: DISABLE + +void +lexical_import(SV *name, CV *cv) + CODE: + PADLIST *pl; + PADOFFSET off; + if (!PL_compcv) + Perl_croak(aTHX_ + "lexical_import can only be called at compile time"); + pl = CvPADLIST(PL_compcv); + ENTER; + SAVESPTR(PL_comppad_name); PL_comppad_name = PadlistNAMES(pl); + SAVESPTR(PL_comppad); PL_comppad = PadlistARRAY(pl)[1]; + SAVESPTR(PL_curpad); PL_curpad = PadARRAY(PL_comppad); + off = pad_add_name_sv(sv_2mortal(newSVpvf("&%"SVf,name)), + padadd_STATE, 0, 0); + SvREFCNT_dec(PL_curpad[off]); + PL_curpad[off] = SvREFCNT_inc(cv); + LEAVE; -- cgit v1.2.3-54-g00ecf