diff options
Diffstat (limited to 'exts')
| -rw-r--r-- | exts/dict.c | 4 | ||||
| -rw-r--r-- | exts/exts.h | 10 | ||||
| -rw-r--r-- | exts/io.c | 4 | ||||
| -rw-r--r-- | exts/test_input.txt | 3 | ||||
| -rw-r--r-- | exts/tests/test_dict.lisp | 17 | ||||
| -rw-r--r-- | exts/tests/test_io.lisp | 15 | ||||
| -rw-r--r-- | exts/vector.c | 4 |
7 files changed, 16 insertions, 41 deletions
diff --git a/exts/dict.c b/exts/dict.c index 772e48f..670949a 100644 --- a/exts/dict.c +++ b/exts/dict.c @@ -15,7 +15,7 @@ typedef String2SExpRefTreeMapNode DictNode; LispUserdataMeta bamboo_lisp_dict_meta; -#define DICT_TYPEID "ext.core.dict" +#define DICT_TYPEID "ext.dict" static bool is_dict_impl(Interp *interp, SExpRef obj) { if (VALTYPE(obj) == kUserDataSExp && strcmp(DICT_TYPEID, REF(obj)->userdata_meta->type) == 0) { @@ -167,7 +167,7 @@ static SExpRef ext_dict_keys(Interp *interp, SExpRef args) { return lst; } -int bamboo_lisp_ext_init(Interp *interp) { +int bamboo_lisp_ext_dict_init(Interp *interp) { bamboo_lisp_dict_meta.type = DICT_TYPEID; bamboo_lisp_dict_meta.free = &dict_free; bamboo_lisp_dict_meta.gcmark = &dict_gcmark; diff --git a/exts/exts.h b/exts/exts.h new file mode 100644 index 0000000..a78fed1 --- /dev/null +++ b/exts/exts.h @@ -0,0 +1,10 @@ +#ifndef BAMBOO_LISP_EXTS_H_ +#define BAMBOO_LISP_EXTS_H_ + +#include <bamboo_lisp/interp.h> + +int bamboo_lisp_ext_vector_init(Interp *interp); +int bamboo_lisp_ext_io_init(Interp *interp); +int bamboo_lisp_ext_dict_init(Interp *interp); + +#endif
\ No newline at end of file @@ -6,7 +6,7 @@ #include <bamboo_lisp/interp.h> #include <bamboo_lisp/sexp.h> -#define STREAM_TYPEID "ext.core.stream" +#define STREAM_TYPEID "ext.stream" typedef struct { FILE *fp; @@ -275,7 +275,7 @@ static void stream_gcmark(Interp *interp, SExpPtrVector *gcstack, void *vself) { (void)vself; } -int bamboo_lisp_ext_init(Interp *interp) { +int bamboo_lisp_ext_io_init(Interp *interp) { bamboo_lisp_stream_meta.type = STREAM_TYPEID; bamboo_lisp_stream_meta.free = &stream_free; bamboo_lisp_stream_meta.gcmark = &stream_gcmark; diff --git a/exts/test_input.txt b/exts/test_input.txt deleted file mode 100644 index c5b2a08..0000000 --- a/exts/test_input.txt +++ /dev/null @@ -1,3 +0,0 @@ -abc123 -ascx -asc
\ No newline at end of file diff --git a/exts/tests/test_dict.lisp b/exts/tests/test_dict.lisp deleted file mode 100644 index 501faba..0000000 --- a/exts/tests/test_dict.lisp +++ /dev/null @@ -1,17 +0,0 @@ -(loadext "./dict.so") - -(defvar d (make-dict)) - -(dict-set d "a" 1) -(dict-set d "b" 2) -(dict-set d "c" 3) - -(assert (equal? (dict-keys d) (list "a" "b" "c"))) -(assert (equal? (dict-get d "a") 1)) -(assert (equal? (dict-get d "b") 2)) -(dict-set d "a" 5) -(assert (equal? (dict-get d "a") 5)) - -(dict-remove d "b") - -(assert (equal? (dict-keys d) (list "a" "c")))
\ No newline at end of file diff --git a/exts/tests/test_io.lisp b/exts/tests/test_io.lisp deleted file mode 100644 index 76b91ce..0000000 --- a/exts/tests/test_io.lisp +++ /dev/null @@ -1,15 +0,0 @@ -(loadext "io.so") - -(defvar fp (open-file "./test_input.txt" "r")) -(read-char fp) -(read-char fp) -(read-char fp) -(stream-close fp) - -(defvar fp (open-file "./test_input.txt" "r")) -(read-line fp) -(stream-close fp) - -(defvar fp (open-file "./test_input.txt" "r")) -(lines fp) -(stream-close fp)
\ No newline at end of file diff --git a/exts/vector.c b/exts/vector.c index 960cf5d..45471df 100644 --- a/exts/vector.c +++ b/exts/vector.c @@ -1,7 +1,7 @@ #include <bamboo_lisp/interp.h> #include <bamboo_lisp/sexp.h> -#define VECTOR_TYPEID "ext.core.vector" +#define VECTOR_TYPEID "ext.vector" LispUserdataMeta bamboo_lisp_array_meta; @@ -112,7 +112,7 @@ static void ext_vector_gcmark(Interp *interp, SExpPtrVector *gcstack, void *vsel } } -int bamboo_lisp_ext_init(Interp *interp) { +int bamboo_lisp_ext_vector_init(Interp *interp) { bamboo_lisp_array_meta.type = VECTOR_TYPEID; bamboo_lisp_array_meta.free = &ext_vector_free; bamboo_lisp_array_meta.gcmark = &ext_vector_gcmark; |
