diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2024-04-08 11:16:28 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-04-08 19:40:24 +0200 |
| commit | 457cdf24489c20f0f9b9b9877bf9e875aa643f91 (patch) | |
| tree | 5c01a4cbe3935784e30b3a2a2912e62aa00ef29a /src/critter-script.cpp | |
| parent | b25edf465d08750fb5f93068cd8b8d5cd9d0dcec (diff) | |
wip
Diffstat (limited to 'src/critter-script.cpp')
| -rw-r--r-- | src/critter-script.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/critter-script.cpp b/src/critter-script.cpp index e2355a64..ede5c5d7 100644 --- a/src/critter-script.cpp +++ b/src/critter-script.cpp @@ -1,7 +1,46 @@ -#include "critter-script.hpp" +#include "critter-script.inl" +#include "compat/assert.hpp" namespace floormat { +namespace { +CORRADE_ALWAYS_INLINE +void touch_ptr(const std::shared_ptr<critter>& p) +{ + (void)p; +#if fm_ASAN + volatile char foo = *reinterpret_cast<volatile const char*>(&*p); + (void)foo; +//#else +// fm_debug_assert(p); +#endif +} + +struct empty_critter_script final : critter_script +{ + empty_critter_script(); + void on_init(const std::shared_ptr<critter>& c) override; + void on_update(const std::shared_ptr<critter>& c, size_t& i, const Ns& dt) override; + void on_destroy(const std::shared_ptr<critter>& c, script_destroy_reason reason) override; + void delete_self() noexcept override; +}; + +empty_critter_script::empty_critter_script() : critter_script{nullptr} {} +void empty_critter_script::on_init(const std::shared_ptr<critter>& p) { touch_ptr(p); } +void empty_critter_script::on_update(const std::shared_ptr<critter>& p, size_t&, const Ns&) { touch_ptr(p); } +void empty_critter_script::on_destroy(const std::shared_ptr<critter>& p, script_destroy_reason) { touch_ptr(p); } +void empty_critter_script::delete_self() noexcept {} + +empty_critter_script empty_script_ = {}; + +} // namespace + +critter_script* const critter_script::empty_script = &empty_script_; + +critter_script::critter_script(const std::shared_ptr<critter>&) {} +critter_script::~critter_script() noexcept {} + +template class Script<critter_script, critter>; } // namespace floormat |
