载入中...
搜索中...
未找到
CollapseScriptValue.h
浏览该文件的文档.
1#pragma once
5
12template <class T>
13[[nodiscard]] ResultRef<T> scriptValue(const ssq::Object& object) {
14 if (object.getType() == ssq::Type::INSTANCE && object.getTypeTag() == script::detail::squirrelTypeHash<T*>()) {
15 try {
16 if (auto* value = object.to<T*>()) return ResultRef<T>::success(std::ref(*value));
17 } catch (const ssq::TypeException&) {
18 // Malformed native wrappers are ordinary invalid arguments at this boundary.
19 }
20 }
21 return ResultRef<T>::failure(invalid("native bake argument has the wrong type or is null"));
22}
23} // namespace eve::physics::collapse_detail
Vocabulary aliases for nullable and checked borrowed references.
Object::Ptr value
Explicit Value/Owned/Borrowed semantics at the Squirrel boundary.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
ResultRef< T > scriptValue(const ssq::Object &object)
Type-check a VM-owned bake argument before obtaining its native reference. @ownership Borrowed only d...