ScmObj
Jump to navigation
Jump to search
概要[edit | edit source]
- gauche.h で定義
- scheme object を表現するためのデータ構造
- 共通のヘッダ部分を定義し、
実装[edit | edit source]
137 /* 138 * An opaque pointer. All Scheme objects are represented by 139 * this type. 140 */ 141 typedef struct ScmHeaderRec *ScmObj; 142 143 /* 144 * The class structure. ScmClass is actually a subclass of ScmObj. 145 */ 146 typedef struct ScmClassRec ScmClass;
294 /* A common header for all Scheme objects */ 295 typedef struct ScmHeaderRec { 296 ScmClass *klass; /* private */ 297 } ScmHeader;
311 /* A common header for objects whose class is defined in Scheme */ 312 typedef struct ScmInstanceRec { 313 ScmClass *klass; 314 ScmObj *slots; 315 } ScmInstance; 316 317 #define SCM_INSTANCE_HEADER ScmInstance hdr /* for declaration */
430 /*--------------------------------------------------------- 431 * CLASS 432 */ 433 434 /* See class.c for the description of function pointer members. 435 There's a lot of voodoo magic in class structure, so don't touch 436 those fields casually. Also, the order of these fields must be 437 reflected to the class definition macros below */ 438 struct ScmClassRec { 439 SCM_INSTANCE_HEADER; 440 void (*print)(ScmObj obj, ScmPort *sink, ScmWriteContext *mode); 441 int (*compare)(ScmObj x, ScmObj y, int equalp); 442 int (*serialize)(ScmObj obj, ScmPort *sink, ScmObj context); 443 ScmObj (*allocate)(ScmClass *klass, ScmObj initargs); 444 ScmClass **cpa; /* class precedence array, NULL terminated */ 445 int numInstanceSlots; /* # of instance slots */ 446 int coreSize; /* size of core structure; 0 == unknown */ 447 unsigned int flags; 448 ScmObj name; /* scheme name */ 449 ScmObj directSupers; /* list of classes */ 450 ScmObj cpl; /* list of classes */ 451 ScmObj accessors; /* alist of slot-name & slot-accessor */ 452 ScmObj directSlots; /* alist of slot-name & slot-definition */ 453 ScmObj slots; /* alist of slot-name & slot-definition */ 454 ScmObj directSubclasses; /* list of direct subclasses */ 455 ScmObj directMethods; /* list of methods that has this class in 456 its specializer */ 457 ScmObj initargs; /* saved key-value list for redefinition */ 458 ScmObj modules; /* modules where this class is defined */ 459 ScmObj redefined; /* if this class is obsoleted by class 460 redefinition, points to the new class. 461 if this class is being redefined, points 462 to a thread that is handling the 463 redefinition. (it won't be seen by 464 Scheme; see class.c) 465 otherwise #f */ 466 ScmInternalMutex mutex; /* to protect from MT hazard */ 467 ScmInternalCond cv; /* wait on this while a class being updated */ 468 };