From de6ff29fbd625e2e874777bf8d5118ddf2225980 Mon Sep 17 00:00:00 2001 From: tqfx Date: Sun, 3 Mar 2024 02:07:50 +0800 Subject: [PATCH] add const for member function --- include/a/tf.h | 4 ++-- include/a/trajbell.h | 8 ++++---- include/a/trajpoly3.h | 6 +++--- include/a/trajpoly5.h | 6 +++--- include/a/trajpoly7.h | 8 ++++---- include/a/trajtrap.h | 6 +++--- javascript/src/a.cpp | 44 ++++++++++++++++++++++---------------------- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/include/a/tf.h b/include/a/tf.h index 79c360a..fe9692c 100644 --- a/include/a/tf.h +++ b/include/a/tf.h @@ -99,11 +99,11 @@ struct a_tf { a_tf_set_den(this, _den_n, _den_p, _output); } - A_INLINE a_float operator()(a_float x) + A_INLINE a_float operator()(a_float x) const { return a_tf_iter(this, x); } - A_INLINE void zero() { a_tf_zero(this); } + A_INLINE void zero() const { a_tf_zero(this); } #endif /* __cplusplus */ }; diff --git a/include/a/trajbell.h b/include/a/trajbell.h index 8f19102..228de89 100644 --- a/include/a/trajbell.h +++ b/include/a/trajbell.h @@ -169,19 +169,19 @@ struct a_trajbell { return a_trajbell_gen(this, _jm, _am, _vm, _p0, _p1, _v0, _v1); } - A_INLINE a_float pos(a_float dt) + A_INLINE a_float pos(a_float dt) const { return a_trajbell_pos(this, dt); } - A_INLINE a_float vel(a_float dt) + A_INLINE a_float vel(a_float dt) const { return a_trajbell_vel(this, dt); } - A_INLINE a_float acc(a_float dt) + A_INLINE a_float acc(a_float dt) const { return a_trajbell_acc(this, dt); } - A_INLINE a_float jer(a_float dt) + A_INLINE a_float jer(a_float dt) const { return a_trajbell_jer(this, dt); } diff --git a/include/a/trajpoly3.h b/include/a/trajpoly3.h index 06da1e1..5d45620 100644 --- a/include/a/trajpoly3.h +++ b/include/a/trajpoly3.h @@ -137,20 +137,20 @@ struct a_trajpoly3 { a_trajpoly3_gen0(this, ts, p0, p1, v0, v1); } - A_INLINE a_float pos(a_float dt) + A_INLINE a_float pos(a_float dt) const { return a_trajpoly3_pos(this, dt); } #if defined(A_TRAJPOLY3) && (A_TRAJPOLY3 + 0 > 1) A_INLINE void gen1() { a_trajpoly3_gen1(this); } - A_INLINE a_float vel(a_float dt) + A_INLINE a_float vel(a_float dt) const { return a_trajpoly3_vel(this, dt); } #endif /* A_TRAJPOLY3 */ #if defined(A_TRAJPOLY3) && (A_TRAJPOLY3 + 0 > 2) A_INLINE void gen2() { a_trajpoly3_gen2(this); } - A_INLINE a_float acc(a_float dt) + A_INLINE a_float acc(a_float dt) const { return a_trajpoly3_acc(this, dt); } diff --git a/include/a/trajpoly5.h b/include/a/trajpoly5.h index 9f57b25..9e85458 100644 --- a/include/a/trajpoly5.h +++ b/include/a/trajpoly5.h @@ -145,20 +145,20 @@ struct a_trajpoly5 { a_trajpoly5_gen0(this, ts, p0, p1, v0, v1, a0, a1); } - A_INLINE a_float pos(a_float dt) + A_INLINE a_float pos(a_float dt) const { return a_trajpoly5_pos(this, dt); } #if defined(A_TRAJPOLY5) && (A_TRAJPOLY5 + 0 > 1) A_INLINE void gen1() { a_trajpoly5_gen1(this); } - A_INLINE a_float vel(a_float dt) + A_INLINE a_float vel(a_float dt) const { return a_trajpoly5_vel(this, dt); } #endif /* A_TRAJPOLY5 */ #if defined(A_TRAJPOLY5) && (A_TRAJPOLY5 + 0 > 2) A_INLINE void gen2() { a_trajpoly5_gen2(this); } - A_INLINE a_float acc(a_float dt) + A_INLINE a_float acc(a_float dt) const { return a_trajpoly5_acc(this, dt); } diff --git a/include/a/trajpoly7.h b/include/a/trajpoly7.h index fd9d625..71a392f 100644 --- a/include/a/trajpoly7.h +++ b/include/a/trajpoly7.h @@ -175,27 +175,27 @@ struct a_trajpoly7 { a_trajpoly7_gen0(this, ts, p0, p1, v0, v1, a0, a1, j0, j1); } - A_INLINE a_float pos(a_float dt) + A_INLINE a_float pos(a_float dt) const { return a_trajpoly7_pos(this, dt); } #if defined(A_TRAJPOLY7) && (A_TRAJPOLY7 + 0 > 1) A_INLINE void gen1() { a_trajpoly7_gen1(this); } - A_INLINE a_float vel(a_float dt) + A_INLINE a_float vel(a_float dt) const { return a_trajpoly7_vel(this, dt); } #endif /* A_TRAJPOLY7 */ #if defined(A_TRAJPOLY7) && (A_TRAJPOLY7 + 0 > 2) A_INLINE void gen2() { a_trajpoly7_gen2(this); } - A_INLINE a_float acc(a_float dt) + A_INLINE a_float acc(a_float dt) const { return a_trajpoly7_acc(this, dt); } #endif /* A_TRAJPOLY7 */ #if defined(A_TRAJPOLY7) && (A_TRAJPOLY7 + 0 > 3) A_INLINE void gen3() { a_trajpoly7_gen3(this); } - A_INLINE a_float jer(a_float dt) + A_INLINE a_float jer(a_float dt) const { return a_trajpoly7_jer(this, dt); } diff --git a/include/a/trajtrap.h b/include/a/trajtrap.h index 921228c..dd209fe 100644 --- a/include/a/trajtrap.h +++ b/include/a/trajtrap.h @@ -115,15 +115,15 @@ struct a_trajtrap { return a_trajtrap_gen(this, vm, _ac, _de, _p0, _p1, _v0, _v1); } - A_INLINE a_float pos(a_float dt) + A_INLINE a_float pos(a_float dt) const { return a_trajtrap_pos(this, dt); } - A_INLINE a_float vel(a_float dt) + A_INLINE a_float vel(a_float dt) const { return a_trajtrap_vel(this, dt); } - A_INLINE a_float acc(a_float dt) + A_INLINE a_float acc(a_float dt) const { return a_trajtrap_acc(this, dt); } diff --git a/javascript/src/a.cpp b/javascript/src/a.cpp index 4d559d7..209fbea 100644 --- a/javascript/src/a.cpp +++ b/javascript/src/a.cpp @@ -52,7 +52,7 @@ struct crc8 { return emscripten::val(emscripten::typed_memory_view(0x100, table)); } - A_INLINE a_u8 operator()(std::string const &block, a_u8 value = 0) + A_INLINE a_u8 operator()(std::string const &block, a_u8 value = 0) const { return a_crc8(table, block.data(), block.length(), value); } @@ -85,7 +85,7 @@ struct crc16 { return emscripten::val(emscripten::typed_memory_view(0x100, table)); } - A_INLINE a_u16 operator()(std::string const &block, a_u16 value = 0) + A_INLINE a_u16 operator()(std::string const &block, a_u16 value = 0) const { return eval(table, block.data(), block.length(), value); } @@ -129,7 +129,7 @@ struct crc32 { return emscripten::val(emscripten::typed_memory_view(0x100, table)); } - A_INLINE a_u32 operator()(std::string const &block, a_u32 value = 0) + A_INLINE a_u32 operator()(std::string const &block, a_u32 value = 0) const { return eval(table, block.data(), block.length(), value); } @@ -174,7 +174,7 @@ struct crc64 { return emscripten::val(emscripten::typed_memory_view(0x100, table)); } - A_INLINE emscripten::val operator()(std::string const &block, a_u64 value = 0) + A_INLINE emscripten::val operator()(std::string const &block, a_u64 value = 0) const { return emscripten::val(eval(table, block.data(), block.length(), value)); } @@ -650,7 +650,7 @@ struct tf: public a_tf set_den_(den, u.o); return this; } - A_INLINE a_float operator()(a_float x) + A_INLINE a_float operator()(a_float x) const { return a_tf::operator()(x); } @@ -670,10 +670,10 @@ struct trajbell: public a_trajbell { return a_trajbell::gen(_jm, _am, _vm, _p0, _p1, _v0, _v1); } - A_INLINE a_float pos(a_float dt) { return a_trajbell::pos(dt); } - A_INLINE a_float vel(a_float dt) { return a_trajbell::vel(dt); } - A_INLINE a_float acc(a_float dt) { return a_trajbell::acc(dt); } - A_INLINE a_float jer(a_float dt) { return a_trajbell::jer(dt); } + A_INLINE a_float pos(a_float dt) const { return a_trajbell::pos(dt); } + A_INLINE a_float vel(a_float dt) const { return a_trajbell::vel(dt); } + A_INLINE a_float acc(a_float dt) const { return a_trajbell::acc(dt); } + A_INLINE a_float jer(a_float dt) const { return a_trajbell::jer(dt); } }; #include "a/trajpoly3.h" @@ -685,9 +685,9 @@ struct trajpoly3: public a_trajpoly3 { a_trajpoly3_gen(this, ts, p0, p1, v0, v1); } - A_INLINE a_float pos(a_float dt) { return a_trajpoly3::pos(dt); } - A_INLINE a_float vel(a_float dt) { return a_trajpoly3::vel(dt); } - A_INLINE a_float acc(a_float dt) { return a_trajpoly3::acc(dt); } + A_INLINE a_float pos(a_float dt) const { return a_trajpoly3::pos(dt); } + A_INLINE a_float vel(a_float dt) const { return a_trajpoly3::vel(dt); } + A_INLINE a_float acc(a_float dt) const { return a_trajpoly3::acc(dt); } A_INLINE emscripten::val get_p() const { return js_array_num_new(p, A_LEN(p)); } A_INLINE emscripten::val get_v() const { return js_array_num_new(v, A_LEN(v)); } A_INLINE emscripten::val get_a() const { return js_array_num_new(a, A_LEN(a)); } @@ -703,9 +703,9 @@ struct trajpoly5: public a_trajpoly5 { a_trajpoly5_gen(this, ts, p0, p1, v0, v1, a0, a1); } - A_INLINE a_float pos(a_float dt) { return a_trajpoly5::pos(dt); } - A_INLINE a_float vel(a_float dt) { return a_trajpoly5::vel(dt); } - A_INLINE a_float acc(a_float dt) { return a_trajpoly5::acc(dt); } + A_INLINE a_float pos(a_float dt) const { return a_trajpoly5::pos(dt); } + A_INLINE a_float vel(a_float dt) const { return a_trajpoly5::vel(dt); } + A_INLINE a_float acc(a_float dt) const { return a_trajpoly5::acc(dt); } A_INLINE emscripten::val get_p() const { return js_array_num_new(p, A_LEN(p)); } A_INLINE emscripten::val get_v() const { return js_array_num_new(v, A_LEN(v)); } A_INLINE emscripten::val get_a() const { return js_array_num_new(a, A_LEN(a)); } @@ -722,10 +722,10 @@ struct trajpoly7: public a_trajpoly7 { a_trajpoly7_gen(this, ts, p0, p1, v0, v1, a0, a1, j0, j1); } - A_INLINE a_float pos(a_float dt) { return a_trajpoly7::pos(dt); } - A_INLINE a_float vel(a_float dt) { return a_trajpoly7::vel(dt); } - A_INLINE a_float acc(a_float dt) { return a_trajpoly7::acc(dt); } - A_INLINE a_float jer(a_float dt) { return a_trajpoly7::jer(dt); } + A_INLINE a_float pos(a_float dt) const { return a_trajpoly7::pos(dt); } + A_INLINE a_float vel(a_float dt) const { return a_trajpoly7::vel(dt); } + A_INLINE a_float acc(a_float dt) const { return a_trajpoly7::acc(dt); } + A_INLINE a_float jer(a_float dt) const { return a_trajpoly7::jer(dt); } A_INLINE emscripten::val get_p() const { return js_array_num_new(p, A_LEN(p)); } A_INLINE emscripten::val get_v() const { return js_array_num_new(v, A_LEN(v)); } A_INLINE emscripten::val get_a() const { return js_array_num_new(a, A_LEN(a)); } @@ -741,9 +741,9 @@ struct trajtrap: public a_trajtrap { return a_trajtrap::gen(vm, _ac, _de, _p0, _p1, _v0, _v1); } - A_INLINE a_float pos(a_float dt) { return a_trajtrap::pos(dt); } - A_INLINE a_float vel(a_float dt) { return a_trajtrap::vel(dt); } - A_INLINE a_float acc(a_float dt) { return a_trajtrap::acc(dt); } + A_INLINE a_float pos(a_float dt) const { return a_trajtrap::pos(dt); } + A_INLINE a_float vel(a_float dt) const { return a_trajtrap::vel(dt); } + A_INLINE a_float acc(a_float dt) const { return a_trajtrap::acc(dt); } }; #include "a/version.h" -- 2.11.4.GIT