diff --git a/example/brainfuck/x86_compile.cpp b/example/brainfuck/x86_compile.cpp index 27c3313d..ece58c56 100644 --- a/example/brainfuck/x86_compile.cpp +++ b/example/brainfuck/x86_compile.cpp @@ -23,8 +23,8 @@ // -// PE関連の構造体 -// からコピペ +// PE structs +// Copy an Paste from // typedef unsigned long DWORD; typedef int BOOL; @@ -133,21 +133,21 @@ typedef struct _IMAGE_SECTION_HEADER { // -// 出力バイナリサイズ +// binary size for output // #ifndef BRAINFUCK_BINARY_SIZE # define BRAINFUCK_BINARY_SIZE (16 * 1024) #endif // -// ループ制限 +// loop limit // #ifndef BRAINFUCK_LOOP_LIMIT # define BRAINFUCK_LOOP_LIMIT 256 #endif // -// 入力ファイル名 +// source file name // #ifndef BRAINFUCK_SOURCE_FILE # define BRAINFUCK_SOURCE_FILE a.bf @@ -155,7 +155,7 @@ typedef struct _IMAGE_SECTION_HEADER { // -// 定数 +// constants // SPROUT_STATIC_CONSTEXPR std::size_t bin_size = BRAINFUCK_BINARY_SIZE; @@ -171,7 +171,7 @@ SPROUT_STATIC_CONSTEXPR std::int32_t addr_buf = 0x00406000; // -// 出力用関数 +// output functions // template SPROUT_CXX14_CONSTEXPR std::size_t @@ -384,7 +384,7 @@ write_idata(OutputIterator& out, std::size_t n = 0) { SPROUT_CONSTEXPR int idt[] = { // IDT 1 0x5028, 0, 0, 0x5034, 0x5044, - // IDT (終端) + // IDT (end) 0, 0, 0, 0, 0 }; n += ::write_bytes( @@ -392,7 +392,7 @@ write_idata(OutputIterator& out, std::size_t n = 0) { idt ); - SPROUT_CONSTEXPR int ilt_iat[] = { + SPROUT_CONSTEXPR int ilt_iat[] = { 0x5050, 0x505a, 0 }; @@ -429,12 +429,12 @@ write_idata(OutputIterator& out, std::size_t n = 0) { } // -// コンパイル +// compile // template SPROUT_CXX14_CONSTEXPR std::size_t compile(InputIterator first, InputIterator last, RandomAccessIterator& out_first) { - sprout::array loops {{}}; // ループを保存するスタック + sprout::array loops {{}}; // loop stack auto loop_first = sprout::begin(loops); auto loop_last = sprout::end(loops); auto loop = loop_first; @@ -499,12 +499,12 @@ compile(InputIterator first, InputIterator last, RandomAccessIterator& out_first break; case '[': SPROUT_ASSERT_MSG(loop != loop_last, "loop overflow"); - *loop++ = idx; // インデックスをスタックに積む + *loop++ = idx; // push index to stack idx += ::write_bytes( out, (unsigned char)0x80, (unsigned char)0x3c, (unsigned char)0x0f, (unsigned char)0x00, // cmp byte [edi+ecx],0 - (unsigned char)0x0f, (unsigned char)0x84, // jz 対応する]の直後 - (unsigned char)0xde, (unsigned char)0xad, (unsigned char)0xbe, (unsigned char)0xef // (アドレスは後で決定) + (unsigned char)0x0f, (unsigned char)0x84, // jz (immediately after corresponding ']') + (unsigned char)0xde, (unsigned char)0xad, (unsigned char)0xbe, (unsigned char)0xef // (set address later) ); break; case ']': @@ -518,7 +518,7 @@ compile(InputIterator first, InputIterator last, RandomAccessIterator& out_first auto out_loop = out_first + (idx_loop + 6); ::write_bytes( out_loop, - (std::int32_t)(idx - (idx_loop + 10)) // (アドレス) + (std::int32_t)(idx - (idx_loop + 10)) // (address) ); break; } @@ -528,7 +528,7 @@ compile(InputIterator first, InputIterator last, RandomAccessIterator& out_first SPROUT_ASSERT_MSG(loop == loop_first, "missing ']'"); - // 終了処理 + // end idx += ::write_bytes( out, (unsigned char)0x5f, // pop edi @@ -540,15 +540,15 @@ compile(InputIterator first, InputIterator last, RandomAccessIterator& out_first } // -// ビルド +// build // template SPROUT_CXX14_CONSTEXPR std::size_t build(InputIterator first, InputIterator last, RandomAccessIterator& out) { std::size_t n = 0; - n += ::write_pe_header(out, n); // ヘッダ出力 - n += ::write_idata(out, n); // .idataセクション出力 - n += ::compile(first, last, out); // コンパイル + n += ::write_pe_header(out, n); // header + n += ::write_idata(out, n); // .idata section + n += ::compile(first, last, out); // compile return n; } diff --git a/example/lifegame/main.cpp b/example/lifegame/main.cpp index 27793060..966c0412 100644 --- a/example/lifegame/main.cpp +++ b/example/lifegame/main.cpp @@ -186,7 +186,7 @@ void SPROUT_NON_CONSTEXPR print_board(Container const& board) { int main() { typedef sprout::array, BOARD_HEIGHT> board_type; - // セルの初期配置 + // cell initial placement #define _ 0 #define X 1 SPROUT_STATIC_CONSTEXPR board_type board0 @@ -211,10 +211,10 @@ int main() { #undef _ #undef X - // ライフゲームの実行 + // execute life game SPROUT_STATIC_CONSTEXPR auto boards = ::next_cells(board0); - // 表示 + // print for (auto&& board : boards) { ::print_board(board); } diff --git a/example/perceptron/g3.cpp b/example/perceptron/g3.cpp index e49415b5..bce924c2 100644 --- a/example/perceptron/g3.cpp +++ b/example/perceptron/g3.cpp @@ -27,33 +27,33 @@ public: private: struct worker { public: - // 入力 + // in sprout::array xi1; sprout::array xi2; sprout::array xi3; - // 出力 + // out sprout::array o1; sprout::array o2; sprout::array o3; }; private: - // 誤差 + // error sprout::array d2; sprout::array d3; - // 重み + // weight sprout::array w1; sprout::array w2; private: - // 順伝播 + // forward propagation template SPROUT_CXX14_CONSTEXPR void forward_propagation(ForwardIterator in_first, ForwardIterator in_last, worker& work) const { - // 入力層の順伝播 + // forward propagation with input layer sprout::copy(in_first, in_last, sprout::begin(work.xi1)); work.xi1[In] = 1; sprout::copy(sprout::begin(work.xi1), sprout::end(work.xi1), sprout::begin(work.o1)); - // 隠れ層の順伝播 + // forward propagation with hidden layer for (std::size_t i = 0; i != Hid; ++i) { work.xi2[i] = 0; for (std::size_t j = 0; j != In + 1; ++j) { @@ -63,7 +63,7 @@ private: } work.o2[Hid] = 1; - // 出力層の順伝播 + // forward propagation with output layer for (std::size_t i = 0; i != Hid; ++i) { work.xi3[i] = 0; for (std::size_t j = 0; j != In + 1; ++j) { @@ -80,9 +80,9 @@ public: , w2(sprout::random::generate_array<(Hid + 1) * Out>(rng, sprout::random::uniform_01())) {} - // ニューラルネットの訓練 - // [in_first, in_last) : 訓練データ (N*In 個) - // [t_first, t_last) : 教師データ (N 個) + // training of neural network + // [in_first, in_last) : training data (N*In elements) + // [t_first, t_last) : training data (N elements) template SPROUT_CXX14_CONSTEXPR void train( @@ -99,24 +99,24 @@ public: ForwardIterator1 in_it = in_first; ForwardIterator2 t_it = t_first; for (; in_it != in_last; sprout::advance(in_it, In), ++t_it) { - // 順伝播 + // forward propagation forward_propagation(in_it, sprout::next(in_it, In), work); - // 出力層の誤差計算 + // error calculation of output layer for (std::size_t i = 0; i != Out; ++i) { d3[i] = *t_it == i ? work.o3[i] - 1 : work.o3[i] ; } - // 出力層の重み更新 + // weight update of output layer for (std::size_t i = 0; i != Hid + 1; ++i) { for (std::size_t j = 0; j != Out; ++j) { w2[i * Out + j] -= eta * d3[j] * work.o2[i]; } } - // 隠れ層の誤差計算 + // error calculation of hidden layer for (std::size_t i = 0; i != Hid + 1; ++i) { d2[i] = 0; for (std::size_t j = 0; j != Out; ++j) { @@ -125,7 +125,7 @@ public: d2[i] *= sprout::math::d_sigmoid(work.xi2[i]); } - // 隠れ層の重み更新 + // weight update of hidden layer for (std::size_t i = 0; i != In + 1; ++i) { for (std::size_t j = 0; j != Hid; ++j) { w1[i * Hid + j] -= eta * d2[j] * work.o1[i]; @@ -135,7 +135,7 @@ public: } } - // 与えられたデータに対して最も可能性の高いクラスを返す + // returns to predict the most likely class for a given data template SPROUT_CXX14_CONSTEXPR std::size_t predict(ForwardIterator in_first, ForwardIterator in_last) const { @@ -143,10 +143,10 @@ public: worker work{}; - // 順伝播による予測 + // prediction by forward propagation forward_propagation(in_first, in_last, work); - // 出力が最大になるクラスを判定 + // determining a class which output is maximum return sprout::distance( sprout::begin(work.o3), sprout::max_element(sprout::begin(work.o3), sprout::end(work.o3)) @@ -161,11 +161,11 @@ public: #include #include -// 訓練データ +// training data SPROUT_CONSTEXPR auto train_data = sprout::make_array( # include "g3_train.csv" ); -// 教師データ +// teaching data SPROUT_CONSTEXPR auto teach_data = sprout::make_array( # include "g3_teach.csv" ); @@ -173,17 +173,17 @@ SPROUT_CONSTEXPR auto teach_data = sprout::make_array( SPROUT_STATIC_ASSERT(train_data.size() % 2 == 0); SPROUT_STATIC_ASSERT(train_data.size() / 2 == teach_data.size()); -// 訓練済みパーセプトロンを生成 +// generate a trained perceptron template SPROUT_CXX14_CONSTEXPR ::perceptron make_trained_perceptron() { - // 乱数生成器 + // random number generator sprout::random::default_random_engine rng(SPROUT_UNIQUE_SEED); - // パーセプトロン + // perceptron ::perceptron per(rng); - // 訓練 + // training per.train( train_data.begin(), train_data.end(), teach_data.begin(), teach_data.end(), @@ -194,10 +194,10 @@ make_trained_perceptron() { } int main() { - // パーセプトロンを生成(入力2 隠れ3 出力3) + // generate a Perceptron (input 2, hidden 3, output 3) SPROUT_CXX14_CONSTEXPR auto per = ::make_trained_perceptron(); - // 結果の表示 + // print results for (auto it = train_data.begin(), last = train_data.end(); it != last; it += 2) { std::cout << per.predict(it, it + 2) << std::endl; } diff --git a/libs/net/test/endian.cpp b/libs/net/test/endian.cpp index 0edf85ec..5c27050d 100644 --- a/libs/net/test/endian.cpp +++ b/libs/net/test/endian.cpp @@ -16,31 +16,31 @@ #include namespace testspr { - static void endian_test() { - using namespace sprout; + static void endian_test() { + using namespace sprout; - { // 16 - TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint16_t(0x0A1B)) == std::uint16_t(0x1B0A)); - TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint16_t(0x1B0A)) == std::uint16_t(0x0A1B)); - TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint16_t(0x0A1B)) == std::uint16_t(0x1B0A)); - TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint16_t(0x1B0A)) == std::uint16_t(0x0A1B)); - } + { // 16 + TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint16_t(0x0A1B)) == std::uint16_t(0x1B0A)); + TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint16_t(0x1B0A)) == std::uint16_t(0x0A1B)); + TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint16_t(0x0A1B)) == std::uint16_t(0x1B0A)); + TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint16_t(0x1B0A)) == std::uint16_t(0x0A1B)); + } - { // 32 - TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint32_t(0x0A1B2C3D)) == std::uint32_t(0x3D2C1B0A)); - TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint32_t(0x3D2C1B0A)) == std::uint32_t(0x0A1B2C3D)); - TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint32_t(0x0A1B2C3D)) == std::uint32_t(0x1B0A3D2C)); - TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint32_t(0x1B0A3D2C)) == std::uint32_t(0x0A1B2C3D)); - } + { // 32 + TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint32_t(0x0A1B2C3D)) == std::uint32_t(0x3D2C1B0A)); + TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint32_t(0x3D2C1B0A)) == std::uint32_t(0x0A1B2C3D)); + TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint32_t(0x0A1B2C3D)) == std::uint32_t(0x1B0A3D2C)); + TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint32_t(0x1B0A3D2C)) == std::uint32_t(0x0A1B2C3D)); + } - { // 64 - TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint64_t(0x0A1B2C3D4E5F6A7B)) == std::uint64_t(0x7B6A5F4E3D2C1B0A)); - TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint64_t(0x7B6A5F4E3D2C1B0A)) == std::uint64_t(0x0A1B2C3D4E5F6A7B)); - TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint64_t(0x0A1B2C3D4E5F6A7B)) == std::uint64_t(0x1B0A3D2C5F4E7B6A)); - TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint64_t(0x1B0A3D2C5F4E7B6A)) == std::uint64_t(0x0A1B2C3D4E5F6A7B)); - } - } -} // namespace testspr + { // 64 + TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint64_t(0x0A1B2C3D4E5F6A7B)) == std::uint64_t(0x7B6A5F4E3D2C1B0A)); + TESTSPR_ASSERT(sprout::net::detail::reverse(std::uint64_t(0x7B6A5F4E3D2C1B0A)) == std::uint64_t(0x0A1B2C3D4E5F6A7B)); + TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint64_t(0x0A1B2C3D4E5F6A7B)) == std::uint64_t(0x1B0A3D2C5F4E7B6A)); + TESTSPR_ASSERT(sprout::net::detail::reverse_words(std::uint64_t(0x1B0A3D2C5F4E7B6A)) == std::uint64_t(0x0A1B2C3D4E5F6A7B)); + } + } +} // namespace testspr #ifndef TESTSPR_CPP_INCLUDE # define TESTSPR_TEST_FUNCTION testspr::endian_test diff --git a/libs/string/example/literals_to_string.cpp b/libs/string/example/literals_to_string.cpp index 7aad1c08..2c2f97b0 100644 --- a/libs/string/example/literals_to_string.cpp +++ b/libs/string/example/literals_to_string.cpp @@ -17,7 +17,7 @@ int main(){ - + // // String literal to Sprout.String // @@ -30,7 +30,7 @@ main(){ static_assert(str2 == L"縺サ繧縺サ繧", ""); static_assert(std::is_same const>{}, ""); } - + // // Integer literal to Sprout.String // @@ -38,7 +38,7 @@ main(){ static constexpr auto str = sprout::to_string(42); static_assert(str == "42", ""); } - + // // Float literal to Sprout.String // diff --git a/libs/weed/example/__TIME__.cpp b/libs/weed/example/__TIME__.cpp index 26ec1eab..17536a2b 100644 --- a/libs/weed/example/__TIME__.cpp +++ b/libs/weed/example/__TIME__.cpp @@ -28,7 +28,7 @@ main(){ // __TIME__ to Sprout.String // static constexpr auto time = sprout::to_string(__TIME__); -// static constexpr auto time = sprout::to_string("23:22:45"); +// static constexpr auto time = sprout::to_string("23:22:45"); // @@ -43,13 +43,13 @@ main(){ // get result // static constexpr sprout::array result_attr = result.attr(); - static constexpr auto hour = result_attr[0]; + static constexpr auto hour = result_attr[0]; static constexpr auto minute = result_attr[1]; - static constexpr auto second = result_attr[2]; + static constexpr auto second = result_attr[2]; -// static_assert(hour == 23, ""); -// static_assert(minute == 22, ""); -// static_assert(second == 45, ""); +// static_assert(hour == 23, ""); +// static_assert(minute == 22, ""); +// static_assert(second == 45, ""); std::cout << hour << std::endl; std::cout << minute << std::endl; diff --git a/sprout/compost/sources/source.hpp b/sprout/compost/sources/source.hpp index f0d3bddc..639e268c 100644 --- a/sprout/compost/sources/source.hpp +++ b/sprout/compost/sources/source.hpp @@ -34,13 +34,13 @@ namespace sprout { // struct info_type { public: - std::uint16_t format_tag; // フォーマットID - std::uint16_t channels; // チャンネル数 - std::uint32_t samples_per_sec; // サンプリングレート - std::uint32_t bytes_per_sec; // データ速度 (Byte/sec) - std::uint16_t block_size; // ブロックサイズ (Byte/sample*チャンネル数) - std::uint16_t bits_per_sample; // サンプルあたりのビット数 (bit/sample) - std::size_t size; // 要素数 + std::uint16_t format_tag; // format ID + std::uint16_t channels; // channels + std::uint32_t samples_per_sec; // sampling rate + std::uint32_t bytes_per_sec; // data speed (Byte/sec) + std::uint16_t block_size; // block size (Byte/sample*channels) + std::uint16_t bits_per_sample; // bits per sample (bit/sample) + std::size_t size; // elements }; // // sound_type diff --git a/sprout/compost/utility/rosenberg.hpp b/sprout/compost/utility/rosenberg.hpp index b9c9b7d3..1b5cc4d6 100644 --- a/sprout/compost/utility/rosenberg.hpp +++ b/sprout/compost/utility/rosenberg.hpp @@ -16,7 +16,9 @@ namespace sprout { namespace compost { // // rosenberg_value - // Rosenberg 波は,声門開大期と閉小期が周期の40%,16%となる非対称形の波形であり,τ1 が開大期,τ2が閉小期を示す. + // Rosenberg wave is asymmetric waveform, + // expansion period/reduction period of the glottis is 40%/16% of the cycle, + // tau1 is expansion period, tau2 is reduction period // template inline SPROUT_CONSTEXPR typename sprout::float_promote::type diff --git a/sprout/cstdlib/abs.hpp b/sprout/cstdlib/abs.hpp index 89c08488..7d870a0b 100644 --- a/sprout/cstdlib/abs.hpp +++ b/sprout/cstdlib/abs.hpp @@ -18,7 +18,7 @@ namespace sprout { - // 7.20.6.1 abs,labs,及び llabs 関数 + // 7.20.6.1 abs, labs, and llabs function inline SPROUT_CONSTEXPR int abs(int j) { return j < 0 ? -j : j; diff --git a/sprout/cstdlib/div.hpp b/sprout/cstdlib/div.hpp index 0bf02507..a77bfa34 100644 --- a/sprout/cstdlib/div.hpp +++ b/sprout/cstdlib/div.hpp @@ -88,7 +88,7 @@ namespace sprout { } } // namespace detail - // 7.20.6.2 div,ldiv,及び lldiv 関数 + // 7.20.6.2 div, ldiv, and lldiv function inline SPROUT_CONSTEXPR sprout::div_t div(int numer, int denom) { return sprout::detail::div_impl(numer, denom); diff --git a/sprout/cstring/memchr.hpp b/sprout/cstring/memchr.hpp index 2c6c854a..cfb40c80 100644 --- a/sprout/cstring/memchr.hpp +++ b/sprout/cstring/memchr.hpp @@ -50,7 +50,7 @@ namespace sprout { } } // namespace detail - // 7.21.5.1 memchr 関数 + // 7.21.5.1 memchr function // // recursion depth: // O(log N) diff --git a/sprout/cstring/memcmp.hpp b/sprout/cstring/memcmp.hpp index b0178d09..9fc3f0db 100644 --- a/sprout/cstring/memcmp.hpp +++ b/sprout/cstring/memcmp.hpp @@ -27,7 +27,7 @@ namespace sprout { } } // namespace detail - // 7.21.4.1 memcmp 関数 + // 7.21.4.1 memcmp function // // recursion depth: // O(log(N1+N2)) diff --git a/sprout/cstring/strchr.hpp b/sprout/cstring/strchr.hpp index 176e1534..5ef83053 100644 --- a/sprout/cstring/strchr.hpp +++ b/sprout/cstring/strchr.hpp @@ -63,7 +63,7 @@ namespace sprout { } // namespace detail - // 7.21.5.2 strchr 関数 + // 7.21.5.2 strchr function // // recursion depth: // O(log N) diff --git a/sprout/cstring/strcmp.hpp b/sprout/cstring/strcmp.hpp index 2e6a70ae..99ae0642 100644 --- a/sprout/cstring/strcmp.hpp +++ b/sprout/cstring/strcmp.hpp @@ -76,7 +76,7 @@ namespace sprout { } } // namespace detail - // 7.21.4.2 strcmp 関数 + // 7.21.4.2 strcmp function // // recursion depth: // O(log(N1+N2)) diff --git a/sprout/cstring/strcoll.hpp b/sprout/cstring/strcoll.hpp index 87d8082c..39d66518 100644 --- a/sprout/cstring/strcoll.hpp +++ b/sprout/cstring/strcoll.hpp @@ -15,7 +15,7 @@ namespace sprout { - // 7.21.4.3 strcoll 関数 + // 7.21.4.3 strcoll function // // recursion depth: // O(log(N1+N2)) diff --git a/sprout/cstring/strcspn.hpp b/sprout/cstring/strcspn.hpp index efe95572..974da44c 100644 --- a/sprout/cstring/strcspn.hpp +++ b/sprout/cstring/strcspn.hpp @@ -66,7 +66,7 @@ namespace sprout { } } // namespace detail - // 7.21.5.3 strcspn 関数 + // 7.21.5.3 strcspn function // // recursion depth: // O(log(N1+N2)) diff --git a/sprout/cstring/strlen.hpp b/sprout/cstring/strlen.hpp index ead67f9e..be5c5b40 100644 --- a/sprout/cstring/strlen.hpp +++ b/sprout/cstring/strlen.hpp @@ -64,7 +64,7 @@ namespace sprout { } } // namespace detail - // 7.21.6.3 strlen 関数 + // 7.21.6.3 strlen function // // recursion depth: // O(log N) diff --git a/sprout/cstring/strncmp.hpp b/sprout/cstring/strncmp.hpp index 41a3e782..42f0d344 100644 --- a/sprout/cstring/strncmp.hpp +++ b/sprout/cstring/strncmp.hpp @@ -17,7 +17,7 @@ namespace sprout { - // 7.21.4.4 strncmp 関数 + // 7.21.4.4 strncmp function // // recursion depth: // O(log(N1+N2)) diff --git a/sprout/cstring/strpbrk.hpp b/sprout/cstring/strpbrk.hpp index 6dd608f1..624ddcde 100644 --- a/sprout/cstring/strpbrk.hpp +++ b/sprout/cstring/strpbrk.hpp @@ -67,7 +67,7 @@ namespace sprout { } } // namespace detail - // 7.21.5.4 strpbrk 関数 + // 7.21.5.4 strpbrk function // // recursion depth: // O(log(N1+N2)) diff --git a/sprout/cstring/strrchr.hpp b/sprout/cstring/strrchr.hpp index a98560b6..3979c65b 100644 --- a/sprout/cstring/strrchr.hpp +++ b/sprout/cstring/strrchr.hpp @@ -74,7 +74,7 @@ namespace sprout { } } // namespace detail - // 7.21.5.5 strrchr 関数 + // 7.21.5.5 strrchr function // // recursion depth: // O(log N) diff --git a/sprout/cstring/strspn.hpp b/sprout/cstring/strspn.hpp index 812efe29..d8d77a15 100644 --- a/sprout/cstring/strspn.hpp +++ b/sprout/cstring/strspn.hpp @@ -66,7 +66,7 @@ namespace sprout { } } // namespace detail - // 7.21.5.6 strspn 関数 + // 7.21.5.6 strspn function // // recursion depth: // O(log(N1+N2)) diff --git a/sprout/cstring/strstr.hpp b/sprout/cstring/strstr.hpp index 0250c579..6940ee4e 100644 --- a/sprout/cstring/strstr.hpp +++ b/sprout/cstring/strstr.hpp @@ -128,7 +128,7 @@ namespace sprout { } } // namespace detail - // 7.21.5.7 strstr 関数 + // 7.21.5.7 strstr function // // recursion depth: // O(log(N1+N2)) diff --git a/tools/files/filegraph.cpp b/tools/files/filegraph.cpp index 37a54c5a..7b29b9e1 100644 --- a/tools/files/filegraph.cpp +++ b/tools/files/filegraph.cpp @@ -34,7 +34,7 @@ class include_graph_hooks private: typedef boost::wave::context_policies::default_preprocessing_hooks base_type; public: - // グラフのノード + // node of graph struct node_type { boost::filesystem::path absolute; boost::filesystem::path filename; @@ -99,7 +99,7 @@ public: edges() const { return edge_list_; } - // グラフ生成 + // make graph template Graph make_graph() const { return Graph(edge_list_.begin(), edge_list_.end(), node_list_.size()); @@ -107,7 +107,7 @@ public: graph_type make_graph() const { return make_graph(); } - // graphviz 出力 + // output graphviz void write_graphviz(std::ostream& out) const { boost::write_graphviz( out, @@ -115,7 +115,7 @@ public: boost::make_label_writer(&node_list_[0]) ); } - // 非インクルードガード検出 + // collect no include guard files template void collect_no_include_guard_files(OutputIterator result) const { std::copy_if( @@ -123,7 +123,7 @@ public: [](node_type const& e) { return !e.has_include_guard; } ); } - // 循環インクルード検出 + // collect circulated includes template void collect_circulated_includes(OutputIterator result) const { boost::depth_first_search( @@ -131,7 +131,7 @@ public: boost::visitor(sprig::make_back_edge_recorder(result)) ); } - // 孤立ファイル検出 + // collect isolated files template void collect_isolated_files(OutputIterator result, boost::filesystem::path const& path) const { typedef boost::filesystem::recursive_directory_iterator iterator; @@ -139,14 +139,14 @@ public: if (!boost::filesystem::is_directory(*it)) { boost::filesystem::path abspath(boost::filesystem::absolute(*it)); auto found = std::find(node_list_.begin(), node_list_.end(), abspath); - if (found == node_list_.end()) { // インクルードされていないならば結果に追加 + if (found == node_list_.end()) { // add result if not include *result++ = abspath.generic_string(); } } } } public: - // インクルードファイルパス設定処理をフック + // hook the locate include file process template bool locate_include_file( Context& ctx, @@ -161,10 +161,10 @@ public: if (!base_type::locate_include_file(ctx, file_path, is_system, current_name, dir_path, native_name)) { return false; } - dir_path = filename; // インクルードディレクティブのテキストで上書き + dir_path = filename; // overwrite the include directive text return true; } - // インクルードファイル解析開始をフック + // hook the opened include file process template void opened_include_file( Context const& /*ctx*/, @@ -176,20 +176,20 @@ public: boost::filesystem::path abspath(boost::filesystem::absolute(absname)); auto found = std::find(node_list_.begin(), node_list_.end(), abspath); auto to = std::distance(node_list_.begin(), found); - if (found == node_list_.end()) { // 最初のインクルードならばノードに追加 + if (found == node_list_.end()) { // add node if first include node_list_.emplace_back(abspath, relname); } edge_list_.emplace_back(current_list_.back(), to); - current_list_.push_back(to); // カレントを更新 + current_list_.push_back(to); // update current current_ = to; } - // インクルードファイル解析完了をフック + // hook the returning from include file process template void returning_from_include_file(Context const& /*ctx*/) { current_ = current_list_.back(); - current_list_.pop_back(); // カレントを戻す + current_list_.pop_back(); // revert current } - // インクルードガード検出をフック + // hook the detected include guard process template void detected_include_guard( Context const& /*ctx*/, @@ -210,7 +210,7 @@ public: } }; -// システムインクルードパスの取得 +// collect sysinclude paths template void collect_sysinclude_paths(OutputIterator result, std::string const& command = "g++") { { @@ -224,7 +224,7 @@ void collect_sysinclude_paths(OutputIterator result, std::string const& command std::istreambuf_iterator() ); auto rng = boost::make_iterator_range(text); - rng = sprig::find_skip(rng, boost::algorithm::first_finder("#include <...>")); // インクルードパスの始点までスキップ + rng = sprig::find_skip(rng, boost::algorithm::first_finder("#include <...>")); // skip to begin of the include path rng = sprig::find_skip(rng, boost::algorithm::first_finder("\n")); while (boost::algorithm::starts_with(rng, " ")) { auto found = sprig::find_between( @@ -247,7 +247,7 @@ int main(int argc, const char* argv[]) { if (argc >= 2) { src = argv[1]; - // ファイルの内容を全部 text に読み込む + // read text from file std::ifstream ifs(argv[1]); text = std::string( std::istreambuf_iterator(ifs.rdbuf()), @@ -259,7 +259,7 @@ int main(int argc, const char* argv[]) { } try { - // プリプロセッサを用意 + // prepare preprocessor typedef boost::wave::context< std::string::iterator, boost::wave::cpplexer::lex_iterator >, @@ -268,14 +268,14 @@ int main(int argc, const char* argv[]) { > context_type; context_type ctx(text.begin(), text.end(), src.c_str(), ::include_graph_hooks(src)); - // ランゲージの設定 + // set language ctx.set_language( boost::wave::language_support( boost::wave::support_cpp11 - | boost::wave::support_option_include_guard_detection // インクルードガード検出 + | boost::wave::support_option_include_guard_detection // include guard detection ) ); - // インクルードパスの設定 + // set include paths if (!command.empty()) { std::cout << "collect command :\n" @@ -304,7 +304,7 @@ int main(int argc, const char* argv[]) { } if (!src.empty()) { - // プリプロセスを走らせる + // run preprocessor for (auto&& e : ctx) { //std::cout << e.get_value(); } @@ -323,7 +323,7 @@ int main(int argc, const char* argv[]) { std::vector tokens; boost::algorithm::split(tokens, line, boost::algorithm::is_space()); if (tokens.at(0) == "find") { - // インクルードファイルを検索 + // find include paths if (tokens.size() < 2) { std::cout << "missing parameter.\n" @@ -348,7 +348,7 @@ int main(int argc, const char* argv[]) { << std::flush ; } else if (tokens.at(0) == "graph") { - // グラフ出力 + // output graph std::cout << "graph output > out.graph.dot\n" ; @@ -358,7 +358,7 @@ int main(int argc, const char* argv[]) { << std::flush ; } else if (tokens.at(0) == "noguard") { - // 非インクルードガードを出力 + // output no include guarde files std::vector<::include_graph_hooks::node_type> list; ctx.get_hooks().collect_no_include_guard_files(std::back_inserter(list)); std::cout @@ -373,7 +373,7 @@ int main(int argc, const char* argv[]) { << std::flush ; } else if (tokens.at(0) == "circulated") { - // 循環インクルードを出力 + // output circulated includes std::vector::edge_descriptor> list; ctx.get_hooks().collect_circulated_includes(std::back_inserter(list)); auto g = ctx.get_hooks().make_graph(); @@ -390,12 +390,12 @@ int main(int argc, const char* argv[]) { << std::flush ; } else if (tokens.at(0) == "isolated") { - // Sprout の孤立ファイルを出力 + // output Sprout isolated files std::cout << "isolated files output > out.isolated.txt\n" ; std::ofstream ofs("out.isolated.txt"); - // Sprout のシステムインクル−ドパスを取得 + // get Sprout system include path std::string filepath("sprout/config.hpp"); std::string dirpath; if (!ctx.find_include_file(filepath, dirpath, true, 0)) { @@ -406,7 +406,7 @@ int main(int argc, const char* argv[]) { continue; } dirpath = boost::filesystem::path(filepath).parent_path().generic_string(); - // リスト出力 + // output list std::vector list; ctx.get_hooks().collect_isolated_files(std::back_inserter(list), dirpath); std::sort(list.begin(), list.end()); @@ -422,7 +422,7 @@ int main(int argc, const char* argv[]) { } } } catch (boost::wave::cpp_exception& e) { - // プリプロセスでエラー発生 + // eorror handling std::cerr << "#error " << e.file_name() << "(" << e.line_no() << "):" << e.description() << "\n" << std::flush