*** empty log message ***

This commit is contained in:
hyung-hwan 2005-09-19 03:05:37 +00:00
parent eea3aa9643
commit 38bc69f7cd
7 changed files with 26 additions and 16 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: init.c,v 1.3 2005-09-18 13:06:43 bacon Exp $ * $Id: init.c,v 1.4 2005-09-19 03:05:37 bacon Exp $
*/ */
#include <xp/lsp/lsp.h> #include <xp/lsp/lsp.h>
@ -38,7 +38,7 @@ xp_lsp_t* xp_lsp_open (xp_lsp_t* lsp,
return XP_NULL; return XP_NULL;
} }
if (xp_lsp_add_prims (lsp->mem) == -1) { if (xp_lsp_add_builtin_prims (lsp->mem) == -1) {
xp_lsp_mem_free (lsp->mem); xp_lsp_mem_free (lsp->mem);
xp_lsp_token_close (&lsp->token); xp_lsp_token_close (&lsp->token);
if (lsp->__malloced) xp_free (lsp); if (lsp->__malloced) xp_free (lsp);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: lsp.h,v 1.11 2005-09-18 14:05:16 bacon Exp $ * $Id: lsp.h,v 1.12 2005-09-19 03:05:37 bacon Exp $
*/ */
#ifndef _XP_LSP_LSP_H_ #ifndef _XP_LSP_LSP_H_
@ -44,13 +44,13 @@ enum
/* /*
* TYPEDEF: xp_lsp_t * TYPEDEF: xp_lsp_t
* Defines a lisp processor * Defines a lisp processor type
*/ */
typedef struct xp_lsp_t xp_lsp_t; typedef struct xp_lsp_t xp_lsp_t;
/* /*
* TYPEDEF: xp_lsp_io_t * TYPEDEF: xp_lsp_io_t
* Defines an IO handler * Defines an IO handler type
*/ */
typedef xp_ssize_t (*xp_lsp_io_t) ( typedef xp_ssize_t (*xp_lsp_io_t) (
int cmd, void* arg, xp_char_t* data, xp_size_t count); int cmd, void* arg, xp_char_t* data, xp_size_t count);
@ -62,6 +62,13 @@ enum
XP_LSP_IO_DATA XP_LSP_IO_DATA
}; };
/*
* TYPEDEF: xp_lsp_prim_t
* Defines a primitive type
*/
typedef xp_lsp_obj_t* (*xp_lsp_prim_t) (xp_lsp_t* lsp, xp_lsp_obj_t* obj);
struct xp_lsp_t struct xp_lsp_t
{ {
/* error number */ /* error number */
@ -186,12 +193,13 @@ int xp_lsp_print (xp_lsp_t* lsp, const xp_lsp_obj_t* obj);
* Adds a user-defined primitive * Adds a user-defined primitive
*/ */
int xp_lsp_add_prim (xp_lsp_t* lsp, const xp_char_t* name, xp_lsp_prim_t prim); int xp_lsp_add_prim (xp_lsp_t* lsp, const xp_char_t* name, xp_lsp_prim_t prim);
int xp_lsp_add_primx (xp_lsp_t* lsp, const xp_char_t* name, xp_size_t len, xp_lsp_prim_t prim);
/* /*
* FUNCTION: xp_lsp_remove_prim * FUNCTION: xp_lsp_remove_prim
* Removes a user-defined primitive * Removes a user-defined primitive
*/ */
int xp_lsp_add_prim (xp_lsp_t* lsp, const xp_char_t* name); int xp_lsp_remove_prim (xp_lsp_t* lsp, const xp_char_t* name);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,6 +1,6 @@
SRCS = name.c token.c array.c prim.c mem.c env.c init.c read.c eval.c print.c SRCS = name.c token.c array.c prim.c mem.c env.c init.c read.c eval.c print.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)
OUT = libxplisp.a OUT = libxplsp.a
CC = @CC@ CC = @CC@
RANLIB = @RANLIB@ RANLIB = @RANLIB@

View File

@ -1,5 +1,5 @@
/* /*
* $Id: mem.c,v 1.1 2005-09-18 11:34:35 bacon Exp $ * $Id: mem.c,v 1.2 2005-09-19 03:05:37 bacon Exp $
*/ */
#include <xp/lsp/mem.h> #include <xp/lsp/mem.h>
@ -92,7 +92,7 @@ void xp_lsp_mem_free (xp_lsp_mem_t* mem)
xp_free (mem); xp_free (mem);
} }
static int xp_lsp_add_prim ( static int __add_prim (
xp_lsp_mem_t* mem, const xp_char_t* name, xp_size_t len, xp_lsp_pimpl_t prim) xp_lsp_mem_t* mem, const xp_char_t* name, xp_size_t len, xp_lsp_pimpl_t prim)
{ {
xp_lsp_obj_t* n, * p; xp_lsp_obj_t* n, * p;
@ -113,11 +113,11 @@ static int xp_lsp_add_prim (
} }
int xp_lsp_add_prims (xp_lsp_mem_t* mem) int xp_lsp_add_builtin_prims (xp_lsp_mem_t* mem)
{ {
#define ADD_PRIM(mem,name,len,prim) \ #define ADD_PRIM(mem,name,len,prim) \
if (xp_lsp_add_prim(mem,name,len,prim) == -1) return -1; if (__add_prim(mem,name,len,prim) == -1) return -1;
ADD_PRIM (mem, XP_TEXT("abort"), 5, xp_lsp_prim_abort); ADD_PRIM (mem, XP_TEXT("abort"), 5, xp_lsp_prim_abort);
ADD_PRIM (mem, XP_TEXT("eval"), 4, xp_lsp_prim_eval); ADD_PRIM (mem, XP_TEXT("eval"), 4, xp_lsp_prim_eval);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: mem.h,v 1.2 2005-09-18 11:54:23 bacon Exp $ * $Id: mem.h,v 1.3 2005-09-19 03:05:37 bacon Exp $
*/ */
#ifndef _XP_LSP_MEM_H_ #ifndef _XP_LSP_MEM_H_
@ -54,7 +54,7 @@ extern "C" {
xp_lsp_mem_t* xp_lsp_mem_new (xp_size_t ubound, xp_size_t ubound_inc); xp_lsp_mem_t* xp_lsp_mem_new (xp_size_t ubound, xp_size_t ubound_inc);
void xp_lsp_mem_free (xp_lsp_mem_t* mem); void xp_lsp_mem_free (xp_lsp_mem_t* mem);
int xp_lsp_add_prims (xp_lsp_mem_t* mem); int xp_lsp_add_builtin_prims (xp_lsp_mem_t* mem);
xp_lsp_obj_t* xp_lsp_allocate (xp_lsp_mem_t* mem, int type, xp_size_t size); xp_lsp_obj_t* xp_lsp_allocate (xp_lsp_mem_t* mem, int type, xp_size_t size);
void xp_lsp_dispose (xp_lsp_mem_t* mem, xp_lsp_obj_t* prev, xp_lsp_obj_t* obj); void xp_lsp_dispose (xp_lsp_mem_t* mem, xp_lsp_obj_t* prev, xp_lsp_obj_t* obj);

View File

@ -155,7 +155,9 @@ int xp_main (int argc, xp_char_t* argv[])
xp_lsp_attach_output (lsp, put_output, XP_NULL); xp_lsp_attach_output (lsp, put_output, XP_NULL);
for (;;) { for (;;) {
xp_printf (XP_TEXT("%s> "), argv[0]); xp_sio_puts (xp_sio_out, argv[0]);
xp_sio_puts (xp_sio_out, XP_TEXT("> "));
xp_sio_flush (xp_sio_out);
obj = xp_lsp_read (lsp); obj = xp_lsp_read (lsp);
if (obj == XP_NULL) { if (obj == XP_NULL) {

View File

@ -3,8 +3,8 @@ 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/lsp
LIBS = @LIBS@ -lxpbas -lxplisp LIBS = @LIBS@ -lxpbas -lxplsp
all: $(OUTS) all: $(OUTS)