Skip to content

Commit

Permalink
Merge pull request #469 from yamacir-kit/release-candidate
Browse files Browse the repository at this point in the history
Release candidate
  • Loading branch information
yamacir-kit authored Dec 16, 2023
2 parents f31503a + 7cbf0be commit 1748222
Show file tree
Hide file tree
Showing 60 changed files with 1,957 additions and 1,145 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,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.66_amd64.deb
sudo apt install build/meevax_0.5.107_amd64.deb
```

or
Expand Down Expand Up @@ -123,9 +123,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.66.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.107.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.66_amd64.deb`
| `package` | Generate debian package `meevax_0.5.107_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.66
0.5.107
3 changes: 1 addition & 2 deletions basis/srfi-4.ss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(define-library (srfi 4)
(import (meevax vector homogeneous))
(export
f32vector? make-f32vector f32vector f32vector-length f32vector-ref
(export f32vector? make-f32vector f32vector f32vector-length f32vector-ref
f32vector-set! f32vector->list list->f32vector

f64vector? make-f64vector f64vector f64vector-length f64vector-ref
Expand Down
12 changes: 9 additions & 3 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ find_package(Meevax REQUIRED) # NOTE: case-insensitive

add_library(${PROJECT_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.cpp)

target_compile_options(${PROJECT_NAME} PUBLIC "-Wno-return-type-c-linkage")

target_link_libraries(${PROJECT_NAME} PRIVATE Meevax::kernel)

enable_testing()

add_test(NAME ${PROJECT_NAME}
COMMAND meevax ${PROJECT_NAME}.ss
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_test(
NAME ${PROJECT_NAME}
COMMAND meevax ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.ss)

set_property(
TEST ${PROJECT_NAME}
PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_CURRENT_BINARY_DIR}")

add_custom_target(develop COMMAND ${CMAKE_MAKE_PROGRAM}
COMMAND ${CMAKE_CTEST_COMMAND})
8 changes: 4 additions & 4 deletions example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using namespace meevax; // NOTE: DIRTY HACK

extern "C"
{
auto arity(object & xs)
auto argument_length(object & xs)
{
return make<exact_integer>(length(xs));
}
Expand Down Expand Up @@ -47,16 +47,16 @@ extern "C"

auto make_hoge(object & xs)
{
return make<hoge>(xs[0].as<exact_integer>());
return make<hoge>(car(xs).as<exact_integer>());
}

auto is_hoge(object & xs)
{
return xs[0].is<hoge>() ? t : f;
return car(xs).is<hoge>() ? t : f;
}

auto hoge_value(object & xs)
{
return make<exact_integer>(xs[0].as<hoge>().value);
return make<exact_integer>(car(xs).as<hoge>().value);
}
}
19 changes: 11 additions & 8 deletions example/example.ss
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,37 @@
(scheme write)
(srfi 78))

(display (get-environment-variable "LD_LIBRARY_PATH"))
(newline)

; ------------------------------------------------------------------------------

(define dummy-procedure
(procedure "build/libexample.so" 'dummy_procedure))
(procedure "libexample.so" 'dummy_procedure))

(check (procedure? dummy-procedure) => #t)

(check (dummy-procedure 'hoge 42 #(1 2 3) 3.14) => 43)

; ------------------------------------------------------------------------------

(define arity
(procedure "build/libexample.so" 'arity))
(define argument-length
(procedure "libexample.so" 'argument_length))

(check (procedure? arity) => #t)
(check (procedure? argument-length) => #t)

(check (arity 'hoge 42 #(1 2 3) 3.14) => 4)
(check (argument-length 'hoge 42 #(1 2 3) 3.14) => 4)

; ------------------------------------------------------------------------------

(define make-hoge
(procedure "build/libexample.so" 'make_hoge))
(procedure "libexample.so" 'make_hoge))

(define hoge?
(procedure "build/libexample.so" 'is_hoge))
(procedure "libexample.so" 'is_hoge))

(define hoge-value
(procedure "build/libexample.so" 'hoge_value))
(procedure "libexample.so" 'hoge_value))

(check (procedure? make-hoge) => #t)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
limitations under the License.
*/

#ifndef INCLUDED_MEEVAX_MEMORY_BIT_CAST_HPP
#define INCLUDED_MEEVAX_MEMORY_BIT_CAST_HPP
#ifndef INCLUDED_MEEVAX_BIT_BIT_CAST_HPP
#define INCLUDED_MEEVAX_BIT_BIT_CAST_HPP

#include <cstring>

#include <meevax/type_traits/requires.hpp>

namespace meevax
{
inline namespace memory
inline namespace bit
{
template <typename To,
typename From,
Expand All @@ -37,7 +37,7 @@ inline namespace memory
std::memcpy(&to, &from, sizeof from);
return to;
}
} // namespace memory
} // namespace bit
} // namespace meevax

#endif // INCLUDED_MEEVAX_MEMORY_BIT_CAST_HPP
#endif // INCLUDED_MEEVAX_BIT_BIT_CAST_HPP
41 changes: 41 additions & 0 deletions include/meevax/bit/log2.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright 2018-2023 Tatsuya Yamasaki.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef INCLUDED_MEEVAX_BIT_LOG2_HPP
#define INCLUDED_MEEVAX_BIT_LOG2_HPP

namespace meevax
{
inline namespace bit
{
template <typename T>
constexpr auto log2(T x) noexcept -> T
{
return (x < 2) ? 1 : log2(x / 2) + 1;
}

static_assert(log2(0b0001) == 1);
static_assert(log2(0b0010) == 2);
static_assert(log2(0b0011) == 2);
static_assert(log2(0b0100) == 3);
static_assert(log2(0b0101) == 3);
static_assert(log2(0b0110) == 3);
static_assert(log2(0b0111) == 3);
static_assert(log2(0b1000) == 4);
} // namespace bit
} // namespace meevax

#endif // INCLUDED_MEEVAX_BIT_LOG2_HPP
52 changes: 52 additions & 0 deletions include/meevax/bitset/simple_bitset.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright 2018-2023 Tatsuya Yamasaki.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef INCLUDED_MEEVAX_BITSET_SIMPLE_BITSET_HPP
#define INCLUDED_MEEVAX_BITSET_SIMPLE_BITSET_HPP

#include <array>
#include <bitset>

namespace meevax
{
inline namespace bitset
{
template <auto N>
struct simple_bitset : public std::array<bool, N>
{
constexpr simple_bitset()
: std::array<bool, N> {}
{}

auto reset(std::size_t i) noexcept -> void
{
(*this)[i] = false;
}

auto set(std::size_t i) noexcept -> void
{
(*this)[i] = true;
}

auto test(std::size_t i) const noexcept -> bool
{
return (*this)[i];
}
};
} // namespace bitset
} // namespace meevax

#endif // INCLUDED_MEEVAX_BITSET_SIMPLE_BITSET_HPP
45 changes: 45 additions & 0 deletions include/meevax/chrono/duration.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2018-2023 Tatsuya Yamasaki.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef INCLUDED_MEEVAX_CHRONO_DURATION_HPP
#define INCLUDED_MEEVAX_CHRONO_DURATION_HPP

#include <chrono>
#include <iostream>

namespace meevax
{
inline namespace chrono
{
using days = std::chrono::duration<std::size_t, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>;

using years = std::chrono::duration<std::size_t, std::ratio_multiply<std::ratio<146097, 400>, days::period>>;

using months = std::chrono::duration<std::size_t, std::ratio_divide<years::period, std::ratio<12>>>;

template <typename Thunk>
auto duration(Thunk thunk)
{
auto begin = std::chrono::high_resolution_clock::now();
thunk();
return std::chrono::high_resolution_clock::now() - begin;
}

auto operator <<(std::ostream &, std::chrono::nanoseconds) -> std::ostream &;
} // namespace chrono
} // namespace meevax

#endif // INCLUDED_MEEVAX_CHRONO_DURATION_HPP
Loading

0 comments on commit 1748222

Please sign in to comment.