Commit | Line | Data |
adfe19db |
1 | ################################################################################ |
2 | ## |
bfc37ff7 |
3 | ## $Revision: 9 $ |
adfe19db |
4 | ## $Author: mhx $ |
bfc37ff7 |
5 | ## $Date: 2010/03/07 13:15:47 +0100 $ |
adfe19db |
6 | ## |
7 | ################################################################################ |
8 | ## |
bfc37ff7 |
9 | ## Version 3.x, Copyright (C) 2004-2010, Marcus Holland-Moritz. |
adfe19db |
10 | ## Version 2.x, Copyright (C) 2001, Paul Marquess. |
11 | ## Version 1.x, Copyright (C) 1999, Kenneth Albanowski. |
12 | ## |
13 | ## This program is free software; you can redistribute it and/or |
14 | ## modify it under the same terms as Perl itself. |
15 | ## |
16 | ################################################################################ |
17 | |
18 | =provides |
19 | |
20 | __UNDEFINED__ |
21 | |
22 | =implementation |
23 | |
24 | #ifdef USE_ITHREADS |
25 | |
26 | __UNDEFINED__ CopFILE(c) ((c)->cop_file) |
27 | __UNDEFINED__ CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) |
28 | __UNDEFINED__ CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) |
29 | __UNDEFINED__ CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) |
30 | __UNDEFINED__ CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) |
31 | __UNDEFINED__ CopSTASHPV(c) ((c)->cop_stashpv) |
32 | __UNDEFINED__ CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) |
33 | __UNDEFINED__ CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) |
34 | __UNDEFINED__ CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) |
35 | __UNDEFINED__ CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ |
36 | || (CopSTASHPV(c) && HvNAME(hv) \ |
37 | && strEQ(CopSTASHPV(c), HvNAME(hv))))) |
38 | |
39 | #else |
40 | |
41 | __UNDEFINED__ CopFILEGV(c) ((c)->cop_filegv) |
42 | __UNDEFINED__ CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) |
43 | __UNDEFINED__ CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) |
44 | __UNDEFINED__ CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) |
45 | __UNDEFINED__ CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) |
46 | __UNDEFINED__ CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) |
47 | __UNDEFINED__ CopSTASH(c) ((c)->cop_stash) |
48 | __UNDEFINED__ CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) |
49 | __UNDEFINED__ CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) |
50 | __UNDEFINED__ CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) |
51 | __UNDEFINED__ CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) |
52 | |
53 | #endif /* USE_ITHREADS */ |
54 | |
55 | =xsubs |
56 | |
57 | char * |
58 | CopSTASHPV() |
59 | CODE: |
60 | RETVAL = CopSTASHPV(PL_curcop); |
61 | OUTPUT: |
62 | RETVAL |
63 | |
64 | char * |
65 | CopFILE() |
66 | CODE: |
67 | RETVAL = CopFILE(PL_curcop); |
68 | OUTPUT: |
69 | RETVAL |
70 | |
71 | =tests plan => 2 |
72 | |
73 | my $package; |
74 | { |
75 | package MyPackage; |
76 | $package = &Devel::PPPort::CopSTASHPV(); |
77 | } |
78 | print "# $package\n"; |
79 | ok($package, "MyPackage"); |
80 | |
81 | my $file = &Devel::PPPort::CopFILE(); |
82 | print "# $file\n"; |
83 | ok($file =~ /cop/i); |
84 | |