*** empty log message ***
This commit is contained in:
		| @ -1,10 +1,11 @@ | |||||||
| /* | /* | ||||||
|  * $Id: stx.c,v 1.2 2005-05-08 10:31:24 bacon Exp $ |  * $Id: stx.c,v 1.3 2005-05-08 10:44:58 bacon Exp $ | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <xp/stx/stx.h> | #include <xp/stx/stx.h> | ||||||
| #include <xp/stx/memory.h> | #include <xp/stx/memory.h> | ||||||
| #include <xp/bas/memory.h> | #include <xp/bas/memory.h> | ||||||
|  | #include <xp/bas/assert.h> | ||||||
|  |  | ||||||
| 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_stx_word_t capacity) | ||||||
| { | { | ||||||
| @ -33,4 +34,16 @@ void xp_stx_close (xp_stx_t* stx) | |||||||
| 	if (stx->__malloced) xp_free (stx); | 	if (stx->__malloced) xp_free (stx); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int xp_stx_bootstrap (xp_stx_t* stx) | ||||||
|  | { | ||||||
|  | 	stx->nil = xp_stx_memory_alloc (&stx->memory, 0); | ||||||
|  | 	stx->true = xp_stx_memory_alloc (&stx->memory, 0); | ||||||
|  | 	stx->false = xp_stx_memory_alloc (&stx->memory, 0); | ||||||
|  |  | ||||||
|  | 	xp_assert (stx->nil == XP_STX_NIL); | ||||||
|  | 	xp_assert (stx->true == XP_STX_TRUE); | ||||||
|  | 	xp_assert (stx->false == XP_STX_FALSE); | ||||||
|  |  | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
|  * $Id: stx.h,v 1.2 2005-05-08 10:31:24 bacon Exp $ |  * $Id: stx.h,v 1.3 2005-05-08 10:44:58 bacon Exp $ | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #ifndef _XP_STX_STX_H_ | #ifndef _XP_STX_STX_H_ | ||||||
| @ -115,8 +115,6 @@ struct xp_stx_t | |||||||
|  |  | ||||||
| */ | */ | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| @ -124,6 +122,8 @@ extern "C" { | |||||||
| 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_stx_word_t capacity); | ||||||
| void xp_stx_close (xp_stx_t* stx); | void xp_stx_close (xp_stx_t* stx); | ||||||
|  |  | ||||||
|  | int xp_stx_bootstrap (xp_stx_t* stx); | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ OUTS = $(SRCS:.c=.x) | |||||||
|  |  | ||||||
| CC = @CC@ | CC = @CC@ | ||||||
| CFLAGS = @CFLAGS@ -I@abs_top_builddir@ | CFLAGS = @CFLAGS@ -I@abs_top_builddir@ | ||||||
| LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/xp/bas -L@abs_top_builddir@/xp/lisp | LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/xp/bas -L@abs_top_builddir@/xp/stx | ||||||
| LIBS = @LIBS@ -lxpstx -lxpbas | LIBS = @LIBS@ -lxpstx -lxpbas | ||||||
|  |  | ||||||
| all: $(OUTS) | all: $(OUTS) | ||||||
|  | |||||||
| @ -7,13 +7,15 @@ int xp_main () | |||||||
| 	xp_stx_word_t i; | 	xp_stx_word_t i; | ||||||
|  |  | ||||||
| 	if (xp_stx_open (&stx, 10) == XP_NULL) { | 	if (xp_stx_open (&stx, 10) == XP_NULL) { | ||||||
| 		xp_printf (XP_TEXT("cannot open memory\n")); | 		xp_printf (XP_TEXT("cannot open stx\n")); | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	stx.nil = xp_stx_memory_alloc(&stx.memory, 0); | 	if (xp_stx_bootstrap(&stx) == -1) { | ||||||
| 	stx.true = xp_stx_memory_alloc(&stx.memory, 0); | 		xp_stx_close (&stx); | ||||||
| 	stx.false = xp_stx_memory_alloc(&stx.memory, 0); | 		xp_printf (XP_TEXT("cannot bootstrap\n")); | ||||||
|  | 		return -1; | ||||||
|  | 	}	 | ||||||
|  |  | ||||||
| 	xp_printf (XP_TEXT("stx.nil %d\n"), stx.nil); | 	xp_printf (XP_TEXT("stx.nil %d\n"), stx.nil); | ||||||
| 	xp_printf (XP_TEXT("stx.true %d\n"), stx.true); | 	xp_printf (XP_TEXT("stx.true %d\n"), stx.true); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user