From 490c97cd814476224bbcce974dae8c7df7d56870 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 17 Jun 2015 00:03:52 +0900 Subject: [PATCH] add library-name and current-library --- extlib/benz/lib.c | 34 ++++++++++++++++++++++++++++++++++ piclib/picrin/base.scm | 2 ++ 2 files changed, 36 insertions(+) diff --git a/extlib/benz/lib.c b/extlib/benz/lib.c index cc1eb503..893cc36e 100644 --- a/extlib/benz/lib.c +++ b/extlib/benz/lib.c @@ -336,6 +336,38 @@ pic_lib_find_library(pic_state *pic) return pic_obj_value(lib); } +static pic_value +pic_lib_current_library(pic_state *pic) +{ + pic_value lib; + size_t n; + + n = pic_get_args(pic, "|o", &lib); + + if (n == 0) { + return pic_obj_value(pic->lib); + } + else { + pic_assert_type(pic, lib, lib); + + pic->lib = pic_lib_ptr(lib); + + return pic_undef_value(); + } +} + +static pic_value +pic_lib_library_name(pic_state *pic) +{ + pic_value lib; + + pic_get_args(pic, "o", &lib); + + pic_assert_type(pic, lib, lib); + + return pic_lib_ptr(lib)->name; +} + static pic_value pic_lib_library_exports(pic_state *pic) { @@ -378,6 +410,8 @@ pic_init_lib(pic_state *pic) pic_defun(pic, "make-library", pic_lib_make_library); pic_defun(pic, "find-library", pic_lib_find_library); + pic_defun(pic, "current-library", pic_lib_current_library); + pic_defun(pic, "library-name", pic_lib_library_name); pic_defun(pic, "library-exports", pic_lib_library_exports); pic_defun(pic, "library-environment", pic_lib_library_environment); } diff --git a/piclib/picrin/base.scm b/piclib/picrin/base.scm index edbac8c1..224043fb 100644 --- a/piclib/picrin/base.scm +++ b/piclib/picrin/base.scm @@ -254,6 +254,8 @@ (export make-library find-library + current-library + library-name library-exports library-environment)