*** empty log message ***

This commit is contained in:
hyung-hwan 2005-05-10 15:15:57 +00:00
parent a0dab9e557
commit 6ef4cc08c2
4 changed files with 58 additions and 46 deletions

View File

@ -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 <xp/stx/hash.h>
@ -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; */

View File

@ -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 <xp/stx/object.h>
#include <xp/stx/memory.h>
#include <xp/bas/string.h>
#include <xp/bas/assert.h>
#include <xp/bas/stdarg.h>
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;
}
*/

View File

@ -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);

View File

@ -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