summaryrefslogtreecommitdiffhomepage
path: root/src/script.inl
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-05-06 03:22:03 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-05-06 03:22:03 +0200
commit518e8cd4cc14bf04dd08f2f8db793430fea175fd (patch)
tree3e3f57b5c18bbb335b4840f0512eb57d8bc21222 /src/script.inl
parentde33d8773c3357653414143b8a76b08b8aa8d149 (diff)
a?
Diffstat (limited to 'src/script.inl')
-rw-r--r--src/script.inl19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/script.inl b/src/script.inl
index afa84e65..27a79e31 100644
--- a/src/script.inl
+++ b/src/script.inl
@@ -2,7 +2,8 @@
#include "script.hpp"
#include "compat/assert.hpp"
#include <utility>
-#include <Corrade/Containers/StringView.h>
+#include <cr/StringView.h>
+#include <cr/Pointer.h>
// ReSharper disable CppDFAUnreachableCode
@@ -61,6 +62,7 @@ Script<S, Obj>::Script(): ptr{nullptr}, _state{script_lifecycle::no_init}
}
template <typename S, typename Obj> script_lifecycle Script<S, Obj>::state() const { return _state; }
+template<typename S, typename Obj> Script<S, Obj>::operator bool() const { return ptr; }
template <typename S, typename Obj>
S* Script<S, Obj>::operator->()
@@ -73,12 +75,19 @@ S* Script<S, Obj>::operator->()
template<typename S, typename Obj>
void Script<S, Obj>::do_create(S* p)
{
- fm_assert(p);
+ if (!p)
+ p = make_empty();
FM_ASSERT_SCRIPT_STATE(script_lifecycle::no_init);
_state = script_lifecycle::initializing;
ptr = p;
}
+template<typename S, typename Obj>
+void Script<S, Obj>::do_create(Pointer<S> p)
+{
+ do_create(p.release());
+}
+
template <typename S, typename Obj>
void Script<S, Obj>::do_initialize(const std::shared_ptr<Obj>& obj)
{
@@ -112,6 +121,12 @@ void Script<S, Obj>::do_reassign(S* p, const std::shared_ptr<Obj>& obj)
}
template <typename S, typename Obj>
+void Script<S, Obj>::do_reassign(Pointer<S> p, const std::shared_ptr<Obj>& obj)
+{
+ return do_reassign(p.release(), obj);
+}
+
+template <typename S, typename Obj>
void Script<S, Obj>::do_clear(const std::shared_ptr<Obj>& obj)
{
FM_ASSERT_SCRIPT_STATE(script_lifecycle::created);