1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-04 02:51:31 -08:00

Using common code for class getters and setters.

Copied from Perforce
 Change: 190836
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Richard Brooksby 2016-04-08 18:33:34 +01:00
parent c92bf9505a
commit fc269fd07a
2 changed files with 35 additions and 19 deletions

View file

@ -290,8 +290,8 @@ extern PoolDebugMixin PoolNoDebugMixin(Pool pool);
extern BufferClass PoolNoBufferClass(void);
extern Size PoolNoSize(Pool pool);
#define ClassOfPool(pool) ((PoolClass)(pool)->instStruct.class)
#define SetClassOfPool(pool, _class) BEGIN (pool)->instStruct.class = (InstClass)(_class); END
#define ClassOfPool(pool) ((PoolClass)ClassOfPoly(pool))
#define SetClassOfPool SetClassOfPoly
#define SuperclassOfPool(pool) \
((PoolClass)InstClassSuperclassPoly(ClassOfPool(pool)))
@ -684,8 +684,8 @@ DECLARE_CLASS(Seg, Seg);
DECLARE_CLASS(Seg, GCSeg);
extern void SegClassMixInNoSplitMerge(SegClass class);
#define ClassOfSeg(seg) ((SegClass)(seg)->instStruct.class)
#define SetClassOfSeg(seg, _class) BEGIN (seg)->instStruct.class = (InstClass)(_class); END
#define ClassOfSeg(seg) ((SegClass)ClassOfPoly(seg))
#define SetClassOfSeg SetClassOfPoly
extern Size SegSize(Seg seg);
extern Addr (SegBase)(Seg seg);
@ -796,8 +796,8 @@ DECLARE_CLASS(Buffer, Buffer);
DECLARE_CLASS(Buffer, SegBuf);
DECLARE_CLASS(Buffer, RankBuf);
#define ClassOfBuffer(buffer) ((BufferClass)(buffer)->instStruct.class)
#define SetClassOfBuffer(buffer, class) BEGIN (buffer)->instStruct.class = (InstClass)(class); END
#define ClassOfBuffer(buffer) ((BufferClass)ClassOfPoly(buffer))
#define SetClassOfBuffer SetClassOfPoly
extern AllocPattern AllocPatternRamp(void);
extern AllocPattern AllocPatternRampCollectAll(void);
@ -991,8 +991,8 @@ extern Bool LandFlush(Land dest, Land src);
extern Size LandSlowSize(Land land);
extern Bool LandClassCheck(LandClass class);
DECLARE_CLASS(Land, Land);
#define ClassOfLand(land) ((LandClass)(land)->instStruct.class)
#define SetClassOfLand(land, _class) BEGIN (land)->instStruct.class = (InstClass)(_class); END
#define ClassOfLand(land) ((LandClass)ClassOfPoly(land))
#define SetClassOfLand SetClassOfPoly
/* STATISTIC -- gather statistics (in some varieties)

View file

@ -80,7 +80,12 @@ typedef enum ClassIdEnum {
ClassIdLIMIT
} ClassIdEnum;
/* ClassLevelEnum -- depth of class in hierarchy */
/* ClassLevelEnum -- depth of class in hierarchy
*
* This defines enum constants like ClassLevelLand equal to the
* distance from the root of the class hierarchy.
*/
#define CLASS_LEVEL_ENUM(prefix, ident, kind, super) prefix ## ident = prefix ## super + 1,
typedef enum ClassLevelEnum {
@ -90,7 +95,12 @@ typedef enum ClassLevelEnum {
} ClassLevelEnum;
/* INHERIT_CLASS -- the standard macro for inheriting from a superclass */
/* INHERIT_CLASS -- inheriting from a superclass
*
* This macro is used at the start of a class definition to inherit
* the superclass and override the fields essential to the
* workings of the protocol.
*/
#define INHERIT_CLASS(this, _class, super) \
BEGIN \
@ -104,11 +114,13 @@ typedef enum ClassLevelEnum {
END
#define InstClassSig ((Sig)0x519B60C7) /* SIGnature PROtocol CLass */
#define InstSig ((Sig)0x519B6014) /* SIGnature PROtocol INst */
/* Inst -- the instance structure for support of the protocol */
/* Inst -- the instance structure for support of the protocol
*
* An InstStruct named instStruct must be the first field of any
* instance structure using the protocol, because the protocol uses
* casting between structures with common prefixes to implement
* polymorphism.
*/
typedef struct InstStruct *Inst;
typedef struct InstClassStruct *InstClass;
@ -120,15 +132,16 @@ typedef struct InstStruct {
/* InstClass -- the class containing the support for the protocol */
typedef const char *InstClassName;
typedef unsigned long ProtocolTypeId;
typedef const char *ClassName;
typedef unsigned char ClassId;
typedef unsigned char ClassLevel;
#define ClassDEPTH 8 /* maximum depth of class hierarchy */
#define InstClassSig ((Sig)0x519B60C7) /* SIGnature PROtocol CLass */
typedef struct InstClassStruct {
Sig sig; /* <design/sig/> */
InstClassName name; /* human readable name such as "Land" */
ClassName name; /* human readable name such as "Land" */
InstClass superclass; /* pointer to direct superclass */
ClassLevel level; /* distance from root of class hierarchy */
ClassId display[ClassDEPTH]; /* ids of classes at this level and above */
@ -156,7 +169,10 @@ extern Bool InstCheck(Inst pro);
#define InstClassSuperclassPoly(class) \
(((InstClass)(class))->superclass)
#define ClassOfPoly(inst) (MustBeA(Inst, inst)->class)
/* FIXME: Try MustBeA here. */
#define ClassOfPoly(inst) (CouldBeA(Inst, inst)->class)
#define SetClassOfPoly(inst, _class) \
BEGIN CouldBeA(Inst, inst)->class = (InstClass)(_class); END
/* SUPERCLASS - get the superclass object, given a class name