Skip to content

Commit

Permalink
Merge pull request #473 from yamacir-kit/release-candidate
Browse files Browse the repository at this point in the history
Release candidate
  • Loading branch information
yamacir-kit authored Feb 19, 2024
2 parents 1748222 + e6dbc64 commit 5e27098
Show file tree
Hide file tree
Showing 24 changed files with 523 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
basis/src
build
include/meevax/basis
include/meevax/unicode
src/kernel/version.cpp
56 changes: 38 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,33 @@ string(TOLOWER ${CMAKE_SYSTEM_NAME} ${PROJECT_NAME}_SYSTEM_NAME)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/README.md ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/version.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/version.cpp)

# ---- Target basis ------------------------------------------------------------

file(GLOB ${PROJECT_NAME}_BASIS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/basis/*.ss)

foreach(EACH IN LISTS ${PROJECT_NAME}_BASIS_SOURCES)
get_filename_component(FILENAME ${EACH} NAME)
file(READ ${EACH} ${FILENAME})
endforeach()

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/configure/basis.cpp
${CMAKE_CURRENT_SOURCE_DIR}/basis/src/basis.cpp)

add_library(basis SHARED)

target_sources(basis PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/basis/src/basis.cpp)

target_include_directories(basis
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/basis/include>
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

set_target_properties(basis PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}-basis # Rename libbasis => libmeevax-basis
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
LINK_FLAGS_RELEASE -s)

# ---- Target kernel -----------------------------------------------------------

add_library(kernel SHARED)
Expand All @@ -81,25 +108,18 @@ target_link_libraries(kernel
PUBLIC gmp)

set_target_properties(kernel PROPERTIES
OUTPUT_NAME ${PROJECT_NAME} # Rename libkernel => libmeevax
OUTPUT_NAME ${PROJECT_NAME}-kernel # Rename libkernel => libmeevax-kernel
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
LINK_FLAGS_RELEASE -s)

# ---- Target basis ------------------------------------------------------------

add_custom_target(basis
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/configure/basis.cmake)

# ---- Target shell ------------------------------------------------------------

add_executable(shell)

add_dependencies(shell basis)

target_sources(shell PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)

target_link_libraries(shell PRIVATE kernel)
target_link_libraries(shell PRIVATE basis kernel)

set_target_properties(shell PROPERTIES
OUTPUT_NAME ${PROJECT_NAME} # Rename shell => meevax
Expand All @@ -116,7 +136,7 @@ write_basic_package_version_file(
# ---- Target install ----------------------------------------------------------

install( # /usr/lib/libmeevax
TARGETS kernel
TARGETS basis kernel
EXPORT ${PROJECT_NAME}-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand All @@ -126,7 +146,8 @@ install( # /usr/bin/meevax
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

install( # /usr/include/meevax
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
${CMAKE_CURRENT_SOURCE_DIR}/basis/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install( # /usr/share/meevax/meevax-config.cmake
Expand All @@ -135,8 +156,7 @@ install( # /usr/share/meevax/meevax-config.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
NAMESPACE Meevax::)

# /usr/share/meevax/meevax-config-version.cmake
install(
install( # /usr/share/meevax/meevax-config-version.cmake
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})

Expand Down Expand Up @@ -180,14 +200,14 @@ file(GLOB ${PROJECT_NAME}_TEST_CPP ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp)

foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_CPP)
get_filename_component(FILENAME ${EACH} NAME_WE)
add_executable(assert-${FILENAME} ${EACH})
add_dependencies(assert-${FILENAME} basis)
target_link_libraries(assert-${FILENAME} PRIVATE kernel)
add_executable(test_${FILENAME} ${EACH})
target_link_libraries(test_${FILENAME} PRIVATE basis kernel)
target_compile_options(test_${FILENAME} PUBLIC -Wno-deprecated-declarations)
add_test(
NAME assert-${FILENAME}
NAME test/${FILENAME}
COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND}
${${PROJECT_NAME}_MEMORY_CHECK_OPTIONS}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/assert-${FILENAME})
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_${FILENAME})
endforeach()

# ---- Additional Targets ------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Latest release is [here](https://github.com/yamacir-kit/meevax/releases).
- Low-level hygienic macro system, known as *syntactic closures* [[Bawden and
Rees 1988](#Bawden-and-Rees-1988); [Hanson 1991](#Hanson-1991)] and *explicit
renaming* [[Clinger 1991](#Clinger-1991)]. For these, the well-known macro
transformers `sc-macro-transformer`, `rsc-macro-transformer`, and
transformers `sc-macro-transformer`, `rsc-macro-transformer` and
`er-macro-transformer` from the library [`(meevax
macro-transformer)`](./basis/meevax.ss) are provided. Note that these are
non-Scheme standards.
Expand Down 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.107_amd64.deb
sudo apt install build/meevax_0.5.119_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.107.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.119.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.107_amd64.deb`
| `package` | Generate debian package `meevax_0.5.119_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.107
0.5.119
27 changes: 27 additions & 0 deletions basis/include/meevax/basis.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
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_KERNEL_BASIS_HPP
#define INCLUDED_MEEVAX_KERNEL_BASIS_HPP

#include <vector>

namespace meevax
{
auto basis() -> std::vector<char const*>;
} // namespace meevax

#endif // INCLUDED_MEEVAX_KERNEL_BASIS_HPP
2 changes: 1 addition & 1 deletion configure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Latest release is [here](https://github.com/yamacir-kit/meevax/releases).
- Low-level hygienic macro system, known as *syntactic closures* [[Bawden and
Rees 1988](#Bawden-and-Rees-1988); [Hanson 1991](#Hanson-1991)] and *explicit
renaming* [[Clinger 1991](#Clinger-1991)]. For these, the well-known macro
transformers `sc-macro-transformer`, `rsc-macro-transformer`, and
transformers `sc-macro-transformer`, `rsc-macro-transformer` and
`er-macro-transformer` from the library [`(meevax
macro-transformer)`](./basis/meevax.ss) are provided. Note that these are
non-Scheme standards.
Expand Down
15 changes: 0 additions & 15 deletions configure/basis.cmake

This file was deleted.

23 changes: 5 additions & 18 deletions configure/basis.hpp → configure/basis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,13 @@
limitations under the License.
*/

#ifndef INCLUDED_MEEVAX_KERNEL_BASIS_HPP
#define INCLUDED_MEEVAX_KERNEL_BASIS_HPP

#include <array>
#include <meevax/basis.hpp>

namespace meevax
{
inline namespace kernel
{
template <typename... Ts>
constexpr auto make_array(Ts&&... xs) -> std::array<std::decay_t<std::common_type_t<Ts...>>, sizeof...(Ts)>
{
return { std::forward<decltype(xs)>(xs)... };
}

constexpr auto basis()
auto basis() -> std::vector<char const*>
{
return make_array(
return {
R"##(${meevax.ss})##",
R"##(${r4rs.ss})##",
R"##(${r5rs.ss})##",
Expand All @@ -53,9 +42,7 @@ inline namespace kernel
R"##(${srfi-78.ss})##",
R"##(${srfi-98.ss})##",
R"##(${srfi-111.ss})##",
R"##(${srfi-149.ss})##");
R"##(${srfi-149.ss})##",
};
}
} // namespace kernel
} // namespace meevax

#endif // INCLUDED_MEEVAX_KERNEL_BASIS_HPP
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ add_library(${PROJECT_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.c

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

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

enable_testing()

Expand Down
1 change: 1 addition & 0 deletions example/example.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <meevax/basis.hpp>
#include <meevax/kernel/environment.hpp>

using namespace meevax; // NOTE: DIRTY HACK
Expand Down
6 changes: 5 additions & 1 deletion include/meevax/kernel/pair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ inline namespace kernel

using const_iterator = forward_iterator<true>;

explicit pair(object const& = unit, object const& = unit);
constexpr pair() = default;

explicit pair(object const&);

explicit pair(object const&, object const&);

template <typename... Ts, typename = std::enable_if_t<(1 < sizeof...(Ts))>>
explicit pair(object const& a, Ts&&... xs)
Expand Down
7 changes: 4 additions & 3 deletions include/meevax/kernel/procedure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ inline namespace kernel
{
std::enable_if_t<std::is_invocable_v<F> or std::is_invocable_v<F, object &>, F> invocable;

explicit generic_procedure(std::string const& name, F f)
: primitive_procedure { name }
, invocable { f }
template <typename T, typename U>
explicit generic_procedure(T && x, U && y)
: primitive_procedure { std::forward<decltype(x)>(x) }
, invocable { std::forward<decltype(y)>(y) }
{}

auto operator ()(object & xs) const -> object override
Expand Down
16 changes: 8 additions & 8 deletions include/meevax/memory/collector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,30 +121,30 @@ inline namespace memory
friend class collector;

protected:
tag * location = nullptr;
tag * object = nullptr;

explicit constexpr mutator() = default;

explicit mutator(tag * location) noexcept
: location { location }
explicit mutator(tag * object) noexcept
: object { object }
{
if (location)
if (object)
{
mutators.insert(this);
}
}

~mutator() noexcept
{
if (location)
if (object)
{
mutators.erase(this);
}
}

auto reset(tag * after = nullptr) noexcept -> void
{
if (auto before = std::exchange(location, after); not before and after)
if (auto before = std::exchange(object, after); not before and after)
{
mutators.insert(this);
}
Expand Down Expand Up @@ -181,9 +181,9 @@ inline namespace memory
protected:
static inline tag * cache = nullptr;

static inline pointer_set<tag *> tags {};
static inline v2::pointer_set<tag *> tags {};

static inline pointer_set<mutator *> mutators {};
static inline v2::pointer_set<mutator *> mutators {};

static inline std::size_t allocation = 0;

Expand Down
4 changes: 2 additions & 2 deletions include/meevax/memory/gc_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ inline namespace memory

gc_pointer(gc_pointer const& gcp)
: pointer { gcp }
, collector::mutator { gcp.location }
, collector::mutator { gcp.object }
{}

gc_pointer(pointer const& p)
Expand Down Expand Up @@ -72,7 +72,7 @@ inline namespace memory
auto reset(gc_pointer const& gcp) -> void
{
pointer::reset(gcp);
collector::mutator::reset(gcp.location);
collector::mutator::reset(gcp.object);
}

auto reset(pointer const& p) -> void
Expand Down
4 changes: 3 additions & 1 deletion include/meevax/memory/heterogeneous_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ inline namespace memory
{
template <typename... Us>
explicit constexpr binder(Us&&... xs)
: std::conditional_t<std::is_base_of_v<Top, Bound>, Top, Bound> { std::forward<decltype(xs)>(xs)... }
: std::conditional_t<std::is_base_of_v<Top, Bound> and std::is_constructible_v<Top, Us...>, Top, Bound> {
std::forward<decltype(xs)>(xs)...
}
{}

~binder() override = default;
Expand Down
Loading

0 comments on commit 5e27098

Please sign in to comment.