From d0132c8edcab726b9e08ab48dc517842d943490a Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 8 Oct 2023 00:46:29 +0900 Subject: [PATCH] Fix struct `procedure` constructor Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- example/example.cpp | 2 +- example/example.ss | 8 ++++---- src/kernel/procedure.cpp | 21 ++++++++++----------- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 610a1d5d2..88ac7264b 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.28_amd64.deb +sudo apt install build/meevax_0.5.29_amd64.deb ``` or @@ -131,9 +131,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.28.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.29.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.28_amd64.deb` +| `package` | Generate debian package `meevax_0.5.29_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index d55306778..7c96be4ee 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.28 +0.5.29 diff --git a/example/example.cpp b/example/example.cpp index abf0036cd..9e7766003 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -4,7 +4,7 @@ using namespace meevax; // NOTE: DIRTY HACK extern "C" { - auto length_of_arguments(object const& xs) + auto arity(object const& xs) { return make(length(xs)); } diff --git a/example/example.ss b/example/example.ss index 3acedb112..863ece4b0 100644 --- a/example/example.ss +++ b/example/example.ss @@ -15,12 +15,12 @@ ; ------------------------------------------------------------------------------ -(define length-of-arguments - (procedure "build/libexample.so" 'length_of_arguments)) +(define arity + (procedure "build/libexample.so" 'arity)) -(check (procedure? length-of-arguments) => #t) +(check (procedure? arity) => #t) -(check (length-of-arguments 'hoge 42 #(1 2 3) 3.14) => 4) +(check (arity 'hoge 42 #(1 2 3) 3.14) => 4) ; ------------------------------------------------------------------------------ diff --git a/src/kernel/procedure.cpp b/src/kernel/procedure.cpp index 48bb892b5..2e1b09759 100644 --- a/src/kernel/procedure.cpp +++ b/src/kernel/procedure.cpp @@ -36,7 +36,7 @@ inline namespace kernel return os << magenta("#,(") << green("procedure") << " " << symbol(datum.name) << magenta(")"); } - auto dlopen(std::string const& libfoo_so) -> void * + auto dlopen(std::string const& filename) -> void * { auto dlclose = [](void * const handle) { @@ -52,18 +52,17 @@ inline namespace kernel try { - return dynamic_libraries.at(libfoo_so).get(); + return dynamic_libraries.at(filename).get(); } catch (std::out_of_range const&) { - if (auto handle = ::dlopen(libfoo_so.c_str(), RTLD_LAZY | RTLD_GLOBAL); handle) + if (auto handle = ::dlopen(filename.c_str(), RTLD_LAZY | RTLD_GLOBAL); handle) { - dynamic_libraries.emplace( - std::piecewise_construct, - std::forward_as_tuple(libfoo_so), - std::forward_as_tuple(handle, dlclose)); + dynamic_libraries.emplace(std::piecewise_construct, + std::forward_as_tuple(filename), + std::forward_as_tuple(handle, dlclose)); - return dlopen(libfoo_so); + return dlopen(filename); } else { @@ -72,9 +71,9 @@ inline namespace kernel } } - auto dlsym(std::string const& name, void * const handle) -> FUNCTION((*)) + auto dlsym(std::string const& symbol, void * const handle) -> FUNCTION((*)) { - if (auto address = ::dlsym(handle, name.c_str()); address) + if (auto address = ::dlsym(handle, symbol.c_str()); address) { return reinterpret_cast(address); } @@ -85,7 +84,7 @@ inline namespace kernel } procedure::procedure(std::string const& filename, std::string const& symbol) - : procedure { name, dlsym(symbol, dlopen(filename)) } + : procedure { filename, dlsym(symbol, dlopen(filename)) } {} } // namespace kernel } // namespace meevax