XS::MagicExt - Provides PERL_MAGIC_ext manipulators for XS modules
This document describes XS::MagicExt version 0.05.
# in Makefile.PL requires_xs 'XS::MagicExt'; # done by Module::Install::XSUtil # in YourModule.pm use XS::MagicExt; /* Then, in YourModule.xs */ #include "magic_ext.h" static MGVTBL id; /* ... */ void foo(pTHX_ SV* sv){ SV* obj = newSViv(42); /* ... */ mg = mgx_attach(sv, &id, obj); mg = mgx_find(sv, &id); mg = MGX_FIND(sv, &id); mg = mgx_get(sv, &id); if(SvOK(MG_obj(mg))){ /* ... */ } mgx_detach(sv, &id); }
XS::MagicExt provides MAGIC manipulators for XS modules.
MAGIC manipulators are an interface to sv_magicext(), mg_find(), and sv_unmagic(), which distinguish magic identities from others' MAGICs by MGVTBL.
sv_magicext()
mg_find()
sv_unmagic()
MGVTBL
Attaches a MAGIC identified by id to sv with obj and ptr / len.
Similar to sv_magicext(sv, obj, PERL_MAGIC_ext, id, ptr, len), but does not increase the refcount of obj.
sv_magicext(sv, obj, PERL_MAGIC_ext, id, ptr, len)
Attaches a MAGIC identified by id to sv with obj and data, not increasing the refcount of data.
The same as mgx_attach_with_ptr(sv, id, obj, (SV*)ptr, HEf_SVKEY).
mgx_attach_with_ptr(sv, id, obj, (SV*)ptr, HEf_SVKEY)
Attaches a MAGIC identified by id to sv with obj.
The same as mgx_attach_with_ptr(sv, id, obj, NULL, 0).
mgx_attach_with_ptr(sv, id, obj, NULL, 0)
Finds a MAGIC identified by id.
If not found, it will return NULL.
If not found, it will die.
Removes all the MAGICs identified by id.
Checks if sv has any MAGICs, and finds a MAGIC like mgx_find().
mgx_find()
The same as mg->mg_obj.
mg->mg_obj
The same as mg->mg_private.
mg->mg_private
The same as mg->mg_ptr.
mg->mg_ptr
The same as mg->mg_len.
mg->mg_len
The same as (void*)mg->mg_ptr.
(void*)mg->mg_ptr
The same as (SV*)mg->mg_ptr.
(SV*)mg->mg_ptr
MG_len(mg) must be HEf_SVKEY.
MG_len(mg)
HEf_SVKEY
Sets sv to MG_sv(mg), and MG_len(mg) = HEf_SVKEY.
MG_sv(mg)
MG_len(mg) = HEf_SVKEY
The same as MG_len(mg) == HEf_SVKEY.
MG_len(mg) == HEf_SVKEY
Perl 5.8.1 or later, and a C compiler.
No bugs have been reported.
Please report any bugs or feature requests to the author.
magic_ext.h.
perlapi.
perlguts.
sv.c.
mg.h.
mg.c.
Module::Install::XSUtil.
Goro Fuji (gfx) <gfuji(at)cpan.org>.
Copyright (c) 2009, Goro Fuji (gfx). Some rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install XS::MagicExt, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XS::MagicExt
CPAN shell
perl -MCPAN -e shell install XS::MagicExt
For more information on module installation, please visit the detailed CPAN module installation guide.