split built-in functins into libraries
This commit is contained in:
parent
906f2c8a93
commit
dda8ad367c
|
@ -127,6 +127,15 @@ void pic_in_library(pic_state *, pic_value);
|
|||
struct pic_lib *pic_make_library(pic_state *, pic_value);
|
||||
struct pic_lib *pic_find_library(pic_state *, pic_value);
|
||||
|
||||
#define DEFLIBRARY(pic,name) \
|
||||
{ \
|
||||
struct pic_lib *lib__ = pic->lib; \
|
||||
pic_make_library(pic, pic_parse(pic, name)); \
|
||||
pic_in_library(pic, pic_parse(pic, name));
|
||||
#define ENDLIBRARY(pic) \
|
||||
pic->lib = lib__; \
|
||||
}
|
||||
|
||||
void pic_export(pic_state *, pic_sym);
|
||||
void pic_export_as(pic_state *, pic_sym, pic_sym);
|
||||
|
||||
|
|
16
src/file.c
16
src/file.c
|
@ -105,10 +105,14 @@ pic_file_delete(pic_state *pic)
|
|||
void
|
||||
pic_init_file(pic_state *pic)
|
||||
{
|
||||
pic_defun(pic, "open-input-file", pic_file_open_input_file);
|
||||
pic_defun(pic, "open-input-binary-file", pic_file_open_input_binary_file);
|
||||
pic_defun(pic, "open-output-file", pic_file_open_output_file);
|
||||
pic_defun(pic, "open-output-binary-file", pic_file_open_output_binary_file);
|
||||
pic_defun(pic, "file-exists?", pic_file_exists_p);
|
||||
pic_defun(pic, "delete-file", pic_file_delete);
|
||||
DEFLIBRARY(pic, "(scheme file)")
|
||||
{
|
||||
pic_defun(pic, "open-input-file", pic_file_open_input_file);
|
||||
pic_defun(pic, "open-input-binary-file", pic_file_open_input_binary_file);
|
||||
pic_defun(pic, "open-output-file", pic_file_open_output_file);
|
||||
pic_defun(pic, "open-output-binary-file", pic_file_open_output_binary_file);
|
||||
pic_defun(pic, "file-exists?", pic_file_exists_p);
|
||||
pic_defun(pic, "delete-file", pic_file_delete);
|
||||
}
|
||||
ENDLIBRARY(pic)
|
||||
}
|
||||
|
|
|
@ -331,11 +331,16 @@ pic_init_port(pic_state *pic)
|
|||
pic_defun(pic, "port?", pic_port_port_p);
|
||||
pic_defun(pic, "input-port-open?", pic_port_input_port_open_p);
|
||||
pic_defun(pic, "output-port-open?", pic_port_output_port_open_p);
|
||||
pic_defun(pic, "write", pic_port_write);
|
||||
pic_defun(pic, "newline", pic_port_newline);
|
||||
pic_defun(pic, "eof-object?", pic_port_eof_object_p);
|
||||
pic_defun(pic, "eof-object", pic_port_eof_object);
|
||||
pic_defun(pic, "close-port", pic_port_close_port);
|
||||
pic_defun(pic, "close-input-port", pic_port_close_port);
|
||||
pic_defun(pic, "close-output-port", pic_port_close_port);
|
||||
|
||||
DEFLIBRARY(pic, "(scheme write)")
|
||||
{
|
||||
pic_defun(pic, "write", pic_port_write);
|
||||
pic_defun(pic, "newline", pic_port_newline);
|
||||
}
|
||||
ENDLIBRARY(pic)
|
||||
}
|
||||
|
|
14
src/system.c
14
src/system.c
|
@ -115,9 +115,13 @@ pic_system_getenvs(pic_state *pic)
|
|||
void
|
||||
pic_init_system(pic_state *pic)
|
||||
{
|
||||
pic_defun(pic, "command-line", pic_system_cmdline);
|
||||
pic_defun(pic, "exit", pic_system_exit);
|
||||
pic_defun(pic, "emergency-exit", pic_system_emergency_exit);
|
||||
pic_defun(pic, "get-environment-variable", pic_system_getenv);
|
||||
pic_defun(pic, "get-environment-variables", pic_system_getenvs);
|
||||
DEFLIBRARY(pic, "(scheme process-context)")
|
||||
{
|
||||
pic_defun(pic, "command-line", pic_system_cmdline);
|
||||
pic_defun(pic, "exit", pic_system_exit);
|
||||
pic_defun(pic, "emergency-exit", pic_system_emergency_exit);
|
||||
pic_defun(pic, "get-environment-variable", pic_system_getenv);
|
||||
pic_defun(pic, "get-environment-variables", pic_system_getenvs);
|
||||
}
|
||||
ENDLIBRARY(pic)
|
||||
}
|
||||
|
|
10
src/time.c
10
src/time.c
|
@ -37,7 +37,11 @@ pic_jiffies_per_second(pic_state *pic)
|
|||
void
|
||||
pic_init_time(pic_state *pic)
|
||||
{
|
||||
pic_defun(pic, "current-second", pic_current_second);
|
||||
pic_defun(pic, "current-jiffy", pic_current_jiffy);
|
||||
pic_defun(pic, "jiffies-per-second", pic_jiffies_per_second);
|
||||
DEFLIBRARY(pic, "(scheme time)")
|
||||
{
|
||||
pic_defun(pic, "current-second", pic_current_second);
|
||||
pic_defun(pic, "current-jiffy", pic_current_jiffy);
|
||||
pic_defun(pic, "jiffies-per-second", pic_jiffies_per_second);
|
||||
}
|
||||
ENDLIBRARY(pic)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue