perl - What is RMAGICAL? -


i'm trying understand xs code inherited. i've been trying add comments section invokes perl magic stuff, can't find documentation me understand line:

svrmagical_off((sv *) myvar); 

what rmagical for? when should 1 turn in on or off when working perl magic variables?

update

perlguts illustrated interesting , has little bit of info on rmagical (the 'r' 'random'), doesn't when mess it: http://cpansearch.perl.org/src/rurban/illguts-0.42/index.html

it's flag indicates whether variable has "clear" magic, magic should called when variable cleared (e.g. when it's destroyed). it's used mg_clear called when 1 attempts like

undef %hash; delete $a[4]; etc 

it's derived information calculated mg_magical should never touched. mg_magical called update flag when magic added or removed variable. if of magic attached scalar has "clear" handler in magic virtual table, scalar gets rmagical set. otherwise, gets turned off. effectively, caches information save perl repeatedly checking magic attached scalar information.

one example use of clear magic: when %sig entry cleared, magic removes signal handler signal.


here's mg_magical:

void perl_mg_magical(pthx_ sv *sv) {     const magic* mg;     perl_args_assert_mg_magical;     perl_unused_context;      svmagical_off(sv);     if ((mg = svmagic(sv))) {         {             const mgvtbl* const vtbl = mg->mg_virtual;             if (vtbl) {                 if (vtbl->svt_get && !(mg->mg_flags & mgf_gskip))                     svgmagical_on(sv);                 if (vtbl->svt_set)                     svsmagical_on(sv);                 if (vtbl->svt_clear)                     svrmagical_on(sv);             }         } while ((mg = mg->mg_moremagic));         if (!(svflags(sv) & (svs_gmg|svs_smg)))             svrmagical_on(sv);     } } 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -