概要
Tclシステムのオブジェクトの定義
メンバー
- int refCount; 0の時、オブジェクトはfreeされる。
- char *bytes; オブジェクトの文字列表現の最初のバイトを指すポインタ。この配列は、null byteが続かないといけない。しかし、組み込まれたnull moji文字を含むだろう。この配列は、ckallocでアロケートされる。NULLは、文字列表現が不正で中間表現から再生成する必要があることを意味する。クライアントは、Tcl_GetStringFromObj か Tcl_GetString で文字列情報を読み出せる。
- int length; *byteのバイト数を示す。最後のnullは含まない。
- Tcl_ObjType *typePtr; オブジェクトの内部表現の型を示す。NULLは、内部表現の型を持っていない(形無し)をしめす。
- union internalRep; オブジェクトの内部表現
union internalRep メンバー
- long longValue; long; 整数の値
- double doubleValue; doubleの値
- VOID *otherValuePtr; 他の型が記述する値
- Tcl_WideInt wideValue; long long の値。
- struct {VOID *ptr1;VOID *ptr2} twoPtrValue;
- struct {VOID *ptr;unsigned long value;*
ソース
/*
* One of the following structures exists for each object in the Tcl system.
* An object stores a value as either a string, some internal representation,
* or both.
*/
typedef struct Tcl_Obj {
int refCount; /* When 0 the object will be freed. */
char *bytes; /* This points to the first byte of the
* object's string representation. The array
* must be followed by a null byte (i.e., at
* offset length) but may also contain
* embedded null characters. The array's
* storage is allocated by ckalloc. NULL means
* the string rep is invalid and must be
* regenerated from the internal rep. Clients
* should use Tcl_GetStringFromObj or
* Tcl_GetString to get a pointer to the byte
* array as a readonly value. */
int length; /* The number of bytes at *bytes, not
* including the terminating null. */
Tcl_ObjType *typePtr; /* Denotes the object's type. Always
* corresponds to the type of the object's
* internal rep. NULL indicates the object has
* no internal rep (has no type). */
union { /* The internal representation: */
long longValue; /* - an long integer value. */
double doubleValue; /* - a double-precision floating value. */
VOID *otherValuePtr; /* - another, type-specific value. */
Tcl_WideInt wideValue; /* - a long long value. */
struct { /* - internal rep as two pointers. */
VOID *ptr1;
VOID *ptr2;
} twoPtrValue;
struct { /* - internal rep as a wide int, tightly
* packed fields. */
VOID *ptr; /* Pointer to digits. */
unsigned long value;/* Alloc, used, and signum packed into a
* single word. */
} ptrAndLongRep;
} internalRep;
} Tcl_Obj;
最終更新:2011年11月02日 10:42