Skip to content

Commit 1748222

Browse files
authored
Merge pull request #469 from yamacir-kit/release-candidate
Release candidate
2 parents f31503a + 7cbf0be commit 1748222

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1957
-1145
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Procedures for each standard are provided by the following R7RS-style libraries:
9191
cmake -B build -DCMAKE_BUILD_TYPE=Release
9292
cd build
9393
make package
94-
sudo apt install build/meevax_0.5.66_amd64.deb
94+
sudo apt install build/meevax_0.5.107_amd64.deb
9595
```
9696

9797
or
@@ -123,9 +123,9 @@ sudo rm -rf /usr/local/share/meevax
123123

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

131131
## Usage

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.66
1+
0.5.107

basis/srfi-4.ss

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
(define-library (srfi 4)
22
(import (meevax vector homogeneous))
3-
(export
4-
f32vector? make-f32vector f32vector f32vector-length f32vector-ref
3+
(export f32vector? make-f32vector f32vector f32vector-length f32vector-ref
54
f32vector-set! f32vector->list list->f32vector
65

76
f64vector? make-f64vector f64vector f64vector-length f64vector-ref

example/CMakeLists.txt

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ find_package(Meevax REQUIRED) # NOTE: case-insensitive
88

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

11+
target_compile_options(${PROJECT_NAME} PUBLIC "-Wno-return-type-c-linkage")
12+
1113
target_link_libraries(${PROJECT_NAME} PRIVATE Meevax::kernel)
1214

1315
enable_testing()
1416

15-
add_test(NAME ${PROJECT_NAME}
16-
COMMAND meevax ${PROJECT_NAME}.ss
17-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
17+
add_test(
18+
NAME ${PROJECT_NAME}
19+
COMMAND meevax ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.ss)
20+
21+
set_property(
22+
TEST ${PROJECT_NAME}
23+
PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_CURRENT_BINARY_DIR}")
1824

1925
add_custom_target(develop COMMAND ${CMAKE_MAKE_PROGRAM}
2026
COMMAND ${CMAKE_CTEST_COMMAND})

example/example.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using namespace meevax; // NOTE: DIRTY HACK
44

55
extern "C"
66
{
7-
auto arity(object & xs)
7+
auto argument_length(object & xs)
88
{
99
return make<exact_integer>(length(xs));
1010
}
@@ -47,16 +47,16 @@ extern "C"
4747

4848
auto make_hoge(object & xs)
4949
{
50-
return make<hoge>(xs[0].as<exact_integer>());
50+
return make<hoge>(car(xs).as<exact_integer>());
5151
}
5252

5353
auto is_hoge(object & xs)
5454
{
55-
return xs[0].is<hoge>() ? t : f;
55+
return car(xs).is<hoge>() ? t : f;
5656
}
5757

5858
auto hoge_value(object & xs)
5959
{
60-
return make<exact_integer>(xs[0].as<hoge>().value);
60+
return make<exact_integer>(car(xs).as<hoge>().value);
6161
}
6262
}

example/example.ss

+11-8
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,37 @@
44
(scheme write)
55
(srfi 78))
66

7+
(display (get-environment-variable "LD_LIBRARY_PATH"))
8+
(newline)
9+
710
; ------------------------------------------------------------------------------
811

912
(define dummy-procedure
10-
(procedure "build/libexample.so" 'dummy_procedure))
13+
(procedure "libexample.so" 'dummy_procedure))
1114

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

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

1619
; ------------------------------------------------------------------------------
1720

18-
(define arity
19-
(procedure "build/libexample.so" 'arity))
21+
(define argument-length
22+
(procedure "libexample.so" 'argument_length))
2023

21-
(check (procedure? arity) => #t)
24+
(check (procedure? argument-length) => #t)
2225

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

2528
; ------------------------------------------------------------------------------
2629

2730
(define make-hoge
28-
(procedure "build/libexample.so" 'make_hoge))
31+
(procedure "libexample.so" 'make_hoge))
2932

3033
(define hoge?
31-
(procedure "build/libexample.so" 'is_hoge))
34+
(procedure "libexample.so" 'is_hoge))
3235

3336
(define hoge-value
34-
(procedure "build/libexample.so" 'hoge_value))
37+
(procedure "libexample.so" 'hoge_value))
3538

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

include/meevax/memory/bit_cast.hpp include/meevax/bit/bit_cast.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
limitations under the License.
1515
*/
1616

17-
#ifndef INCLUDED_MEEVAX_MEMORY_BIT_CAST_HPP
18-
#define INCLUDED_MEEVAX_MEMORY_BIT_CAST_HPP
17+
#ifndef INCLUDED_MEEVAX_BIT_BIT_CAST_HPP
18+
#define INCLUDED_MEEVAX_BIT_BIT_CAST_HPP
1919

2020
#include <cstring>
2121

2222
#include <meevax/type_traits/requires.hpp>
2323

2424
namespace meevax
2525
{
26-
inline namespace memory
26+
inline namespace bit
2727
{
2828
template <typename To,
2929
typename From,
@@ -37,7 +37,7 @@ inline namespace memory
3737
std::memcpy(&to, &from, sizeof from);
3838
return to;
3939
}
40-
} // namespace memory
40+
} // namespace bit
4141
} // namespace meevax
4242

43-
#endif // INCLUDED_MEEVAX_MEMORY_BIT_CAST_HPP
43+
#endif // INCLUDED_MEEVAX_BIT_BIT_CAST_HPP

include/meevax/bit/log2.hpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2018-2023 Tatsuya Yamasaki.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
#ifndef INCLUDED_MEEVAX_BIT_LOG2_HPP
18+
#define INCLUDED_MEEVAX_BIT_LOG2_HPP
19+
20+
namespace meevax
21+
{
22+
inline namespace bit
23+
{
24+
template <typename T>
25+
constexpr auto log2(T x) noexcept -> T
26+
{
27+
return (x < 2) ? 1 : log2(x / 2) + 1;
28+
}
29+
30+
static_assert(log2(0b0001) == 1);
31+
static_assert(log2(0b0010) == 2);
32+
static_assert(log2(0b0011) == 2);
33+
static_assert(log2(0b0100) == 3);
34+
static_assert(log2(0b0101) == 3);
35+
static_assert(log2(0b0110) == 3);
36+
static_assert(log2(0b0111) == 3);
37+
static_assert(log2(0b1000) == 4);
38+
} // namespace bit
39+
} // namespace meevax
40+
41+
#endif // INCLUDED_MEEVAX_BIT_LOG2_HPP
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright 2018-2023 Tatsuya Yamasaki.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
#ifndef INCLUDED_MEEVAX_BITSET_SIMPLE_BITSET_HPP
18+
#define INCLUDED_MEEVAX_BITSET_SIMPLE_BITSET_HPP
19+
20+
#include <array>
21+
#include <bitset>
22+
23+
namespace meevax
24+
{
25+
inline namespace bitset
26+
{
27+
template <auto N>
28+
struct simple_bitset : public std::array<bool, N>
29+
{
30+
constexpr simple_bitset()
31+
: std::array<bool, N> {}
32+
{}
33+
34+
auto reset(std::size_t i) noexcept -> void
35+
{
36+
(*this)[i] = false;
37+
}
38+
39+
auto set(std::size_t i) noexcept -> void
40+
{
41+
(*this)[i] = true;
42+
}
43+
44+
auto test(std::size_t i) const noexcept -> bool
45+
{
46+
return (*this)[i];
47+
}
48+
};
49+
} // namespace bitset
50+
} // namespace meevax
51+
52+
#endif // INCLUDED_MEEVAX_BITSET_SIMPLE_BITSET_HPP

include/meevax/chrono/duration.hpp

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2018-2023 Tatsuya Yamasaki.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
#ifndef INCLUDED_MEEVAX_CHRONO_DURATION_HPP
18+
#define INCLUDED_MEEVAX_CHRONO_DURATION_HPP
19+
20+
#include <chrono>
21+
#include <iostream>
22+
23+
namespace meevax
24+
{
25+
inline namespace chrono
26+
{
27+
using days = std::chrono::duration<std::size_t, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>;
28+
29+
using years = std::chrono::duration<std::size_t, std::ratio_multiply<std::ratio<146097, 400>, days::period>>;
30+
31+
using months = std::chrono::duration<std::size_t, std::ratio_divide<years::period, std::ratio<12>>>;
32+
33+
template <typename Thunk>
34+
auto duration(Thunk thunk)
35+
{
36+
auto begin = std::chrono::high_resolution_clock::now();
37+
thunk();
38+
return std::chrono::high_resolution_clock::now() - begin;
39+
}
40+
41+
auto operator <<(std::ostream &, std::chrono::nanoseconds) -> std::ostream &;
42+
} // namespace chrono
43+
} // namespace meevax
44+
45+
#endif // INCLUDED_MEEVAX_CHRONO_DURATION_HPP

0 commit comments

Comments
 (0)