X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlguts.pod;h=e8898765a8000e22c9e3d2144a85da8039b0eb0f;hb=6e0733998eff7a098d2d21d5602f3eb2a7521e1f;hp=3a40e683b2b3032ca6bc899ca4fac63c697f72c1;hpb=2575c402a8f9be55f848bdfb219afbf912c50ac1;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlguts.pod b/pod/perlguts.pod index 3a40e68..e889876 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -191,7 +191,7 @@ have "magic". See L later in this document. If you know the name of a scalar variable, you can get a pointer to its SV by using the following: - SV* get_sv("package::varname", FALSE); + SV* get_sv("package::varname", 0); This returns NULL if the variable does not exist. @@ -367,7 +367,7 @@ then nothing is done. If you know the name of an array variable, you can get a pointer to its AV by using the following: - AV* get_av("package::varname", FALSE); + AV* get_av("package::varname", 0); This returns NULL if the variable does not exist. @@ -442,7 +442,7 @@ specified below. If you know the name of a hash variable, you can get a pointer to its HV by using the following: - HV* get_hv("package::varname", FALSE); + HV* get_hv("package::varname", 0); This returns NULL if the variable does not exist. @@ -600,7 +600,7 @@ The most useful types that will be returned are: SVt_PVGV Glob (possible a file handle) SVt_PVMG Blessed or Magical Scalar - See the sv.h header file for more details. +See the F header file for more details. =head2 Blessed References and Class Objects @@ -667,9 +667,9 @@ to write: To create a new Perl variable with an undef value which can be accessed from your Perl script, use the following routines, depending on the variable type. - SV* get_sv("package::varname", TRUE); - AV* get_av("package::varname", TRUE); - HV* get_hv("package::varname", TRUE); + SV* get_sv("package::varname", GV_ADD); + AV* get_av("package::varname", GV_ADD); + HV* get_hv("package::varname", GV_ADD); Notice the use of TRUE as the second parameter. The new variable can now be set, using the routines appropriate to the data type. @@ -878,7 +878,7 @@ following code: extern int dberror; extern char *dberror_list; - SV* sv = get_sv("dberror", TRUE); + SV* sv = get_sv("dberror", GV_ADD); sv_setiv(sv, (IV) dberror); sv_setpv(sv, dberror_list[dberror]); SvIOK_on(sv); @@ -901,9 +901,9 @@ linked list of C's, typedef'ed to C. U16 mg_private; char mg_type; U8 mg_flags; + I32 mg_len; SV* mg_obj; char* mg_ptr; - I32 mg_len; }; Note this is current as of patchlevel 0, and could change at any time. @@ -979,7 +979,7 @@ routine types: int (*svt_clear)(SV* sv, MAGIC* mg); int (*svt_free)(SV* sv, MAGIC* mg); - int (*svt_copy)(SV *sv, MAGIC* mg, SV *nsv, const char *name, int namlen); + int (*svt_copy)(SV *sv, MAGIC* mg, SV *nsv, const char *name, I32 namlen); int (*svt_dup)(MAGIC *mg, CLONE_PARAMS *param); int (*svt_local)(SV *nsv, MAGIC *mg); @@ -994,12 +994,12 @@ actions depending on which function is being called. svt_get Do something before the value of the SV is retrieved. svt_set Do something after the SV is assigned a value. svt_len Report on the SV's length. - svt_clear Clear something the SV represents. + svt_clear Clear something the SV represents. svt_free Free any extra storage associated with the SV. - svt_copy copy tied variable magic to a tied element - svt_dup duplicate a magic structure during thread cloning - svt_local copy magic to local value during 'local' + svt_copy copy tied variable magic to a tied element + svt_dup duplicate a magic structure during thread cloning + svt_local copy magic to local value during 'local' For instance, the MGVTBL structure called C (which corresponds to an C of C) contains: @@ -1022,53 +1022,52 @@ to change. The current kinds of Magic Virtual Tables are: mg_type - (old-style char and macro) MGVTBL Type of magic - -------------------------- ------ ---------------------------- - \0 PERL_MAGIC_sv vtbl_sv Special scalar variable - A PERL_MAGIC_overload vtbl_amagic %OVERLOAD hash + (old-style char and macro) MGVTBL Type of magic + -------------------------- ------ ------------- + \0 PERL_MAGIC_sv vtbl_sv Special scalar variable + A PERL_MAGIC_overload vtbl_amagic %OVERLOAD hash a PERL_MAGIC_overload_elem vtbl_amagicelem %OVERLOAD hash element - c PERL_MAGIC_overload_table (none) Holds overload table (AMT) - on stash - B PERL_MAGIC_bm vtbl_bm Boyer-Moore (fast string search) - D PERL_MAGIC_regdata vtbl_regdata Regex match position data - (@+ and @- vars) - d PERL_MAGIC_regdatum vtbl_regdatum Regex match position data - element - E PERL_MAGIC_env vtbl_env %ENV hash - e PERL_MAGIC_envelem vtbl_envelem %ENV hash element - f PERL_MAGIC_fm vtbl_fm Formline ('compiled' format) - g PERL_MAGIC_regex_global vtbl_mglob m//g target / study()ed string - H PERL_MAGIC_hints vtbl_sig %^H hash - h PERL_MAGIC_hintselem vtbl_hintselem %^H hash element - I PERL_MAGIC_isa vtbl_isa @ISA array - i PERL_MAGIC_isaelem vtbl_isaelem @ISA array element - k PERL_MAGIC_nkeys vtbl_nkeys scalar(keys()) lvalue - L PERL_MAGIC_dbfile (none) Debugger %_ is one of a number of macros (in perl.h) that hide the +C is one of a number of macros (in F) that hide the details of the interpreter's context. THX stands for "thread", "this", or "thingy", as the case may be. (And no, George Lucas is not involved. :-) The first character could be 'p' for a B

