Verified Commit 8a6f7c11 authored by nagayama15's avatar nagayama15

chore: rename method name "*-ordering" -> "*-reordering"

parent 5b0c3ad2
#ifndef INCLUDE_kyut_Ordering_inl_hpp
#define INCLUDE_kyut_Ordering_inl_hpp
#include "Ordering.hpp"
#include "Reordering.hpp"
#include <algorithm>
#include "BitStreamWriter.hpp"
......@@ -43,7 +43,7 @@ namespace kyut {
}
template <typename RandomAccessIterator, typename Less>
inline std::size_t embed_by_ordering(
inline std::size_t embed_by_reordering(
CircularBitStreamReader& r,
std::size_t chunk_size,
RandomAccessIterator begin,
......@@ -119,7 +119,7 @@ namespace kyut {
}
template <typename RandomAccessIterator, typename Less>
inline std::size_t extract_by_ordering(
inline std::size_t extract_by_reordering(
BitStreamWriter& w,
std::size_t chunk_size,
RandomAccessIterator begin,
......@@ -144,23 +144,23 @@ namespace kyut {
} // namespace detail
template <typename RandomAccessIterator, typename Less>
inline std::size_t embed_by_ordering(
inline std::size_t embed_by_reordering(
CircularBitStreamReader& r,
std::size_t chunk_size,
RandomAccessIterator begin,
RandomAccessIterator end,
Less less) {
return detail::embed_by_ordering(r, chunk_size, begin, end, less);
return detail::embed_by_reordering(r, chunk_size, begin, end, less);
}
template <typename RandomAccessIterator, typename Less>
inline std::size_t extract_by_ordering(
inline std::size_t extract_by_reordering(
BitStreamWriter& w,
std::size_t chunk_size,
RandomAccessIterator begin,
RandomAccessIterator end,
Less less) {
return detail::extract_by_ordering(w, chunk_size, begin, end, less);
return detail::extract_by_reordering(w, chunk_size, begin, end, less);
}
} // namespace kyut
......
#ifndef INCLUDE_kyut_Ordering_hpp
#define INCLUDE_kyut_Ordering_hpp
#ifndef INCLUDE_kyut_Reordering_hpp
#define INCLUDE_kyut_Reordering_hpp
#include <cstddef>
......@@ -10,7 +10,7 @@ namespace kyut {
constexpr std::size_t max_chunk_size = 20;
template <typename RandomAccessIterator, typename Less>
std::size_t embed_by_ordering(
std::size_t embed_by_reordering(
CircularBitStreamReader& r,
std::size_t chunk_size,
RandomAccessIterator begin,
......@@ -18,7 +18,7 @@ namespace kyut {
Less less);
template <typename RandomAccessIterator, typename Less>
std::size_t extract_by_ordering(
std::size_t extract_by_reordering(
BitStreamWriter& w,
std::size_t chunk_size,
RandomAccessIterator begin,
......@@ -26,6 +26,6 @@ namespace kyut {
Less less);
} // namespace kyut
#include "Ordering-inl.hpp"
#include "Reordering-inl.hpp"
#endif // INCLUDE_kyut_Ordering_hpp
#endif // INCLUDE_kyut_Reordering_hpp
#ifndef INCLUDE_kyut_methods_ExportOrdering_hpp
#define INCLUDE_kyut_methods_ExportOrdering_hpp
#ifndef INCLUDE_kyut_methods_ExportReordering_hpp
#define INCLUDE_kyut_methods_ExportReordering_hpp
#include "../Ordering.hpp"
#include "../Reordering.hpp"
#include "wasm.h"
namespace kyut {
......@@ -9,9 +9,9 @@ namespace kyut {
class BitStreamWriter;
} // namespace kyut
namespace kyut::methods::export_ordering {
namespace kyut::methods::export_reordering {
inline std::size_t embed(CircularBitStreamReader& r, wasm::Module& module, std::size_t chunk_size) {
const auto size_bits = embed_by_ordering(
const auto size_bits = embed_by_reordering(
r,
chunk_size,
std::begin(module.exports),
......@@ -24,7 +24,7 @@ namespace kyut::methods::export_ordering {
}
inline std::size_t extract(BitStreamWriter& w, wasm::Module& module, std::size_t chunk_size) {
const auto size_bits = extract_by_ordering(
const auto size_bits = extract_by_reordering(
w,
chunk_size,
std::begin(module.exports),
......@@ -35,6 +35,6 @@ namespace kyut::methods::export_ordering {
return size_bits;
}
} // namespace kyut::methods::export_ordering
} // namespace kyut::methods::export_reordering
#endif // INCLUDE_kyut_methods_ExportOrdering_hpp
#endif // INCLUDE_kyut_methods_ExportReordering_hpp
#ifndef INCLUDE_kyut_methods_FunctionOrdering_hpp
#define INCLUDE_kyut_methods_FunctionOrdering_hpp
#ifndef INCLUDE_kyut_methods_FunctionReordering_hpp
#define INCLUDE_kyut_methods_FunctionReordering_hpp
#include "../Ordering.hpp"
#include "../Reordering.hpp"
#include "../wasm-ext/Compare.hpp"
namespace kyut {
......@@ -9,7 +9,7 @@ namespace kyut {
class BitStreamWriter;
} // namespace kyut
namespace kyut::methods::function_ordering {
namespace kyut::methods::function_reordering {
inline std::size_t embed(CircularBitStreamReader& r, wasm::Module& module, std::size_t chunk_size) {
const auto begin = std::begin(module.functions);
const auto end = std::end(module.functions);
......@@ -18,7 +18,7 @@ namespace kyut::methods::function_ordering {
return f->body == nullptr;
});
const auto size_bits = embed_by_ordering(
const auto size_bits = embed_by_reordering(
r,
chunk_size,
start,
......@@ -38,7 +38,7 @@ namespace kyut::methods::function_ordering {
return f->body == nullptr;
});
const auto size_bits = extract_by_ordering(
const auto size_bits = extract_by_reordering(
w,
chunk_size,
start,
......@@ -49,6 +49,6 @@ namespace kyut::methods::function_ordering {
return size_bits;
}
} // namespace kyut::methods::function_ordering
} // namespace kyut::methods::function_reordering
#endif // INCLUDE_kyut_methods_FunctionOrdering_hpp
#endif // INCLUDE_kyut_methods_FunctionReordering_hpp
#include <fmt/printf.h>
#include "cmdline.h"
#include "kyut/methods/ExportOrdering.hpp"
#include "kyut/methods/FunctionOrdering.hpp"
#include "kyut/methods/ExportReordering.hpp"
#include "kyut/methods/FunctionReordering.hpp"
#include "wasm-io.h"
namespace {
......@@ -15,7 +15,7 @@ int main(int argc, char* argv[]) {
options.add("help", 'h', "Print help message");
options.add("version", 'v', "Print version");
options.add<std::string>("method", 'm', "Embedding method (function-ordering, export-ordering)", true, "", cmdline::oneof<std::string>("function-ordering", "export-ordering"));
options.add<std::string>("method", 'm', "Embedding method (function-reordering, export-reordering)", true, "", cmdline::oneof<std::string>("function-reordering", "export-reordering"));
options.add<std::size_t>("chunk-size", 'c', "Chunk size [2~20]", false, 20, cmdline::range<std::size_t>(2, 20));
options.add<std::string>("dump", 0, "Output format (ascii, hex)", false, "ascii", cmdline::oneof<std::string>("ascii", "hex"));
......@@ -51,10 +51,10 @@ int main(int argc, char* argv[]) {
kyut::BitStreamWriter w{};
std::size_t size_bits;
if (method == "function-ordering") {
size_bits = kyut::methods::function_ordering::extract(w, module, chunk_size);
} else if (method == "export-ordering") {
size_bits = kyut::methods::export_ordering::extract(w, module, chunk_size);
if (method == "function-reordering") {
size_bits = kyut::methods::function_reordering::extract(w, module, chunk_size);
} else if (method == "export-reordering") {
size_bits = kyut::methods::export_reordering::extract(w, module, chunk_size);
} else {
WASM_UNREACHABLE(("unknown method: " + method).c_str());
}
......
#include <fmt/printf.h>
#include "cmdline.h"
#include "kyut/methods/ExportOrdering.hpp"
#include "kyut/methods/FunctionOrdering.hpp"
#include "kyut/methods/ExportReordering.hpp"
#include "kyut/methods/FunctionReordering.hpp"
#include "support/colors.h"
#include "wasm-io.h"
......@@ -17,7 +17,7 @@ int main(int argc, char* argv[]) {
options.add("version", 'v', "Print version");
options.add<std::string>("output", 'o', "Output filename", true);
options.add<std::string>("method", 'm', "Embedding method (function-ordering, export-ordering)", true, "", cmdline::oneof<std::string>("function-ordering", "export-ordering"));
options.add<std::string>("method", 'm', "Embedding method (function-reordering, export-reordering)", true, "", cmdline::oneof<std::string>("function-reordering", "export-reordering"));
options.add<std::string>("watermark", 'w', "Watermark to embed", true);
options.add<std::size_t>("chunk-size", 'c', "Chunk size [2~20]", false, 20, cmdline::range<std::size_t>(2, 20));
......@@ -68,10 +68,10 @@ int main(int argc, char* argv[]) {
kyut::CircularBitStreamReader r{watermark};
std::size_t size_bits;
if (method == "function-ordering") {
size_bits = kyut::methods::function_ordering::embed(r, module, chunk_size);
} else if (method == "export-ordering") {
size_bits = kyut::methods::export_ordering::embed(r, module, chunk_size);
if (method == "function-reordering") {
size_bits = kyut::methods::function_reordering::embed(r, module, chunk_size);
} else if (method == "export-reordering") {
size_bits = kyut::methods::export_reordering::embed(r, module, chunk_size);
} else {
WASM_UNREACHABLE(("unknown method: " + method).c_str());
}
......
......@@ -3,7 +3,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test")
add_executable(test_kyut
test_BitStreamWriter.cpp
test_CircularBitStreamReader.cpp
test_Ordering.cpp
test_Reordering.cpp
)
target_link_libraries(test_kyut
......
#include "kyut/Ordering.hpp"
#include "kyut/Reordering.hpp"
#include <gtest/gtest.h>
......@@ -11,7 +11,7 @@ namespace {
std::string_view expected_reordered_data) {
kyut::CircularBitStreamReader r{watermark};
const auto size_bits = kyut::embed_by_ordering(
const auto size_bits = kyut::embed_by_reordering(
r,
chunk_size,
std::begin(data),
......@@ -23,7 +23,7 @@ namespace {
}
} // namespace
TEST(kyut_Ordering, embed_by_ordering) {
TEST(kyut_Reordering, embed_by_reordering) {
using namespace std::string_view_literals;
check_embed("1234", "\x00"sv, 20, 4, "1234");
......@@ -47,7 +47,7 @@ namespace {
std::string_view expected_watermark_extracted) {
kyut::BitStreamWriter w{};
const auto size_bits = kyut::extract_by_ordering(
const auto size_bits = kyut::extract_by_reordering(
w,
chunk_size,
std::begin(data),
......@@ -60,7 +60,7 @@ namespace {
}
} // namespace
TEST(kyut_Ordering, extract_by_ordering) {
TEST(kyut_Reordering, extract_by_reordering) {
using namespace std::string_view_literals;
check_extract("1234", 20, 4, "\x00"sv);
......@@ -80,7 +80,7 @@ namespace {
std::string_view expected_watermark_extracted) {
kyut::CircularBitStreamReader r{watermark_embedding};
const auto size_bits_embedded = kyut::embed_by_ordering(
const auto size_bits_embedded = kyut::embed_by_reordering(
r,
chunk_size,
std::begin(data),
......@@ -91,7 +91,7 @@ namespace {
kyut::BitStreamWriter w{};
const auto size_bits_extracted = kyut::extract_by_ordering(
const auto size_bits_extracted = kyut::extract_by_reordering(
w,
chunk_size,
std::begin(data),
......@@ -103,7 +103,7 @@ namespace {
}
} // namespace
TEST(kyut_Ordering, embed_then_extract) {
TEST(kyut_Reordering, embed_then_extract) {
using namespace std::string_view_literals;
check_embed_then_extract("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv", "Test"sv, 15, 40 * 3 + 32, "TestTestTestTestTes"sv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment