remove script system and bindings

This commit is contained in:
BlackMATov
2020-10-04 04:54:16 +07:00
parent 27419dea3f
commit d257cf2adf
125 changed files with 0 additions and 7350 deletions

View File

@@ -18,7 +18,6 @@
#include "assets/mesh_asset.hpp"
#include "assets/model_asset.hpp"
#include "assets/prefab_asset.hpp"
#include "assets/script_asset.hpp"
#include "assets/shader_asset.hpp"
#include "assets/shape_asset.hpp"
#include "assets/sound_asset.hpp"
@@ -29,7 +28,6 @@
#include "assets/xml_asset.hpp"
#include "components/actor.hpp"
#include "components/behaviour.hpp"
#include "components/camera.hpp"
#include "components/colliders.hpp"
#include "components/commands.hpp"
@@ -51,7 +49,6 @@
#include "resources/flipbook.hpp"
#include "resources/model.hpp"
#include "resources/prefab.hpp"
#include "resources/script.hpp"
#include "resources/spine.hpp"
#include "resources/sprite.hpp"
@@ -62,7 +59,6 @@
#include "systems/label_system.hpp"
#include "systems/layout_system.hpp"
#include "systems/render_system.hpp"
#include "systems/script_system.hpp"
#include "systems/spine_system.hpp"
#include "systems/touch_system.hpp"
#include "systems/world_system.hpp"
@@ -78,7 +74,6 @@
#include "inspector.inl"
#include "library.hpp"
#include "library.inl"
#include "luasol.hpp"
#include "node.hpp"
#include "node.inl"
#include "starter.hpp"

View File

