diff --git a/ase/stx/object.c b/ase/stx/object.c index 25229990..8ae443d3 100644 --- a/ase/stx/object.c +++ b/ase/stx/object.c @@ -1,5 +1,5 @@ /* - * $Id: object.c,v 1.10 2005-05-10 15:15:57 bacon Exp $ + * $Id: object.c,v 1.11 2005-05-10 16:20:53 bacon Exp $ */ #include @@ -8,7 +8,7 @@ #include #include -xp_stx_word_t xp_stx_strlen (const xp_stx_char_t* str) +static xp_stx_word_t __strlen (const xp_stx_char_t* str) { const xp_stx_char_t* p = str; while (*p != XP_STX_CHAR('\0')) p++; @@ -57,7 +57,7 @@ xp_stx_word_t xp_stx_alloc_string_object ( { xp_stx_word_t idx, n; - n = xp_stx_strlen(str); + n = __strlen(str); idx = xp_stx_memory_alloc (&stx->memory, (n + 1) * xp_sizeof(xp_stx_char_t) + xp_sizeof(xp_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ @@ -79,7 +79,7 @@ xp_stx_word_t xp_stx_allocn_string_object (xp_stx_t* stx, ...) xp_va_start (ap, stx); while ((p = xp_va_arg(ap, const xp_stx_char_t*)) != XP_NULL) { - n += xp_stx_strlen(p); + n += __strlen(p); } xp_va_end (ap); @@ -116,16 +116,25 @@ xp_stx_word_t xp_stx_hash_string_object (xp_stx_t* stx, xp_stx_word_t idx) return h; } -xp_stx_word_t xp_stx_new_string_object ( - xp_stx_t* stx, const xp_stx_char_t* name, xp_stx_word_t class) +xp_stx_word_t xp_stx_new_symbol ( + xp_stx_t* stx, const xp_stx_char_t* name) { xp_stx_word_t x; x = xp_stx_alloc_string_object (stx, name); - XP_STX_CLASS(stx,x) = class; + XP_STX_CLASS(stx,x) = stx->class_symbol; return x; } -xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, xp_stx_char_t* name) +xp_stx_word_t xp_stx_new_symbol_postfix ( + xp_stx_t* stx, const xp_stx_char_t* name, const xp_char_t* postfix) +{ + xp_stx_word_t x; + x = xp_stx_allocn_string_object (stx, name, postfix, XP_NULL); + XP_STX_CLASS(stx,x) = stx->class_symbol; + return x; +} + +xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, const xp_stx_char_t* name) { xp_stx_word_t meta, class; xp_stx_word_t meta_name, class_name; @@ -138,9 +147,10 @@ xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, xp_stx_char_t* name) class = xp_stx_alloc_object (stx, XP_STX_CLASS_DIMENSION); XP_STX_CLASS(stx,class) = meta; - meta_name = xp_stx_new_string_object (stx, name, stx->class_symbol); + meta_name = xp_stx_new_symbol (stx, name); XP_STX_AT(stx,meta,XP_STX_CLASS_NAME) = meta_name; - class_name = xp_stx_new_string_object (stx, name, stx->class_symbol); + class_name = xp_stx_new_symbol_postfix ( + stx, name, XP_STX_TEXT("Meta")); XP_STX_AT(stx,class,XP_STX_CLASS_NAME) = class_name; xp_stx_hash_insert (stx, stx->symbol_table, diff --git a/ase/stx/object.h b/ase/stx/object.h index 0ab5bf38..e4eb6e65 100644 --- a/ase/stx/object.h +++ b/ase/stx/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.8 2005-05-10 15:15:57 bacon Exp $ + * $Id: object.h,v 1.9 2005-05-10 16:20:53 bacon Exp $ */ #ifndef _XP_STX_OBJECT_H_ @@ -34,9 +34,12 @@ xp_stx_word_t xp_stx_allocn_string_object (xp_stx_t* stx, ...); xp_stx_word_t xp_stx_hash_string_object (xp_stx_t* stx, xp_stx_word_t idx); -xp_stx_word_t xp_stx_new_string_object ( - xp_stx_t* stx, const xp_stx_char_t* name, xp_stx_word_t class); - +xp_stx_word_t xp_stx_new_symbol ( + xp_stx_t* stx, const xp_stx_char_t* name); +xp_stx_word_t xp_stx_new_symbol_postfix ( + xp_stx_t* stx, const xp_stx_char_t* name, const xp_stx_char_t* postfix); +xp_stx_word_t xp_stx_new_class ( + xp_stx_t* stx, const xp_stx_char_t* name); #ifdef __cplusplus } diff --git a/ase/stx/stx.c b/ase/stx/stx.c index 025488c3..d2d11379 100644 --- a/ase/stx/stx.c +++ b/ase/stx/stx.c @@ -1,5 +1,5 @@ /* - * $Id: stx.c,v 1.9 2005-05-10 15:15:57 bacon Exp $ + * $Id: stx.c,v 1.10 2005-05-10 16:20:53 bacon Exp $ */ #include @@ -49,6 +49,7 @@ int xp_stx_bootstrap (xp_stx_t* stx) xp_stx_word_t symbol_Metaclass, symbol_MetaclassMeta; xp_stx_word_t class_Symbol, class_SymbolMeta; xp_stx_word_t class_Metaclass, class_MetaclassMeta; + xp_stx_word_t class_UndefinedObject; /* allocate three keyword objects */ stx->nil = xp_stx_alloc_object (stx, 0); @@ -100,13 +101,18 @@ int xp_stx_bootstrap (xp_stx_t* stx) xp_stx_hash_string_object(stx, symbol_MetaclassMeta), symbol_MetaclassMeta, class_MetaclassMeta); + /* ready to use new_symbol & new_class */ + stx->symbol_table = symtab; + stx->class_symbol = class_Symbol; + stx->class_metaclass = class_Metaclass; + /* more initialization for nil, true, false */ - symbol_nil = xp_stx_new_string_object ( - stx, XP_STX_TEXT("nil"), class_Symbol); - symbol_true = xp_stx_new_string_object ( - stx, XP_STX_TEXT("true"), class_Symbol); - symbol_false = xp_stx_new_string_object ( - stx, XP_STX_TEXT("false"), class_Symbol); + symbol_nil = xp_stx_new_symbol ( + stx, XP_STX_TEXT("nil")); + symbol_true = xp_stx_new_symbol ( + stx, XP_STX_TEXT("true")); + symbol_false = xp_stx_new_symbol ( + stx, XP_STX_TEXT("false")); xp_stx_hash_insert (stx, symtab, xp_stx_hash_string_object(stx, symbol_nil), @@ -118,11 +124,7 @@ int xp_stx_bootstrap (xp_stx_t* stx) xp_stx_hash_string_object(stx, symbol_false), symbol_false, stx->false); - /* ready to use new_class */ - stx->symbol_table = symtab; - stx->class_symbol = class_Symbol; - stx->class_metaclass = class_Metaclass; - + class_UndefinedObject = xp_stx_new_class (stx, XP_STX_TEXT("UndefinedObject")); /* class_Symbol = xp_stx_instantiate_class (XP_STX_TEXT("Symbol"));