rototype, 'a' for Brgument, @@ -2029,7 +2028,7 @@ built with PERL_IMPLICIT_CONTEXT enabled. There are three ways to do this. First, the easy but inefficient way, which is also the default, in order to maintain source compatibility -with extensions: whenever XSUB.h is #included, it redefines the aTHX +with extensions: whenever F is #included, it redefines the aTHX and aTHX_ macros to call a function that will return the context. Thus, something like: @@ -2056,9 +2055,9 @@ your Foo.xs: #include "perl.h" #include "XSUB.h" - static my_private_function(int arg1, int arg2); + STATIC void my_private_function(int arg1, int arg2); - static SV * + STATIC void my_private_function(int arg1, int arg2) { dTHX; /* fetch context */ @@ -2096,9 +2095,9 @@ the Perl guts: #include "XSUB.h" /* pTHX_ only needed for functions that call Perl API */ - static my_private_function(pTHX_ int arg1, int arg2); + STATIC void my_private_function(pTHX_ int arg1, int arg2); - static SV * + STATIC void my_private_function(pTHX_ int arg1, int arg2) { /* dTHX; not needed here, because THX is an argument */ @@ -2166,7 +2165,7 @@ This allows the ability to provide an extra pointer (called the "host" environment) for all the system calls. This makes it possible for all the system stuff to maintain their own state, broken down into seven C structures. These are thin wrappers around the usual system -calls (see win32/perllib.c) for the default perl executable, but for a +calls (see F) for the default perl executable, but for a more ambitious host (like the one that would do fork() emulation) all the extra work needed to pretend that different interpreters are actually different "processes", would be done here. @@ -2611,9 +2610,7 @@ you can use C<*s = uv>. =item * Mixing UTF-8 and non-UTF-8 strings is tricky. Use C to get -a new string which is UTF-8 encoded. There are tricks you can use to -delay deciding whether you need to use a UTF-8 string until you get to a -high character - C is one of those. +a new string which is UTF-8 encoded, and then combine them. =back