クラス構造体。ScmClassは実際はScmObjのサブクラスです。
%% gauche.h typedef struct ScmClassRec ScmClass;
/* See class.c for the description of function pointer members. There's a lot of voodoo magic in class structure, so don't touch those fields casually. Also, the order of these fields must be reflected to the class definition macros below */ struct ScmClassRec { /* We need all class structures be aligned on (at least) 8-byte boundary to make our tagging scheme work. Dynamically allocated objects are *always* 8-byte aligned due to Boehm GC's architecture. However, we found that statically allocated class structures can be placed 4-byte boundary on some 32bit systems if we started ScmClassRec with SCM_INSTANCE_HEADER. The following union is the trick to ensure 8-byte alighment on such systems. */ union { SCM_INSTANCE_HEADER; double align_dummy; } classHdr;
8-byte な境界整列に対応するための実装と思われます。
ScmClassPrintProc print; ScmClassCompareProc compare; ScmClassSerializeProc serialize; ScmClassAllocateProc allocate;
ScmClass **cpa; /* class precedence array, NULL terminated */ int numInstanceSlots; /* # of instance slots */ int coreSize; /* size of core structure; 0 == unknown */
unsigned int flags; ScmObj name; /* scheme name */ ScmObj directSupers; /* list of classes */ ScmObj cpl; /* list of classes */ ScmObj accessors; /* alist of slot-name & slot-accessor */ ScmObj directSlots; /* alist of slot-name & slot-definition */ ScmObj slots; /* alist of slot-name & slot-definition */ ScmObj directSubclasses; /* list of direct subclasses */ ScmObj directMethods; /* list of methods that has this class in its specializer */ ScmObj initargs; /* saved key-value list for redefinition */ ScmObj modules; /* modules where this class is defined */ ScmObj redefined; /* if this class is obsoleted by class redefinition, points to the new class. if this class is being redefined, points to a thread that is handling the redefinition. (it won't be seen by Scheme; see class.c) otherwise #f */ ScmInternalMutex mutex; /* to protect from MT hazard */ ScmInternalCond cv; /* wait on this while a class being updated */ void *data; /* extra data to do nasty trick */ };
コメントはありません。 コメント/Reading Gauche/Reading Gauche 0.9/gauche.h/ScmClass?