diff options
author | David Mitchell <davem@iabyn.com> | 2017-01-18 12:35:50 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-01-21 10:04:44 +0000 |
commit | 1e85b6586ab5aca2ff20296114f8e70b45956a92 (patch) | |
tree | a9e404be66ca10a1189d38a66705702e15c4111d /op.h | |
parent | f5294d12c0aa55a61680444556e53554d881d9b0 (diff) | |
download | perl-1e85b6586ab5aca2ff20296114f8e70b45956a92.tar.gz |
add Perl_op_class(o) API function
Given an op, this function determines what type of struct it has been
allocated as. Returns one of the OPclass enums, such as OPclass_LISTOP.
Originally this was a static function in B.xs, but it has wider
applicability; indeed several XS modules on CPAN have cut and pasted it.
It adds the OPclass enum to op.h. In B.xs there was a similar enum, but
with names like OPc_LISTOP. I've renamed them to OPclass_LISTOP etc. so as
not to clash with the cut+paste code already on CPAN.
Diffstat (limited to 'op.h')
-rw-r--r-- | op.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -475,6 +475,24 @@ struct loop { #define kLOOP cLOOPx(kid) +typedef enum { + OPclass_NULL, /* 0 */ + OPclass_BASEOP, /* 1 */ + OPclass_UNOP, /* 2 */ + OPclass_BINOP, /* 3 */ + OPclass_LOGOP, /* 4 */ + OPclass_LISTOP, /* 5 */ + OPclass_PMOP, /* 6 */ + OPclass_SVOP, /* 7 */ + OPclass_PADOP, /* 8 */ + OPclass_PVOP, /* 9 */ + OPclass_LOOP, /* 10 */ + OPclass_COP, /* 11 */ + OPclass_METHOP, /* 12 */ + OPclass_UNOP_AUX /* 13 */ +} OPclass; + + #ifdef USE_ITHREADS # define cGVOPx_gv(o) ((GV*)PAD_SVl(cPADOPx(o)->op_padix)) # ifndef PERL_CORE |