File Coverage

include/oh_core.h
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 7 7 100.0


line stmt bran cond sub pod time code
1             /*
2             * oh_core.h -- private declarations shared between oh_core.c (the
3             * C implementation) and OrderedHash.xs (the XSUB layer).
4             *
5             * Public ABI lives in include/tie_orderedhash.h.
6             *
7             * Filename note: not "orderedhash.h" because xsubpp generates
8             * OrderedHash.c from OrderedHash.xs, and macOS's case-insensitive
9             * filesystem collapses "OrderedHash.c" and "orderedhash.c" into the
10             * same path.
11             */
12              
13             #ifndef TIE_ORDEREDHASH_PRIVATE_H
14             #define TIE_ORDEREDHASH_PRIVATE_H
15              
16             #include "EXTERN.h"
17             #include "perl.h"
18             #include "XSUB.h"
19              
20             #include "tie_orderedhash.h"
21              
22             #define TIE_OH_CLASS "Tie::OrderedHash"
23              
24             /* Resolve $self->[0..2] (idx HV, keys AV, values AV). Croaks if the
25             * SV doesn't look like one of our impl objects. $self->[3] (iter
26             * cursor) is fetched separately via oh_iter_cursor when needed -
27             * the FIRSTKEY/NEXTKEY path is the only consumer. */
28             void oh_resolve(pTHX_ SV *self,
29             HV **out_idx, AV **out_keys, AV **out_vals);
30              
31             /* Fast resolve: trusts that `self` is one of our impl objects.
32             * No type checks, no croaks. Called on hot paths from XSUBs that
33             * are reached only through tie magic dispatch on our class. */
34             PERL_STATIC_INLINE void
35 10195           oh_resolve_fast(pTHX_ SV *self, HV **out_idx, AV **out_keys, AV **out_vals)
36             {
37 10195           AV *av = (AV *)SvRV(self);
38 10195           SV **slots = AvARRAY(av);
39 10195           *out_idx = (HV *)SvRV(slots[0]);
40 10195           *out_keys = (AV *)SvRV(slots[1]);
41 10195           *out_vals = (AV *)SvRV(slots[2]);
42 10195           }
43              
44             /* Internal helpers used by the OO methods (Pop / Shift / Unshift /
45             * Push) but not part of the public C ABI. */
46             SV *oh_pop(pTHX_ SV *self, SV **out_key);
47             SV *oh_shift(pTHX_ SV *self, SV **out_key);
48             void oh_unshift_pair(pTHX_ SV *self, SV *key_sv, SV *val);
49             void oh_push_pair(pTHX_ SV *self, SV *key_sv, SV *val);
50              
51             /* $self->[3] iterator cursor accessors for FIRSTKEY/NEXTKEY. */
52             SSize_t oh_perl_iter_get(pTHX_ SV *self);
53             void oh_perl_iter_set(pTHX_ SV *self, SSize_t pos);
54              
55             #endif /* TIE_ORDEREDHASH_PRIVATE_H */