@@ -10,9 +10,6 @@
#include <ecs.hpp/ecs.hpp>
#define SOL_ALL_SAFETIES_ON 1
#include <3rdparty/sol/sol.hpp>
namespace e2d
{
namespace ecs
@@ -33,7 +30,6 @@ namespace e2d
class mesh_asset;
class model_asset;
class prefab_asset;
class script_asset;
class shader_asset;
class shape_asset;
class sound_asset;
@@ -44,7 +40,6 @@ namespace e2d
class xml_asset;
class actor;
class behaviour;
class camera;
class rect_collider;
class circle_collider;
@@ -71,7 +66,6 @@ namespace e2d
class flipbook;
class model;
class prefab;
class script;
class spine;
class sprite;
@@ -82,7 +76,6 @@ namespace e2d
class label_system;
class layout_system;
class render_system;
class script_system;
class spine_system;
class touch_system;
class world_system;
@@ -99,7 +92,6 @@ namespace e2d
class editor;
class inspector;
class luasol;
class starter;
class world;
@@ -111,24 +103,6 @@ namespace e2d
class const_gcomponent;
}
namespace sol
{
template < typename T >
struct unique_usertype_traits<e2d::intrusive_ptr<T>> {
using type = T;
using actual_type = e2d::intrusive_ptr<T>;
static const bool value = true;
static bool is_null(const actual_type& ptr) {
return !ptr;
}
static type* get(actual_type& ptr) {
return ptr.get();
}
};
}
namespace e2d::ecsex
{
template < typename T, typename Disposer, typename... Opts >

View File

@@ -1,21 +0,0 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
#include "../_high.hpp"
#include "../library.hpp"
#include "../resources/script.hpp"
namespace e2d
{
class script_asset final : public content_asset<script_asset, script> {
public:
static const char* type_name() noexcept { return "script_asset"; }
static load_async_result load_async(const library& library, str_view address);
};
}

View File

@@ -1,149 +0,0 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
#include "_components.hpp"
#include "../assets/script_asset.hpp"
namespace e2d
{
class behaviour final {
public:
behaviour() = default;
behaviour& meta(sol::table value) noexcept;
behaviour& script(const script_asset::ptr& value) noexcept;
[[nodiscard]] sol::table& meta() noexcept;
[[nodiscard]] const sol::table& meta() const noexcept;
[[nodiscard]] const script_asset::ptr& script() const noexcept;
private:
sol::table meta_;
script_asset::ptr script_;
};
}
namespace e2d
{
template <>
class factory_loader<behaviour> final : factory_loader<> {
public:
static const char* schema_source;
bool operator()(
behaviour& component,
const fill_context& ctx) const;
bool operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const;
};
}
namespace e2d
{
template <>
class component_inspector<behaviour> final : component_inspector<> {
public:
static const char* title;
void operator()(gcomponent<behaviour>& c) const;
};
}
namespace e2d
{
inline behaviour& behaviour::meta(sol::table value) noexcept {
meta_ = std::move(value);
return *this;
}
inline behaviour& behaviour::script(const script_asset::ptr& value) noexcept {
script_ = value;
return *this;
}
inline sol::table& behaviour::meta() noexcept {
return meta_;
}
inline const sol::table& behaviour::meta() const noexcept {
return meta_;
}
inline const script_asset::ptr& behaviour::script() const noexcept {
return script_;
}
}
namespace e2d::behaviours
{
ENUM_HPP_CLASS_DECL(fill_result, u8,
(failed)
(success))
ENUM_HPP_REGISTER_TRAITS(fill_result)
inline fill_result fill_meta_table(behaviour& behaviour) {
if ( !behaviour.script() ) {
return fill_result::failed;
}
sol::protected_function_result meta = behaviour.script()->content().call();
if ( !meta.valid() ) {
sol::error err = meta;
the<debug>().error("BEHAVIOUR: Behaviour script error:\n"
"--> Error: %0",
err.what());
return fill_result::failed;
}
if ( meta.get_type() != sol::type::table ) {
the<debug>().error("BEHAVIOUR: Behaviour script must return a meta table");
return fill_result::failed;
}
behaviour.meta(std::move(meta));
return fill_result::success;
}
ENUM_HPP_CLASS_DECL(call_result, u8,
(failed)
(success)
(method_not_found))
ENUM_HPP_REGISTER_TRAITS(call_result)
template < typename... Args >
call_result call_meta_method(behaviour& behaviour, str_view method, Args&&... args) {
if ( method.empty() || !behaviour.meta() || !behaviour.meta().valid() ) {
return call_result::method_not_found;
}
sol::optional<sol::protected_function> f = behaviour.meta()[method];
if ( !f ) {
return call_result::method_not_found;
}
sol::protected_function_result r = f->call(
behaviour.meta(),
std::forward<Args>(args)...);
if ( !r.valid() ) {
sol::error err = r;
the<debug>().error("BEHAVIOUR: Behaviour method error:\n"
"--> Method: %0\n"
"--> Error: %1",
method,
err.what());
return call_result::failed;
}
return call_result::success;
}
}

View File

@@ -1,47 +0,0 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
#include "_high.hpp"
#include "resources/script.hpp"
namespace e2d
{
class luasol final : public module<luasol> {
public:
luasol();
~luasol() noexcept final = default;
void collect_garbage();
template < typename F >
decltype(auto) with_state(F&& f);
template < typename F >
decltype(auto) with_state(F&& f) const;
std::optional<script> load_script(str_view src);
std::optional<script> load_script(buffer_view src);
private:
sol::state state_;
};
}
namespace e2d
{
template < typename F >
decltype(auto) luasol::with_state(F&& f) {
E2D_ASSERT(is_in_main_thread());
return std::invoke(std::forward<F>(f), state_);
}
template < typename F >
decltype(auto) luasol::with_state(F&& f) const {
E2D_ASSERT(is_in_main_thread());
return std::invoke(std::forward<F>(f), state_);
}
}

View File

@@ -1,62 +0,0 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
#include "../_high.hpp"
namespace e2d
{
class bad_script_access final : public exception {
public:
const char* what() const noexcept final {
return "bad script access";
}
};
class script final {
public:
script() = default;
~script() noexcept = default;
script(script&& other) noexcept;
script& operator=(script&& other) noexcept;
script(const script& other);
script& operator=(const script& other);
script(sol::protected_function&& func) noexcept;
script(const sol::protected_function& func);
script& assign(script&& other) noexcept;
script& assign(const script& other);
script& assign(sol::protected_function&& func) noexcept;
script& assign(const sol::protected_function& func);
void clear() noexcept;
void swap(script& other) noexcept;
bool empty() const noexcept;
template < typename... Ret, typename... Args >
decltype(auto) call(Args&&... args) const;
private:
std::optional<sol::protected_function> func_;
};
void swap(script& l, script& r) noexcept;
}
namespace e2d
{
template < typename... Ret, typename... Args >
decltype(auto) script::call(Args&&... args) const {
if ( !func_ ) {
throw bad_script_access();
}
return func_->call<Ret...>(std::forward<Args>(args)...);
}
}

View File

@@ -1,32 +0,0 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
#include "_systems.hpp"
namespace e2d
{
class script_system final
: public ecs::system<
systems::update_event,
ecs::before<systems::update_event>> {
public:
script_system();
~script_system() noexcept;
void process(
ecs::registry& owner,
const systems::update_event& event) override;
void process(
ecs::registry& owner,
const ecs::before<systems::update_event>& trigger) override;
private:
class internal_state;
std::unique_ptr<internal_state> state_;
};
}