summaryrefslogtreecommitdiff
path: root/sv.h
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2023-02-04 00:27:00 +0000
committerPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2023-02-10 12:07:02 +0000
commit24c33697796a1556af3f58e15fc4fb6b0d1538dc (patch)
treef747d7bdf730b423528f6d960db2465f9c708d4e /sv.h
parent99b497aa90ed7db99d29a301b47c91fba65c9cb3 (diff)
downloadperl-24c33697796a1556af3f58e15fc4fb6b0d1538dc.tar.gz
Create a specific SV type for object instances
Diffstat (limited to 'sv.h')
-rw-r--r--sv.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/sv.h b/sv.h
index c296dcc6e7..9c2370196c 100644
--- a/sv.h
+++ b/sv.h
@@ -38,9 +38,11 @@ The types are:
SVt_PVCV
SVt_PVFM
SVt_PVIO
+ SVt_PVOBJ
These are most easily explained from the bottom up.
+C<SVt_PVOBJ> is for object instances of the new `use feature 'class'` kind.
C<SVt_PVIO> is for I/O objects, C<SVt_PVFM> for formats, C<SVt_PVCV> for
subroutines, C<SVt_PVHV> for hashes and C<SVt_PVAV> for arrays.
@@ -120,6 +122,9 @@ Type flag for formats. See L</svtype>.
=for apidoc AmnU||SVt_PVIO
Type flag for I/O objects. See L</svtype>.
+=for apidoc AmnUx||SVt_PVOBJ
+Type flag for object instances. See L</svtype>.
+
=cut
These are ordered so that the simpler types have a lower value; SvUPGRADE
@@ -149,7 +154,8 @@ typedef enum {
SVt_PVCV, /* 13 */
SVt_PVFM, /* 14 */
SVt_PVIO, /* 15 */
- /* 16-31: Unused, though one should be reserved for a
+ SVt_PVOBJ, /* 16 */
+ /* 17-31: Unused, though one should be reserved for a
* freed sv, if the other 3 bits below the flags ones
* get allocated */
SVt_LAST /* keep last in enum. used to size arrays */
@@ -273,6 +279,11 @@ struct invlist {
_SV_HEAD_UNION;
};
+struct object {
+ _SV_HEAD(XPVOBJ*); /* pointer to xobject body */
+ _SV_HEAD_UNION;
+};
+
#undef _SV_HEAD
#undef _SV_HEAD_UNION /* ensure no pollution */
@@ -667,6 +678,18 @@ struct xpvio {
#define IOf_FAKE_DIRP 64 /* xio_dirp is fake (source filters kludge)
Also, when this is set, SvPVX() is valid */
+struct xobject {
+ HV* xmg_stash;
+ union _xmgu xmg_u;
+ SSize_t xobject_maxfield;
+ SSize_t xobject_iter_sv_at; /* this is only used by Perl_sv_clear() */
+ SV** xobject_fields;
+};
+
+#define ObjectMAXFIELD(inst) ((XPVOBJ *)SvANY(inst))->xobject_maxfield
+#define ObjectITERSVAT(inst) ((XPVOBJ *)SvANY(inst))->xobject_iter_sv_at
+#define ObjectFIELDS(inst) ((XPVOBJ *)SvANY(inst))->xobject_fields
+
/* The following macros define implementation-independent predicates on SVs. */
/*