diff --git a/ase/stx/misc.h b/ase/stx/misc.h index c09a918e..8318eda3 100644 --- a/ase/stx/misc.h +++ b/ase/stx/misc.h @@ -1,5 +1,5 @@ /* - * $Id: misc.h,v 1.5 2005-06-08 16:00:51 bacon Exp $ + * $Id: misc.h,v 1.6 2005-06-08 16:05:41 bacon Exp $ */ #ifndef _XP_STX_MISC_H_ @@ -31,21 +31,6 @@ #include #include #include - - /* - #define xp_assert xp_assert - #define xp_malloc xp_malloc - #define xp_realloc xp_realloc - #define xp_free xp_free - #define xp_va_list xp_va_list - #define xp_va_start xp_va_start - #define xp_va_end xp_va_end - #define xp_va_arg xp_va_arg - #define xp_isspace xp_isspace - #define xp_isdigit xp_isdigit - #define xp_isalpha xp_isalpha - #define xp_isalnum xp_isalnum - */ #endif #ifdef __cplusplus diff --git a/ase/stx/object.c b/ase/stx/object.c index 81997e2b..08170820 100644 --- a/ase/stx/object.c +++ b/ase/stx/object.c @@ -1,5 +1,5 @@ /* - * $Id: object.c,v 1.23 2005-05-23 15:51:03 bacon Exp $ + * $Id: object.c,v 1.24 2005-06-08 16:00:51 bacon Exp $ */ #include @@ -9,19 +9,19 @@ #include /* n: number of instance variables */ -xp_stx_word_t xp_stx_alloc_word_object (xp_stx_t* stx, xp_stx_word_t n) +xp_word_t xp_stx_alloc_word_object (xp_stx_t* stx, xp_word_t n) { - xp_stx_word_t idx; + xp_word_t idx; xp_stx_word_object_t* obj; /* bytes to allocidxed = * number of instance variables * word_size */ idx = xp_stx_memory_alloc (&stx->memory, - n * xp_sizeof(xp_stx_word_t) + xp_sizeof(xp_stx_object_t)); + n * xp_sizeof(xp_word_t) + xp_sizeof(xp_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ - xp_stx_assert (stx->nil == XP_STX_NIL); + xp_assert (stx->nil == XP_STX_NIL); /* XP_STX_CLASS(stx,idx) = stx->nil; @@ -37,16 +37,16 @@ xp_stx_word_t xp_stx_alloc_word_object (xp_stx_t* stx, xp_stx_word_t n) } /* n: number of bytes */ -xp_stx_word_t xp_stx_alloc_byte_object (xp_stx_t* stx, xp_stx_word_t n) +xp_word_t xp_stx_alloc_byte_object (xp_stx_t* stx, xp_word_t n) { - xp_stx_word_t idx; + xp_word_t idx; xp_stx_byte_object_t* obj; idx = xp_stx_memory_alloc ( &stx->memory, n + xp_sizeof(xp_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ - xp_stx_assert (stx->nil == XP_STX_NIL); + xp_assert (stx->nil == XP_STX_NIL); /* XP_STX_CLASS(stx,idx) = stx->nil; @@ -61,84 +61,84 @@ xp_stx_word_t xp_stx_alloc_byte_object (xp_stx_t* stx, xp_stx_word_t n) return idx; } -xp_stx_word_t xp_stx_alloc_char_object ( - xp_stx_t* stx, const xp_stx_char_t* str) +xp_word_t xp_stx_alloc_char_object ( + xp_stx_t* stx, const xp_char_t* str) { return xp_stx_alloc_char_objectx (stx, str, xp_stx_strlen(str)); } -xp_stx_word_t xp_stx_alloc_char_objectx ( - xp_stx_t* stx, const xp_stx_char_t* str, xp_stx_word_t n) +xp_word_t xp_stx_alloc_char_objectx ( + xp_stx_t* stx, const xp_char_t* str, xp_word_t n) { - xp_stx_word_t idx; + xp_word_t idx; xp_stx_char_object_t* obj; idx = xp_stx_memory_alloc (&stx->memory, - (n + 1) * xp_sizeof(xp_stx_char_t) + xp_sizeof(xp_stx_object_t)); + (n + 1) * xp_sizeof(xp_char_t) + xp_sizeof(xp_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ - xp_stx_assert (stx->nil == XP_STX_NIL); + 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_STX_ACCESS(stx,idx) = (n << 2) | XP_CHAR_INDEXED; + XP_STX_CHARAT(stx,idx,n) = XP_CHAR('\0'); while (n-- > 0) XP_STX_CHARAT(stx,idx,n) = str[n]; */ - obj = XP_STX_CHAR_OBJECT(stx,idx); + obj = XP_CHAR_OBJECT(stx,idx); obj->header.class = stx->nil; - obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED; - obj->data[n] = XP_STX_CHAR('\0'); + obj->header.access = (n << 2) | XP_CHAR_INDEXED; + obj->data[n] = XP_CHAR('\0'); while (n-- > 0) obj->data[n] = str[n]; return idx; } -xp_stx_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...) +xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...) { - xp_stx_word_t idx, n = 0; - const xp_stx_char_t* p; - xp_stx_va_list ap; + xp_word_t idx, n = 0; + const xp_char_t* p; + xp_va_list ap; xp_stx_char_object_t* obj; - xp_stx_va_start (ap, stx); - while ((p = xp_stx_va_arg(ap, const xp_stx_char_t*)) != XP_NULL) { + xp_va_start (ap, stx); + while ((p = xp_va_arg(ap, const xp_char_t*)) != XP_NULL) { n += xp_stx_strlen(p); } - xp_stx_va_end (ap); + xp_va_end (ap); idx = xp_stx_memory_alloc (&stx->memory, - (n + 1) * xp_sizeof(xp_stx_char_t) + xp_sizeof(xp_stx_object_t)); + (n + 1) * xp_sizeof(xp_char_t) + xp_sizeof(xp_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ - xp_stx_assert (stx->nil == XP_STX_NIL); + 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_STX_ACCESS(stx,idx) = (n << 2) | XP_CHAR_INDEXED; + XP_STX_CHARAT(stx,idx,n) = XP_CHAR('\0'); */ - obj = XP_STX_CHAR_OBJECT(stx,idx); + obj = XP_CHAR_OBJECT(stx,idx); obj->header.class = stx->nil; - obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED; - obj->data[n] = XP_STX_CHAR('\0'); + obj->header.access = (n << 2) | XP_CHAR_INDEXED; + obj->data[n] = XP_CHAR('\0'); - xp_stx_va_start (ap, stx); + xp_va_start (ap, stx); n = 0; - while ((p = xp_stx_va_arg(ap, const xp_stx_char_t*)) != XP_NULL) { - while (*p != XP_STX_CHAR('\0')) { + while ((p = xp_va_arg(ap, const xp_char_t*)) != XP_NULL) { + while (*p != XP_CHAR('\0')) { /*XP_STX_CHARAT(stx,idx,n++) = *p++;*/ obj->data[n++] = *p++; } } - xp_stx_va_end (ap); + xp_va_end (ap); return idx; } -xp_stx_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_stx_word_t idx) +xp_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_word_t idx) { - xp_stx_assert (XP_STX_TYPE(stx,idx) == XP_STX_CHAR_INDEXED); + xp_assert (XP_STX_TYPE(stx,idx) == XP_CHAR_INDEXED); return xp_stx_strxhash ( XP_STX_DATA(stx,idx), XP_STX_SIZE(stx,idx)); } diff --git a/ase/stx/object.h b/ase/stx/object.h index 49a4b1ae..0cec03bc 100644 --- a/ase/stx/object.h +++ b/ase/stx/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.17 2005-05-23 15:51:03 bacon Exp $ + * $Id: object.h,v 1.18 2005-06-08 16:00:51 bacon Exp $ */ #ifndef _XP_STX_OBJECT_H_ @@ -15,17 +15,17 @@ extern "C" { #endif -xp_stx_word_t xp_stx_alloc_word_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_char_object ( - xp_stx_t* stx, const xp_stx_char_t* str); -xp_stx_word_t xp_stx_alloc_char_objectx ( - xp_stx_t* stx, const xp_stx_char_t* str, xp_stx_word_t n); -xp_stx_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...); +xp_word_t xp_stx_alloc_word_object (xp_stx_t* stx, xp_word_t n); +xp_word_t xp_stx_alloc_byte_object (xp_stx_t* stx, xp_word_t n); +xp_word_t xp_stx_alloc_char_object ( + xp_stx_t* stx, const xp_char_t* str); +xp_word_t xp_stx_alloc_char_objectx ( + xp_stx_t* stx, const xp_char_t* str, xp_word_t n); +xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...); -xp_stx_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_stx_word_t idx); +xp_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_word_t idx); int xp_stx_lookup_global ( - xp_stx_t* stx, xp_stx_word_t key, xp_stx_word_t* value); + xp_stx_t* stx, xp_word_t key, xp_word_t* value); #ifdef __cplusplus } diff --git a/ase/stx/parser.c b/ase/stx/parser.c index ca4d967b..8f10669e 100644 --- a/ase/stx/parser.c +++ b/ase/stx/parser.c @@ -1,5 +1,5 @@ /* - * $Id: parser.c,v 1.23 2005-06-08 15:49:35 bacon Exp $ + * $Id: parser.c,v 1.24 2005-06-08 16:00:51 bacon Exp $ */ #include @@ -8,7 +8,7 @@ static int __parse_method ( xp_stx_parser_t* parser, - xp_stx_word_t method_class, void* input); + xp_word_t method_class, void* input); static int __parse_message_pattern (xp_stx_parser_t* parser); static int __parse_temporaries (xp_stx_parser_t* parser); static int __parse_statements (xp_stx_parser_t* parser); @@ -30,21 +30,21 @@ xp_stx_parser_t* xp_stx_parser_open (xp_stx_parser_t* parser, xp_stx_t* stx) { if (parser == XP_NULL) { parser = (xp_stx_parser_t*) - xp_stx_malloc (xp_sizeof(xp_stx_parser_t)); + xp_malloc (xp_sizeof(xp_stx_parser_t)); if (parser == XP_NULL) return XP_NULL; parser->__malloced = xp_true; } else parser->__malloced = xp_false; if (xp_stx_token_open (&parser->token, 256) == XP_NULL) { - if (parser->__malloced) xp_stx_free (parser); + if (parser->__malloced) xp_free (parser); return XP_NULL; } parser->stx = stx; parser->error_code = XP_STX_PARSER_ERROR_NONE; - parser->curc = XP_STX_CHAR_EOF; + parser->curc = XP_CHAR_EOF; parser->ungotc_count = 0; parser->input_owner = XP_NULL; @@ -55,7 +55,7 @@ xp_stx_parser_t* xp_stx_parser_open (xp_stx_parser_t* parser, xp_stx_t* stx) void xp_stx_parser_close (xp_stx_parser_t* parser) { xp_stx_token_close (&parser->token); - if (parser->__malloced) xp_stx_free (parser); + if (parser->__malloced) xp_free (parser); } #define GET_CHAR(parser) \ @@ -73,7 +73,7 @@ void xp_stx_parser_close (xp_stx_parser_t* parser) } while (0) int xp_stx_parser_parse_method ( - xp_stx_parser_t* parser, xp_stx_word_t method_class, void* input) + xp_stx_parser_t* parser, xp_word_t method_class, void* input) { int n; @@ -90,7 +90,7 @@ int xp_stx_parser_parse_method ( } static int __parse_method ( - xp_stx_parser_t* parser, xp_stx_word_t method_class, void* input) + xp_stx_parser_t* parser, xp_word_t method_class, void* input) { /* * ::= @@ -124,7 +124,7 @@ static int __parse_message_pattern (xp_stx_parser_t* parser) } else if (parser->token.type == XP_STX_TOKEN_KEYWORD) { /* keyword pattern */ - xp_stx_char_t* selector; + xp_char_t* selector; } else { parser->error_code = XP_STX_PARSER_ERROR_MESSAGE_SELECTOR; @@ -160,14 +160,14 @@ static inline xp_bool_t __is_binary_char (xp_cint_t c) */ return - c == XP_STX_CHAR('!') || c == XP_STX_CHAR('%') || - c == XP_STX_CHAR('&') || c == XP_STX_CHAR('*') || - c == XP_STX_CHAR('+') || c == XP_STX_CHAR(',') || - c == XP_STX_CHAR('/') || c == XP_STX_CHAR('<') || - c == XP_STX_CHAR('=') || c == XP_STX_CHAR('>') || - c == XP_STX_CHAR('?') || c == XP_STX_CHAR('@') || - c == XP_STX_CHAR('\\') || c == XP_STX_CHAR('|') || - c == XP_STX_CHAR('~') || c == XP_STX_CHAR('-'); + c == XP_CHAR('!') || c == XP_CHAR('%') || + c == XP_CHAR('&') || c == XP_CHAR('*') || + c == XP_CHAR('+') || c == XP_CHAR(',') || + c == XP_CHAR('/') || c == XP_CHAR('<') || + c == XP_CHAR('=') || c == XP_CHAR('>') || + c == XP_CHAR('?') || c == XP_CHAR('@') || + c == XP_CHAR('\\') || c == XP_CHAR('|') || + c == XP_CHAR('~') || c == XP_CHAR('-'); } static int __get_token (xp_stx_parser_t* parser) @@ -176,7 +176,7 @@ static int __get_token (xp_stx_parser_t* parser) do { if (__skip_spaces(parser) == -1) return -1; - if (parser->curc == XP_STX_CHAR('"')) { + if (parser->curc == XP_CHAR('"')) { GET_CHAR (parser); if (__skip_comment(parser) == -1) return -1; } @@ -186,56 +186,56 @@ static int __get_token (xp_stx_parser_t* parser) c = parser->curc; xp_stx_token_clear (&parser->token); - if (c == XP_STX_CHAR_EOF) { + if (c == XP_CHAR_EOF) { parser->token.type = XP_STX_TOKEN_END; } - else if (xp_stx_isalpha(c)) { + else if (xp_isalpha(c)) { if (__get_ident(parser) == -1) return -1; } - else if (xp_stx_isdigit(c)) { + else if (xp_isdigit(c)) { if (__get_numlit(parser, xp_false) == -1) return -1; } - else if (c == XP_STX_CHAR('$')) { + else if (c == XP_CHAR('$')) { GET_CHAR (parser); if (__get_charlit(parser) == -1) return -1; } - else if (c == XP_STX_CHAR('\'')) { + else if (c == XP_CHAR('\'')) { GET_CHAR (parser); if (__get_strlit(parser) == -1) return -1; } - else if (c == XP_STX_CHAR(':')) { + else if (c == XP_CHAR(':')) { parser->token.type = XP_STX_TOKEN_COLON; ADD_TOKEN_CHAR(parser, c); GET_CHAR (parser); c = parser->curc; - if (c == XP_STX_CHAR('=')) { + if (c == XP_CHAR('=')) { parser->token.type = XP_STX_TOKEN_ASSIGN; ADD_TOKEN_CHAR(parser, c); GET_CHAR (parser); } } - else if (c == XP_STX_CHAR('^')) { + else if (c == XP_CHAR('^')) { parser->token.type = XP_STX_TOKEN_RETURN; ADD_TOKEN_CHAR(parser, c); GET_CHAR (parser); } - else if (c == XP_STX_CHAR('|')) { + else if (c == XP_CHAR('|')) { parser->token.type = XP_STX_TOKEN_BAR; ADD_TOKEN_CHAR(parser, c); GET_CHAR (parser); } - else if (c == XP_STX_CHAR('[')) { + else if (c == XP_CHAR('[')) { parser->token.type = XP_STX_TOKEN_LBRACKET; ADD_TOKEN_CHAR(parser, c); GET_CHAR (parser); } - else if (c == XP_STX_CHAR(']')) { + else if (c == XP_CHAR(']')) { parser->token.type = XP_STX_TOKEN_RBRACKET; ADD_TOKEN_CHAR(parser, c); GET_CHAR (parser); } - else if (c == XP_STX_CHAR('.')) { + else if (c == XP_CHAR('.')) { parser->token.type = XP_STX_TOKEN_PERIOD; ADD_TOKEN_CHAR(parser, c); GET_CHAR (parser); @@ -265,9 +265,9 @@ static int __get_ident (xp_stx_parser_t* parser) ADD_TOKEN_CHAR(parser, c); GET_CHAR (parser); c = parser->curc; - } while (xp_stx_isalnum(c)); + } while (xp_isalnum(c)); - if (c == XP_STX_CHAR(':')) { + if (c == XP_CHAR(':')) { parser->token.type = XP_STX_TOKEN_KEYWORD; GET_CHAR (parser); } @@ -302,7 +302,7 @@ static int __get_numlit (xp_stx_parser_t* parser, xp_bool_t negated) ADD_TOKEN_CHAR(parser, c); GET_CHAR (parser); c = parser->curc; - } while (xp_stx_isalnum(c)); + } while (xp_isalnum(c)); /* TODO; more */ return 0; @@ -316,7 +316,7 @@ static int __get_charlit (xp_stx_parser_t* parser) */ xp_cint_t c = parser->curc; /* even a new-line or white space would be taken */ - if (c == XP_STX_CHAR_EOF) { + if (c == XP_CHAR_EOF) { parser->error_code = XP_STX_PARSER_ERROR_CHARLIT; return -1; } @@ -346,15 +346,15 @@ static int __get_strlit (xp_stx_parser_t* parser) GET_CHAR (parser); c = parser->curc; - if (c == XP_STX_CHAR_EOF) { + if (c == XP_CHAR_EOF) { parser->error_code = XP_STX_PARSER_ERROR_STRLIT; return -1; } - } while (c != XP_STX_CHAR('\'')); + } while (c != XP_CHAR('\'')); GET_CHAR (parser); c = parser->curc; - } while (c == XP_STX_CHAR('\'')); + } while (c == XP_CHAR('\'')); return 0; } @@ -369,9 +369,9 @@ static int __get_binary (xp_stx_parser_t* parser) ADD_TOKEN_CHAR (parser, c); - if (c == XP_STX_CHAR('<')) { + if (c == XP_CHAR('<')) { /* - const xp_stx_char_t* p = XP_TEXT("primitive:"); + const xp_char_t* p = XP_TEXT("primitive:"); do { GET_CHAR (parser); @@ -380,10 +380,10 @@ static int __get_binary (xp_stx_parser_t* parser) } while (*c) */ } - else if (c == XP_STX_CHAR('-')) { + else if (c == XP_CHAR('-')) { GET_CHAR (parser); c = parser->curc; - if (xp_stx_isdigit(c)) return __get_numlit(parser,xp_true); + if (xp_isdigit(c)) return __get_numlit(parser,xp_true); } else { GET_CHAR (parser); @@ -401,13 +401,13 @@ static int __get_binary (xp_stx_parser_t* parser) static int __skip_spaces (xp_stx_parser_t* parser) { - while (xp_stx_isspace(parser->curc)) GET_CHAR (parser); + while (xp_isspace(parser->curc)) GET_CHAR (parser); return 0; } static int __skip_comment (xp_stx_parser_t* parser) { - while (parser->curc != XP_STX_CHAR('"')) GET_CHAR (parser); + while (parser->curc != XP_CHAR('"')) GET_CHAR (parser); GET_CHAR (parser); return 0; } @@ -448,7 +448,7 @@ static int __open_input (xp_stx_parser_t* parser, void* input) } parser->error_code = XP_STX_PARSER_ERROR_NONE; - parser->curc = XP_STX_CHAR_EOF; + parser->curc = XP_CHAR_EOF; parser->ungotc_count = 0; return 0; } diff --git a/ase/stx/parser.h b/ase/stx/parser.h index cb45fa3c..da953947 100644 --- a/ase/stx/parser.h +++ b/ase/stx/parser.h @@ -1,5 +1,5 @@ /* - * $Id: parser.h,v 1.13 2005-06-08 03:19:31 bacon Exp $ + * $Id: parser.h,v 1.14 2005-06-08 16:00:51 bacon Exp $ */ #ifndef _XP_STX_PARSER_H_ @@ -44,8 +44,8 @@ struct xp_stx_parser_t int error_code; xp_stx_token_t token; - xp_stx_cint_t curc; - xp_stx_cint_t ungotc[5]; + xp_cint_t curc; + xp_cint_t ungotc[5]; xp_size_t ungotc_count; void* input_owner; @@ -62,7 +62,7 @@ xp_stx_parser_t* xp_stx_parser_open (xp_stx_parser_t* parser, xp_stx_t* stx); void xp_stx_parser_close (xp_stx_parser_t* parser); int xp_stx_parser_parse_method ( - xp_stx_parser_t* parser, xp_stx_word_t method_class, void* input); + xp_stx_parser_t* parser, xp_word_t method_class, void* input); #ifdef __cplusplus } diff --git a/ase/stx/stx.c b/ase/stx/stx.c index 1953b198..802f8a7d 100644 --- a/ase/stx/stx.c +++ b/ase/stx/stx.c @@ -1,22 +1,22 @@ /* - * $Id: stx.c,v 1.29 2005-05-25 16:44:05 bacon Exp $ + * $Id: stx.c,v 1.30 2005-06-08 16:00:51 bacon Exp $ */ #include #include #include -xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_stx_word_t capacity) +xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_word_t capacity) { if (stx == XP_NULL) { - stx = (xp_stx_t*)xp_stx_malloc (xp_sizeof(stx)); + stx = (xp_stx_t*)xp_malloc (xp_sizeof(stx)); if (stx == XP_NULL) return XP_NULL; stx->__malloced = xp_true; } else stx->__malloced = xp_false; if (xp_stx_memory_open (&stx->memory, capacity) == XP_NULL) { - if (stx->__malloced) xp_stx_free (stx); + if (stx->__malloced) xp_free (stx); return XP_NULL; } @@ -43,6 +43,6 @@ xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_stx_word_t capacity) void xp_stx_close (xp_stx_t* stx) { xp_stx_memory_close (&stx->memory); - if (stx->__malloced) xp_stx_free (stx); + if (stx->__malloced) xp_free (stx); } diff --git a/ase/stx/stx.h b/ase/stx/stx.h index aa44cab9..518060e5 100644 --- a/ase/stx/stx.h +++ b/ase/stx/stx.h @@ -1,5 +1,5 @@ /* - * $Id: stx.h,v 1.25 2005-06-08 15:49:35 bacon Exp $ + * $Id: stx.h,v 1.26 2005-06-08 16:00:51 bacon Exp $ */ #ifndef _XP_STX_STX_H_ @@ -8,11 +8,6 @@ #include #include -typedef xp_byte_t xp_byte_t; -typedef xp_char_t xp_char_t; -typedef xp_cint_t xp_stx_cint_t; -typedef xp_word_t xp_word_t; - typedef struct xp_stx_objhdr_t xp_stx_objhdr_t; typedef struct xp_stx_object_t xp_stx_object_t; typedef struct xp_stx_word_object_t xp_stx_word_object_t; @@ -21,10 +16,6 @@ typedef struct xp_stx_char_object_t xp_stx_char_object_t; typedef struct xp_stx_memory_t xp_stx_memory_t; typedef struct xp_stx_t xp_stx_t; -#define XP_STX_CHAR(x) XP_CHAR(x) -#define XP_STX_TEXT(x) XP_TEXT(x) -#define XP_STX_CHAR_EOF XP_CHAR_EOF - /* common object structure */ struct xp_stx_objhdr_t { @@ -90,8 +81,6 @@ struct xp_stx_t xp_bool_t __wantabort; /* TODO: make it a function pointer */ }; -typedef xp_stx_cint_t (*xp_stx_getc_t) (void*); - #define XP_STX_NIL 0 #define XP_STX_TRUE 1 #define XP_STX_FALSE 2 @@ -105,13 +94,13 @@ typedef xp_stx_cint_t (*xp_stx_getc_t) (void*); #define XP_STX_SIZE(stx,idx) (XP_STX_ACCESS(stx,idx) >> 0x02) #define XP_STX_WORD_INDEXED (0x00) #define XP_STX_BYTE_INDEXED (0x01) -#define XP_STX_CHAR_INDEXED (0x02) +#define XP_CHAR_INDEXED (0x02) #define XP_STX_WORD_OBJECT(stx,idx) \ ((xp_stx_word_object_t*)XP_STX_OBJECT(stx,idx)) #define XP_STX_BYTE_OBJECT(stx,idx) \ ((xp_stx_byte_object_t*)XP_STX_OBJECT(stx,idx)) -#define XP_STX_CHAR_OBJECT(stx,idx) \ +#define XP_CHAR_OBJECT(stx,idx) \ ((xp_stx_char_object_t*)XP_STX_OBJECT(stx,idx)) #define XP_STX_WORDAT(stx,idx,n) \ diff --git a/ase/stx/symbol.c b/ase/stx/symbol.c index eba87d65..44623329 100644 --- a/ase/stx/symbol.c +++ b/ase/stx/symbol.c @@ -1,14 +1,14 @@ /* - * $Id: symbol.c,v 1.8 2005-05-29 16:51:16 bacon Exp $ + * $Id: symbol.c,v 1.9 2005-06-08 16:00:51 bacon Exp $ */ #include #include #include -xp_stx_word_t xp_stx_new_symlink (xp_stx_t* stx, xp_stx_word_t sym) +xp_word_t xp_stx_new_symlink (xp_stx_t* stx, xp_word_t sym) { - xp_stx_word_t x; + xp_word_t x; x = xp_stx_alloc_word_object (stx, XP_STX_SYMLINK_SIZE); XP_STX_CLASS(stx,x) = stx->class_symlink; @@ -18,9 +18,9 @@ xp_stx_word_t xp_stx_new_symlink (xp_stx_t* stx, xp_stx_word_t sym) return x; } -xp_stx_word_t xp_stx_new_symbol (xp_stx_t* stx, const xp_stx_char_t* name) +xp_word_t xp_stx_new_symbol (xp_stx_t* stx, const xp_char_t* name) { - xp_stx_word_t x, hash, table, link, next; + xp_word_t x, hash, table, link, next; table = stx->symbol_table; hash = xp_stx_strhash(name) % XP_STX_SIZE(stx,table); @@ -34,7 +34,7 @@ xp_stx_word_t xp_stx_new_symbol (xp_stx_t* stx, const xp_stx_char_t* name) else { do { x = XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_SYMBOL); - xp_stx_assert (XP_STX_CLASS(stx,x) == stx->class_symbol); + xp_assert (XP_STX_CLASS(stx,x) == stx->class_symbol); if (xp_stx_strxcmp ( &XP_STX_CHARAT(stx,x,0), @@ -56,10 +56,10 @@ xp_stx_word_t xp_stx_new_symbol (xp_stx_t* stx, const xp_stx_char_t* name) return x; } -xp_stx_word_t xp_stx_new_symbolx ( - xp_stx_t* stx, const xp_stx_char_t* name, xp_stx_word_t len) +xp_word_t xp_stx_new_symbolx ( + xp_stx_t* stx, const xp_char_t* name, xp_word_t len) { - xp_stx_word_t x, hash, table, link, next; + xp_word_t x, hash, table, link, next; table = stx->symbol_table; hash = xp_stx_strhash(name) % XP_STX_SIZE(stx,table); @@ -73,7 +73,7 @@ xp_stx_word_t xp_stx_new_symbolx ( else { do { x = XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_SYMBOL); - xp_stx_assert (XP_STX_CLASS(stx,x) == stx->class_symbol); + xp_assert (XP_STX_CLASS(stx,x) == stx->class_symbol); if (xp_stx_strxcmp ( &XP_STX_CHARAT(stx,x,0), @@ -95,11 +95,11 @@ xp_stx_word_t xp_stx_new_symbolx ( return x; } -xp_stx_word_t xp_stx_new_symbol_pp ( - xp_stx_t* stx, const xp_stx_char_t* name, - const xp_stx_char_t* prefix, const xp_stx_char_t* postfix) +xp_word_t xp_stx_new_symbol_pp ( + xp_stx_t* stx, const xp_char_t* name, + const xp_char_t* prefix, const xp_char_t* postfix) { - xp_stx_word_t x, hash, table, link, next; + xp_word_t x, hash, table, link, next; table = stx->symbol_table; hash = xp_stx_strhash(name) % XP_STX_SIZE(stx,table); @@ -113,7 +113,7 @@ xp_stx_word_t xp_stx_new_symbol_pp ( else { do { x = XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_SYMBOL); - xp_stx_assert (XP_STX_CLASS(stx,x) == stx->class_symbol); + xp_assert (XP_STX_CLASS(stx,x) == stx->class_symbol); if (xp_stx_strxcmp ( &XP_STX_CHARAT(stx,x,0), @@ -137,11 +137,11 @@ xp_stx_word_t xp_stx_new_symbol_pp ( } void xp_stx_traverse_symbol_table ( - xp_stx_t* stx, void (*func) (xp_stx_t*,xp_stx_word_t)) + xp_stx_t* stx, void (*func) (xp_stx_t*,xp_word_t)) { - xp_stx_word_t link; - xp_stx_word_t size; - xp_stx_word_t table; + xp_word_t link; + xp_word_t size; + xp_word_t table; table = stx->symbol_table; size = XP_STX_SIZE(stx,table); diff --git a/ase/stx/symbol.h b/ase/stx/symbol.h index 5d521ea6..c3e0b5e0 100644 --- a/ase/stx/symbol.h +++ b/ase/stx/symbol.h @@ -1,5 +1,5 @@ /* - * $Id: symbol.h,v 1.5 2005-05-23 15:51:03 bacon Exp $ + * $Id: symbol.h,v 1.6 2005-06-08 16:00:51 bacon Exp $ */ #ifndef _XP_STX_SYMBOL_H_ @@ -14,8 +14,8 @@ struct xp_stx_symlink_t { xp_stx_objhdr_t header; - xp_stx_word_t link; - xp_stx_word_t symbol; + xp_word_t link; + xp_word_t symbol; }; typedef struct xp_stx_symlink_t xp_stx_symlink_t; @@ -24,18 +24,18 @@ typedef struct xp_stx_symlink_t xp_stx_symlink_t; extern "C" { #endif -xp_stx_word_t xp_stx_new_symbol_link (xp_stx_t* stx, xp_stx_word_t sym); +xp_word_t xp_stx_new_symbol_link (xp_stx_t* stx, xp_word_t sym); -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_symbolx ( - xp_stx_t* stx, const xp_stx_char_t* name, xp_stx_word_t len); +xp_word_t xp_stx_new_symbol ( + xp_stx_t* stx, const xp_char_t* name); +xp_word_t xp_stx_new_symbolx ( + xp_stx_t* stx, const xp_char_t* name, xp_word_t len); -xp_stx_word_t xp_stx_new_symbol_pp ( - xp_stx_t* stx, const xp_stx_char_t* name, - const xp_stx_char_t* prefix, const xp_stx_char_t* postfix); +xp_word_t xp_stx_new_symbol_pp ( + xp_stx_t* stx, const xp_char_t* name, + const xp_char_t* prefix, const xp_char_t* postfix); void xp_stx_traverse_symbol_table ( - xp_stx_t* stx, void (*func) (xp_stx_t*,xp_stx_word_t)); + xp_stx_t* stx, void (*func) (xp_stx_t*,xp_word_t)); #ifdef __cplusplus } diff --git a/ase/stx/token.c b/ase/stx/token.c index ed91ccb5..1876ee53 100644 --- a/ase/stx/token.c +++ b/ase/stx/token.c @@ -1,27 +1,27 @@ /* - * $Id: token.c,v 1.4 2005-05-30 15:01:01 bacon Exp $ + * $Id: token.c,v 1.5 2005-06-08 16:00:51 bacon Exp $ */ #include #include xp_stx_token_t* xp_stx_token_open ( - xp_stx_token_t* token, xp_stx_word_t capacity) + xp_stx_token_t* token, xp_word_t capacity) { - xp_stx_assert (capacity > 0); + xp_assert (capacity > 0); if (token == XP_NULL) { token = (xp_stx_token_t*) - xp_stx_malloc (xp_sizeof(xp_stx_token_t)); + xp_malloc (xp_sizeof(xp_stx_token_t)); if (token == XP_NULL) return XP_NULL; token->__malloced = xp_true; } else token->__malloced = xp_false; - token->buffer = (xp_stx_char_t*) - xp_stx_malloc ((capacity + 1) * xp_sizeof(xp_stx_char_t)); + token->buffer = (xp_char_t*) + xp_malloc ((capacity + 1) * xp_sizeof(xp_char_t)); if (token->buffer == XP_NULL) { - if (token->__malloced) xp_stx_free (token); + if (token->__malloced) xp_free (token); return XP_NULL; } @@ -32,30 +32,30 @@ xp_stx_token_t* xp_stx_token_open ( token->size = 0; token->capacity = capacity; - token->buffer[0] = XP_STX_CHAR('\0'); + token->buffer[0] = XP_CHAR('\0'); return token; } void xp_stx_token_close (xp_stx_token_t* token) { - xp_stx_free (token->buffer); - if (token->__malloced) xp_stx_free (token); + xp_free (token->buffer); + if (token->__malloced) xp_free (token); } -int xp_stx_token_addc (xp_stx_token_t* token, xp_stx_cint_t c) +int xp_stx_token_addc (xp_stx_token_t* token, xp_cint_t c) { if (token->size >= token->capacity) { /* double the capacity. */ - xp_stx_char_t* space = (xp_stx_char_t*)xp_stx_realloc ( - token->buffer, (token->capacity * 2 + 1) * xp_sizeof(xp_stx_char_t)); + xp_char_t* space = (xp_char_t*)xp_realloc ( + token->buffer, (token->capacity * 2 + 1) * xp_sizeof(xp_char_t)); if (space == XP_NULL) return -1; token->buffer = space; token->capacity = token->capacity * 2; } token->buffer[token->size++] = c; - token->buffer[token->size] = XP_STX_CHAR('\0'); + token->buffer[token->size] = XP_CHAR('\0'); return 0; } @@ -67,30 +67,30 @@ void xp_stx_token_clear (xp_stx_token_t* token) */ token->size = 0; - token->buffer[0] = XP_STX_CHAR('\0'); + token->buffer[0] = XP_CHAR('\0'); } -xp_stx_char_t* xp_stx_token_yield (xp_stx_token_t* token, xp_stx_word_t capacity) +xp_char_t* xp_stx_token_yield (xp_stx_token_t* token, xp_word_t capacity) { - xp_stx_char_t* old_buffer, * new_buffer; + xp_char_t* old_buffer, * new_buffer; - new_buffer = (xp_stx_char_t*) - xp_stx_malloc((capacity + 1) * xp_sizeof(xp_stx_char_t)); + new_buffer = (xp_char_t*) + xp_malloc((capacity + 1) * xp_sizeof(xp_char_t)); if (new_buffer == XP_NULL) return XP_NULL; old_buffer = token->buffer; token->buffer = new_buffer; token->size = 0; token->capacity = capacity; - token->buffer[0] = XP_STX_CHAR('\0'); + token->buffer[0] = XP_CHAR('\0'); return old_buffer; } -int xp_stx_token_compare (xp_stx_token_t* token, const xp_stx_char_t* str) +int xp_stx_token_compare (xp_stx_token_t* token, const xp_char_t* str) { - xp_stx_char_t* p = token->buffer; - xp_stx_word_t index = 0; + xp_char_t* p = token->buffer; + xp_word_t index = 0; while (index < token->size) { if (*p > *str) return 1; @@ -98,5 +98,5 @@ int xp_stx_token_compare (xp_stx_token_t* token, const xp_stx_char_t* str) index++; p++; str++; } - return (*str == XP_STX_CHAR('\0'))? 0: -1; + return (*str == XP_CHAR('\0'))? 0: -1; } diff --git a/ase/stx/token.h b/ase/stx/token.h index bd9ab84d..a6a5daa2 100644 --- a/ase/stx/token.h +++ b/ase/stx/token.h @@ -1,5 +1,5 @@ /* - * $Id: token.h,v 1.8 2005-06-08 15:49:35 bacon Exp $ + * $Id: token.h,v 1.9 2005-06-08 16:00:51 bacon Exp $ */ #ifndef _XP_STX_TOKEN_H_ @@ -35,9 +35,9 @@ struct xp_stx_token_t xp_stx_real_t fvalue; */ - xp_stx_word_t capacity; - xp_stx_word_t size; - xp_stx_char_t* buffer; + xp_word_t capacity; + xp_word_t size; + xp_char_t* buffer; xp_bool_t __malloced; }; @@ -49,13 +49,13 @@ extern "C" { #endif xp_stx_token_t* xp_stx_token_open ( - xp_stx_token_t* token, xp_stx_word_t capacity); + xp_stx_token_t* token, xp_word_t capacity); void xp_stx_token_close (xp_stx_token_t* token); -int xp_stx_token_addc (xp_stx_token_t* token, xp_stx_cint_t c); +int xp_stx_token_addc (xp_stx_token_t* token, xp_cint_t c); void xp_stx_token_clear (xp_stx_token_t* token); -xp_stx_char_t* xp_stx_token_yield (xp_stx_token_t* token, xp_stx_word_t capacity); -int xp_stx_token_compare (xp_stx_token_t* token, const xp_stx_char_t* str); +xp_char_t* xp_stx_token_yield (xp_stx_token_t* token, xp_word_t capacity); +int xp_stx_token_compare (xp_stx_token_t* token, const xp_char_t* str); #ifdef __cplusplus } diff --git a/ase/test/stx/parser.c b/ase/test/stx/parser.c index a657b877..958230cf 100644 --- a/ase/test/stx/parser.c +++ b/ase/test/stx/parser.c @@ -16,7 +16,7 @@ struct ss_t { - const xp_stx_char_t* text; + const xp_char_t* text; xp_size_t index; }; @@ -27,7 +27,7 @@ int ss_func (int cmd, void* owner, void* arg) if (cmd == XP_STX_PARSER_INPUT_OPEN) { ss_t* ss = *(ss_t**)owner; - ss->text = (const xp_stx_char_t*)arg; + ss->text = (const xp_char_t*)arg; ss->index = 0; return 0; } @@ -38,8 +38,8 @@ int ss_func (int cmd, void* owner, void* arg) else if (cmd == XP_STX_PARSER_INPUT_CONSUME) { ss_t* ss = (ss_t*)owner; xp_cint_t* c = (xp_cint_t*)arg; - if (ss->text[ss->index] == XP_STX_CHAR('\0')) { - *c = XP_STX_CHAR_EOF; + if (ss->text[ss->index] == XP_CHAR('\0')) { + *c = XP_CHAR_EOF; } else *c = ss->text[ss->index++]; return 0; @@ -78,7 +78,7 @@ int stdio_func (int cmd, void* owner, void* arg) xp_cint_t t = xp_fgetc (p->stdio); if (t == XP_CHAR_EOF) { if (xp_ferror (p->stdio)) return -1; - *c = XP_STX_CHAR_EOF; + *c = XP_CHAR_EOF; } else *c = t; return 0; @@ -92,7 +92,7 @@ int stdio_func (int cmd, void* owner, void* arg) int xp_main (int argc, xp_char_t* argv[]) { xp_stx_parser_t parser; - xp_stx_word_t i; + xp_word_t i; #ifdef __linux mtrace (); diff --git a/ase/test/stx/stx.c b/ase/test/stx/stx.c index e8c87cbc..95094212 100644 --- a/ase/test/stx/stx.c +++ b/ase/test/stx/stx.c @@ -15,22 +15,22 @@ #include #include -void print_symbol_names (xp_stx_t* stx, xp_stx_word_t sym) +void print_symbol_names (xp_stx_t* stx, xp_word_t sym) { xp_printf (XP_TEXT("%lu [%s]\n"), (unsigned long)sym, &XP_STX_CHARAT(stx,sym,0)); } -void print_symbol_names_2 (xp_stx_t* stx, xp_stx_word_t idx) +void print_symbol_names_2 (xp_stx_t* stx, xp_word_t idx) { - xp_stx_word_t key = XP_STX_WORDAT(stx,idx,XP_STX_PAIRLINK_KEY); - xp_stx_word_t value = XP_STX_WORDAT(stx,idx,XP_STX_PAIRLINK_VALUE); + xp_word_t key = XP_STX_WORDAT(stx,idx,XP_STX_PAIRLINK_KEY); + xp_word_t value = XP_STX_WORDAT(stx,idx,XP_STX_PAIRLINK_VALUE); xp_printf (XP_TEXT("%lu [%s] %lu\n"), (unsigned long)key, &XP_STX_CHARAT(stx,key,0), (unsigned long)value); } void print_superclasses (xp_stx_t* stx, const xp_char_t* name) { - xp_stx_word_t n; + xp_word_t n; xp_stx_class_t* obj; n = xp_stx_lookup_class (stx, name); @@ -47,7 +47,7 @@ void print_superclasses (xp_stx_t* stx, const xp_char_t* name) void print_metaclass_superclasses (xp_stx_t* stx, const xp_char_t* name) { - xp_stx_word_t n, x; + xp_word_t n, x; xp_stx_metaclass_t* obj; xp_stx_class_t* xobj; @@ -76,7 +76,7 @@ void print_metaclass_superclasses (xp_stx_t* stx, const xp_char_t* name) } } -void print_class_name (xp_stx_t* stx, xp_stx_word_t class, int tabs) +void print_class_name (xp_stx_t* stx, xp_word_t class, int tabs) { xp_stx_class_t* xobj; xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,class); @@ -88,7 +88,7 @@ void print_class_name (xp_stx_t* stx, xp_stx_word_t class, int tabs) (unsigned long)class); } -void print_metaclass_name (xp_stx_t* stx, xp_stx_word_t class, int tabs) +void print_metaclass_name (xp_stx_t* stx, xp_word_t class, int tabs) { xp_stx_metaclass_t* obj; xp_stx_class_t* xobj; @@ -103,7 +103,7 @@ void print_metaclass_name (xp_stx_t* stx, xp_stx_word_t class, int tabs) (unsigned long)class); } -void print_subclass_names (xp_stx_t* stx, xp_stx_word_t class, int tabs) +void print_subclass_names (xp_stx_t* stx, xp_word_t class, int tabs) { xp_stx_class_t* obj; @@ -116,7 +116,7 @@ void print_subclass_names (xp_stx_t* stx, xp_stx_word_t class, int tabs) } if (obj->subclasses != stx->nil) { - xp_stx_word_t count = XP_STX_SIZE(stx, obj->subclasses); + xp_word_t count = XP_STX_SIZE(stx, obj->subclasses); while (count-- > 0) { print_subclass_names (stx, XP_STX_WORDAT(stx,obj->subclasses,count), tabs + 1); @@ -126,7 +126,7 @@ void print_subclass_names (xp_stx_t* stx, xp_stx_word_t class, int tabs) void print_subclasses (xp_stx_t* stx, const xp_char_t* name) { - xp_stx_word_t class; + xp_word_t class; class = xp_stx_lookup_class (stx, name); xp_printf (XP_TEXT("== NORMAL == \n")); print_subclass_names (stx, class, 0); @@ -137,7 +137,7 @@ void print_subclasses (xp_stx_t* stx, const xp_char_t* name) int xp_main (int argc, xp_char_t* argv[]) { xp_stx_t stx; - xp_stx_word_t i; + xp_word_t i; #ifndef _DOS if (xp_setlocale () == -1) { @@ -173,33 +173,33 @@ int xp_main (int argc, xp_char_t* argv[]) xp_stx_hash_traverse (&stx, stx.smalltalk, print_symbol_names_2); xp_printf (XP_TEXT("-------------\n")); - print_superclasses (&stx, XP_STX_TEXT("Array")); + print_superclasses (&stx, XP_TEXT("Array")); xp_printf (XP_TEXT("-------------\n")); - print_metaclass_superclasses (&stx, XP_STX_TEXT("Array")); + print_metaclass_superclasses (&stx, XP_TEXT("Array")); xp_printf (XP_TEXT("-------------\n")); - print_superclasses (&stx, XP_STX_TEXT("False")); + print_superclasses (&stx, XP_TEXT("False")); xp_printf (XP_TEXT("-------------\n")); - print_metaclass_superclasses (&stx, XP_STX_TEXT("False")); + print_metaclass_superclasses (&stx, XP_TEXT("False")); xp_printf (XP_TEXT("-------------\n")); - print_superclasses (&stx, XP_STX_TEXT("Metaclass")); + print_superclasses (&stx, XP_TEXT("Metaclass")); xp_printf (XP_TEXT("-------------\n")); - print_metaclass_superclasses (&stx, XP_STX_TEXT("Metaclass")); + print_metaclass_superclasses (&stx, XP_TEXT("Metaclass")); xp_printf (XP_TEXT("-------------\n")); - print_superclasses (&stx, XP_STX_TEXT("Class")); + print_superclasses (&stx, XP_TEXT("Class")); xp_printf (XP_TEXT("-------------\n")); - print_metaclass_superclasses (&stx, XP_STX_TEXT("Class")); + print_metaclass_superclasses (&stx, XP_TEXT("Class")); xp_printf (XP_TEXT("-------------\n")); - print_subclasses (&stx, XP_STX_TEXT("Object")); + print_subclasses (&stx, XP_TEXT("Object")); xp_printf (XP_TEXT("-------------\n")); #if 0 { - xp_stx_word_t method_name; - xp_stx_word_t main_class; - xp_stx_word_t method, context; + xp_word_t method_name; + xp_word_t main_class; + xp_word_t method, context; - method_name = xp_stx_new_symbol (&stx,XP_STX_TEXT("main")); + method_name = xp_stx_new_symbol (&stx,XP_TEXT("main")); main_class = xp_stx_lookup_class (&stx,argv[1]); if (main_class == stx.nil) { @@ -211,7 +211,7 @@ int xp_main (int argc, xp_char_t* argv[]) method = xp_stx_alloc_byte_object (&stx,100); XP_STX_CLASS(&stx,method) = stx.class_method; */ - method = xp_stx_instantiate (&stx, XP_STX_TEXT("Method")); + method = xp_stx_instantiate (&stx, XP_TEXT("Method")); XP_STX_BYTEAT(&stx,method,0) = PUSH_OBJECT; XP_STX_BYTEAT(&stx,method,1) = main_class; @@ -222,7 +222,7 @@ int xp_main (int argc, xp_char_t* argv[]) /* context = xp_stx_new_context (&stx, method, stx.nil, stx.nil); */ - context = xp_stx_instantiate (&stx, XP_STX_TEXT("Context")); + context = xp_stx_instantiate (&stx, XP_TEXT("Context")); xp_stx_run_context (&stx, context); } #endif