2014-08-25 00:38:09 -04:00
|
|
|
/**
|
|
|
|
* See Copyright Notice in picrin.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "picrin.h"
|
2016-02-20 10:58:58 -05:00
|
|
|
#include "picrin/extra.h"
|
2015-06-09 07:20:56 -04:00
|
|
|
|
2017-04-03 09:09:19 -04:00
|
|
|
#if PIC_USE_LIBRARY
|
|
|
|
|
2016-02-18 03:39:32 -05:00
|
|
|
void
|
2017-04-02 06:16:25 -04:00
|
|
|
pic_deflibrary(pic_state *pic, const char *lib)
|
2014-08-25 00:38:09 -04:00
|
|
|
{
|
2017-04-02 06:16:25 -04:00
|
|
|
pic_value name = pic_intern_cstr(pic, lib), v;
|
2014-08-25 00:38:09 -04:00
|
|
|
|
2017-04-02 06:16:25 -04:00
|
|
|
v = pic_funcall(pic, "find-library", 1, name);
|
|
|
|
if (! pic_bool(pic, v)) {
|
|
|
|
pic_funcall(pic, "make-library", 1, name);
|
2016-02-18 03:39:32 -05:00
|
|
|
}
|
2014-08-25 00:38:09 -04:00
|
|
|
}
|
|
|
|
|
2016-02-14 23:20:26 -05:00
|
|
|
void
|
2016-02-18 03:39:32 -05:00
|
|
|
pic_in_library(pic_state *pic, const char *lib)
|
2016-02-14 23:20:26 -05:00
|
|
|
{
|
2017-04-02 06:16:25 -04:00
|
|
|
pic_value name = pic_intern_cstr(pic, lib);
|
2016-02-14 23:20:26 -05:00
|
|
|
|
2017-04-02 06:16:25 -04:00
|
|
|
pic_funcall(pic, "current-library", 1, name);
|
2014-08-25 00:38:09 -04:00
|
|
|
}
|
|
|
|
|
2015-06-16 12:52:20 -04:00
|
|
|
void
|
2017-04-02 11:37:37 -04:00
|
|
|
pic_export(pic_state *pic, int n, ...)
|
2014-08-25 00:38:09 -04:00
|
|
|
{
|
2017-04-02 06:16:25 -04:00
|
|
|
size_t ai = pic_enter(pic);
|
|
|
|
va_list ap;
|
2016-02-18 03:39:32 -05:00
|
|
|
|
2017-04-02 06:16:25 -04:00
|
|
|
va_start(ap, n);
|
|
|
|
while (n--) {
|
|
|
|
pic_value var = pic_intern_cstr(pic, va_arg(ap, const char *));
|
|
|
|
pic_funcall(pic, "library-export", 2, var, var);
|
2015-06-16 11:03:52 -04:00
|
|
|
}
|
2017-04-02 06:16:25 -04:00
|
|
|
va_end(ap);
|
|
|
|
pic_leave(pic, ai);
|
2014-08-25 00:38:09 -04:00
|
|
|
}
|
2017-04-03 09:09:19 -04:00
|
|
|
|
|
|
|
#endif
|