From 6ef4cc08c21657452008a694b906a39d67f966e0 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 10 May 2005 15:15:57 +0000 Subject: [PATCH] *** empty log message *** --- ase/stx/hash.c | 4 +-- ase/stx/object.c | 74 +++++++++++++++++++++++++++--------------------- ase/stx/object.h | 14 ++++++++- ase/stx/stx.h | 12 +------- 4 files changed, 58 insertions(+), 46 deletions(-) diff --git a/ase/stx/hash.c b/ase/stx/hash.c index fe107d21..1486e9c6 100644 --- a/ase/stx/hash.c +++ b/ase/stx/hash.c @@ -1,5 +1,5 @@ /* - * $Id: hash.c,v 1.5 2005-05-10 08:21:10 bacon Exp $ + * $Id: hash.c,v 1.6 2005-05-10 15:15:57 bacon Exp $ */ #include @@ -12,7 +12,7 @@ xp_stx_word_t xp_stx_new_link ( xp_stx_word_t x; x = xp_stx_alloc_object (stx, 3); - XP_STX_CLASS(stx,x) = stx->link_class; + XP_STX_CLASS(stx,x) = stx->class_link; XP_STX_AT(stx,x,0) = key; XP_STX_AT(stx,x,1) = value; /* XP_STX_AT(stx,x,2) = stx->nil; */ diff --git a/ase/stx/object.c b/ase/stx/object.c index e1ca9729..886340d1 100644 --- a/ase/stx/object.c +++ b/ase/stx/object.c @@ -1,11 +1,18 @@ /* - * $Id: object.c,v 1.8 2005-05-10 12:00:43 bacon Exp $ + * $Id: object.c,v 1.9 2005-05-10 15:12:31 bacon Exp $ */ #include #include -#include #include +#include + +xp_stx_word_t xp_stx_strlen (const xp_stx_char_t* str) +{ + const xp_stx_char_t* p = str; + while (*p != XP_STX_CHAR('\0')) p++; + return p - str; +} /* n: number of instance variables */ xp_stx_word_t xp_stx_alloc_object (xp_stx_t* stx, xp_stx_word_t n) @@ -49,7 +56,7 @@ xp_stx_word_t xp_stx_alloc_string_object ( { xp_stx_word_t idx, n; - n = xp_strlen(str); + n = xp_stx_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 */ @@ -63,6 +70,38 @@ xp_stx_word_t xp_stx_alloc_string_object ( return idx; } +xp_stx_word_t xp_stx_allocn_string_object (xp_stx_t* stx, ...) +{ + xp_stx_word_t idx, n = 0; + const xp_stx_char_t* p; + xp_va_list ap; + + xp_va_start (ap, stx); + while ((p = xp_va_arg(ap, const xp_stx_char_t*)) != XP_NULL) { + n += xp_stx_strlen(p); + } + xp_va_end (ap, stx); + + 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 */ + + xp_assert (stx->nil == XP_STX_NIL); + XP_STX_CLASS(stx,idx) = stx->nil; + XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_CHAR_INDEXED; + XP_STX_CHARAT(stx,idx,n) = XP_STX_CHAR('\0'); + + xp_va_start (ap, stx); + n = 0; + while ((p = xp_va_arg(ap, const xp_stx_char_t*)) != XP_NULL) { + while (*p != XP_STX_CHAR('\0')) + XP_STX_CHARAT(stx,idx,n) = *p++; + } + xp_va_end (ap, stx); + + return idx; +} + xp_stx_word_t xp_stx_hash_string_object (xp_stx_t* stx, xp_stx_word_t idx) { xp_stx_word_t nb, h = 0; @@ -113,32 +152,3 @@ xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, xp_stx_char_t* name) return class; } -/* -struct class_info_t -{ - const xp_stx_char_t* name; - xp_size_word_t inst_vars; -}; -typedef struct class_info_t class_info_t; - -class_info_t class_info[] = -{ - { XP_STX_TEXT("Class"), 5 }, - { XP_STX_TEXT("Metaclass"), 5 }, - { XP_NULL, 0 } -}; -*/ - - -/* - - -xp_stx_word_t xp_stx_instantiate_string (xp_stx_t* stx, xp_stx_char_t* str) -{ - xp_stx_word_t x; - x = xp_stx_alloc_string_object (stx, str); - XP_STX_CLASS(&stx->memory,x) = stx->class_string; - return x; -} - -*/ diff --git a/ase/stx/object.h b/ase/stx/object.h index 3adde30c..e6554b6d 100644 --- a/ase/stx/object.h +++ b/ase/stx/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.6 2005-05-10 12:00:43 bacon Exp $ + * $Id: object.h,v 1.7 2005-05-10 15:12:31 bacon Exp $ */ #ifndef _XP_STX_OBJECT_H_ @@ -11,6 +11,17 @@ #define XP_STX_TO_SMALLINT(x) ((x) << 1) | 0x01) #define XP_STX_FROM_SMALLINT(x) ((x) >> 1) +/* definitions for common objects */ +#define XP_STX_CLASS_DIMENSION 8 +#define XP_STX_CLASS_NAME 0 +#define XP_STX_CLASS_SIZE 1 +#define XP_STX_CLASS_METHODS 2 +#define XP_STX_CLASS_SUPERCLASS 3 +#define XP_STX_CLASS_VARIABLES 4 +#define XP_STX_CLASS_CLASSVARS 5 +#define XP_STX_CLASS_POOLDICT 6 +#define XP_STX_CLASS_CATEGORY 7 + #ifdef __cplusplus extern "C" { #endif @@ -19,6 +30,7 @@ xp_stx_word_t xp_stx_alloc_object (xp_stx_t* stx, xp_stx_word_t n); xp_stx_word_t xp_stx_alloc_byte_object (xp_stx_t* stx, xp_stx_word_t n); xp_stx_word_t xp_stx_alloc_string_object ( xp_stx_t* stx, const xp_stx_char_t* str); +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); diff --git a/ase/stx/stx.h b/ase/stx/stx.h index 4b772d90..4364bc7e 100644 --- a/ase/stx/stx.h +++ b/ase/stx/stx.h @@ -1,5 +1,5 @@ /* - * $Id: stx.h,v 1.8 2005-05-10 12:00:43 bacon Exp $ + * $Id: stx.h,v 1.9 2005-05-10 15:12:31 bacon Exp $ */ #ifndef _XP_STX_STX_H_ @@ -112,16 +112,6 @@ struct xp_stx_t #define XP_STX_CHARAT(stx,idx,n) \ (((xp_stx_char_t*)(XP_STX_OBJECT(stx,idx) + 1))[n]) -#define XP_STX_CLASS_DIMENSION 8 -#define XP_STX_CLASS_NAME 0 -#define XP_STX_CLASS_SIZE 1 -#define XP_STX_CLASS_METHODS 2 -#define XP_STX_CLASS_SUPERCLASS 3 -#define XP_STX_CLASS_VARIABLES 4 -#define XP_STX_CLASS_CLASSVARS 5 -#define XP_STX_CLASS_POOLDICT 6 -#define XP_STX_CLASS_CATEGORY 7 - #ifdef __cplusplus extern "C" { #endif