Skip to content

Commit

Permalink
Implement (version) (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii authored Aug 2, 2024
1 parent 3757882 commit a4ada0c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/goldfish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ int main(int argc, char **argv) {
s7_load(sc, gf_boot.string().c_str());
s7_add_to_load_path(sc, gf_lib.string().c_str());

// Glues for the Standard Library
// Glues
glue_goldfish(sc);
glue_scheme_time(sc);

// Command options
Expand Down
18 changes: 17 additions & 1 deletion src/goldfish.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ const std::string goldfish_version = std::to_string(major_version)
.append(".")
.append(std::to_string(patch_version));

// Glues for Goldfish
static s7_pointer f_version(s7_scheme *sc, s7_pointer args) {
return s7_make_string(sc, goldfish_version.c_str());
}

inline void glue_goldfish(s7_scheme *sc) {
s7_pointer cur_env = s7_curlet(sc);

const char *s_version = "version";
const char *d_version = "(version) => string, return the "
"goldfish version";
s7_define(sc, cur_env, s7_make_symbol(sc, s_version),
s7_make_typed_function(sc, s_version, f_version, 0, 0, false,
d_version, NULL));
}

// Glues for (scheme time)
static s7_pointer f_current_second(s7_scheme *sc, s7_pointer args) {
auto now = std::chrono::system_clock::now();
Expand All @@ -38,7 +54,7 @@ static s7_pointer f_current_second(s7_scheme *sc, s7_pointer args) {
return s7_make_real(sc, res);
}

static void glue_scheme_time(s7_scheme *sc) {
inline void glue_scheme_time(s7_scheme *sc) {
s7_pointer cur_env = s7_curlet(sc);

const char *s_current_second = "g_current-second";
Expand Down

0 comments on commit a4ada0c

Please sign in to comment.