Commit | Line | Data |
a0d0e21e |
1 | /* mg.h |
79072805 |
2 | * |
4bb101f2 |
3 | * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, |
4 | * 2000, 2002, by Larry Wall and others |
79072805 |
5 | * |
6 | * You may distribute under the terms of either the GNU General Public |
7 | * License or the Artistic License, as specified in the README file. |
8 | * |
79072805 |
9 | */ |
10 | |
0f4eea8f |
11 | #ifdef STRUCT_MGVTBL_DEFINITION |
12 | STRUCT_MGVTBL_DEFINITION; |
13 | #else |
79072805 |
14 | struct mgvtbl { |
cea2e8a9 |
15 | int (CPERLscope(*svt_get)) (pTHX_ SV *sv, MAGIC* mg); |
16 | int (CPERLscope(*svt_set)) (pTHX_ SV *sv, MAGIC* mg); |
17 | U32 (CPERLscope(*svt_len)) (pTHX_ SV *sv, MAGIC* mg); |
18 | int (CPERLscope(*svt_clear))(pTHX_ SV *sv, MAGIC* mg); |
19 | int (CPERLscope(*svt_free)) (pTHX_ SV *sv, MAGIC* mg); |
68795e93 |
20 | int (CPERLscope(*svt_copy)) (pTHX_ SV *sv, MAGIC* mg, |
21 | SV *nsv, const char *name, int namlen); |
22 | int (CPERLscope(*svt_dup)) (pTHX_ MAGIC *mg, CLONE_PARAMS *param); |
79072805 |
23 | }; |
0f4eea8f |
24 | #endif |
79072805 |
25 | |
26 | struct magic { |
27 | MAGIC* mg_moremagic; |
28 | MGVTBL* mg_virtual; /* pointer to magic functions */ |
29 | U16 mg_private; |
30 | char mg_type; |
31 | U8 mg_flags; |
32 | SV* mg_obj; |
33 | char* mg_ptr; |
565764a8 |
34 | I32 mg_len; |
79072805 |
35 | }; |
8990e307 |
36 | |
cb50f42d |
37 | #define MGf_TAINTEDDIR 1 /* PERL_MAGIC_envelem only */ |
38 | #define MGf_MINMATCH 1 /* PERL_MAGIC_regex_global only */ |
85e6fe83 |
39 | #define MGf_REFCOUNTED 2 |
a0d0e21e |
40 | #define MGf_GSKIP 4 |
68795e93 |
41 | #define MGf_COPY 8 |
42 | #define MGf_DUP 16 |
748a9306 |
43 | |
1e422769 |
44 | #define MgTAINTEDDIR(mg) (mg->mg_flags & MGf_TAINTEDDIR) |
45 | #define MgTAINTEDDIR_on(mg) (mg->mg_flags |= MGf_TAINTEDDIR) |
46 | #define MgTAINTEDDIR_off(mg) (mg->mg_flags &= ~MGf_TAINTEDDIR) |
99069129 |
47 | |
32da55ab |
48 | #define MgPV(mg,lp) ((((int)(lp = (mg)->mg_len)) == HEf_SVKEY) ? \ |
5aabfad6 |
49 | SvPV((SV*)((mg)->mg_ptr),lp) : \ |
50 | (mg)->mg_ptr) |
33c27489 |
51 | |
52 | #define SvTIED_mg(sv,how) \ |
53 | (SvRMAGICAL(sv) ? mg_find((sv),(how)) : Null(MAGIC*)) |
54 | #define SvTIED_obj(sv,mg) \ |
55 | ((mg)->mg_obj ? (mg)->mg_obj : sv_2mortal(newRV(sv))) |