| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
STATIC MGVTBL null_mg_vtbl = { |
|
2
|
|
|
|
|
|
|
NULL, /* get */ |
|
3
|
|
|
|
|
|
|
NULL, /* set */ |
|
4
|
|
|
|
|
|
|
NULL, /* len */ |
|
5
|
|
|
|
|
|
|
NULL, /* clear */ |
|
6
|
|
|
|
|
|
|
NULL, /* free */ |
|
7
|
|
|
|
|
|
|
#if MGf_COPY |
|
8
|
|
|
|
|
|
|
NULL, /* copy */ |
|
9
|
|
|
|
|
|
|
#endif /* MGf_COPY */ |
|
10
|
|
|
|
|
|
|
#if MGf_DUP |
|
11
|
|
|
|
|
|
|
NULL, /* dup */ |
|
12
|
|
|
|
|
|
|
#endif /* MGf_DUP */ |
|
13
|
|
|
|
|
|
|
#if MGf_LOCAL |
|
14
|
|
|
|
|
|
|
NULL, /* local */ |
|
15
|
|
|
|
|
|
|
#endif /* MGf_LOCAL */ |
|
16
|
|
|
|
|
|
|
}; |
|
17
|
|
|
|
|
|
|
|
|
18
|
5
|
|
|
|
|
|
void xs_object_magic_attach_struct (pTHX_ SV *sv, void *ptr) { |
|
19
|
5
|
|
|
|
|
|
sv_magicext(sv, NULL, PERL_MAGIC_ext, &null_mg_vtbl, ptr, 0 ); |
|
20
|
5
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
5
|
|
|
|
|
|
SV *xs_object_magic_create (pTHX_ void *ptr, HV *stash) { |
|
23
|
5
|
|
|
|
|
|
HV *hv = newHV(); |
|
24
|
5
|
|
|
|
|
|
SV *obj = newRV_noinc((SV *)hv); |
|
25
|
|
|
|
|
|
|
|
|
26
|
5
|
|
|
|
|
|
sv_bless(obj, stash); |
|
27
|
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
|
xs_object_magic_attach_struct(aTHX_ (SV *)hv, ptr); |
|
29
|
|
|
|
|
|
|
|
|
30
|
5
|
|
|
|
|
|
return obj; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
251
|
|
|
|
|
|
STATIC MAGIC *xs_object_magic_get_mg (pTHX_ SV *sv) { |
|
34
|
|
|
|
|
|
|
MAGIC *mg; |
|
35
|
|
|
|
|
|
|
|
|
36
|
251
|
50
|
|
|
|
|
if (SvTYPE(sv) >= SVt_PVMG) { |
|
37
|
251
|
50
|
|
|
|
|
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) { |
|
38
|
251
|
|
|
|
|
|
if ( |
|
39
|
251
|
50
|
|
|
|
|
(mg->mg_type == PERL_MAGIC_ext) |
|
40
|
251
|
|
|
|
|
|
&& |
|
41
|
251
|
50
|
|
|
|
|
(mg->mg_virtual == &null_mg_vtbl) |
|
42
|
|
|
|
|
|
|
) { |
|
43
|
251
|
|
|
|
|
|
return mg; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return NULL; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
void *xs_object_magic_get_struct (pTHX_ SV *sv) { |
|
52
|
0
|
|
|
|
|
|
MAGIC *mg = xs_object_magic_get_mg(aTHX_ sv); |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if ( mg ) |
|
55
|
0
|
|
|
|
|
|
return mg->mg_ptr; |
|
56
|
|
|
|
|
|
|
else |
|
57
|
|
|
|
|
|
|
return NULL; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
251
|
|
|
|
|
|
void *xs_object_magic_get_struct_rv_pretty (pTHX_ SV *sv, const char *name) { |
|
61
|
251
|
50
|
|
|
|
|
if ( sv && SvROK(sv) ) { |
|
|
|
50
|
|
|
|
|
|
|
62
|
251
|
|
|
|
|
|
MAGIC *mg = xs_object_magic_get_mg(aTHX_ SvRV(sv)); |
|
63
|
|
|
|
|
|
|
|
|
64
|
251
|
50
|
|
|
|
|
if ( mg ) |
|
65
|
251
|
|
|
|
|
|
return mg->mg_ptr; |
|
66
|
|
|
|
|
|
|
else |
|
67
|
0
|
|
|
|
|
|
croak("%s does not have a struct associated with it", name); |
|
68
|
|
|
|
|
|
|
} else { |
|
69
|
0
|
|
|
|
|
|
croak("%s is not a reference", name); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
void *xs_object_magic_get_struct_rv (pTHX_ SV *sv) { |
|
74
|
0
|
|
|
|
|
|
return xs_object_magic_get_struct_rv_pretty(aTHX_ sv, "argument"); |
|
75
|
|
|
|
|
|
|
} |