You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
GDScript: Lambda hot reloading
Co-authored-by: Adam Scott <ascott.ca@gmail.com>
This commit is contained in:
@@ -31,12 +31,13 @@
|
||||
#ifndef GDSCRIPT_LAMBDA_CALLABLE_H
|
||||
#define GDSCRIPT_LAMBDA_CALLABLE_H
|
||||
|
||||
#include "gdscript.h"
|
||||
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/templates/vector.h"
|
||||
#include "core/variant/callable.h"
|
||||
#include "core/variant/variant.h"
|
||||
|
||||
class GDScript;
|
||||
class GDScriptFunction;
|
||||
class GDScriptInstance;
|
||||
|
||||
@@ -44,6 +45,7 @@ class GDScriptLambdaCallable : public CallableCustom {
|
||||
GDScriptFunction *function = nullptr;
|
||||
Ref<GDScript> script;
|
||||
uint32_t h;
|
||||
GDScript::UpdatableFuncPtrElement updatable_func_ptr_element;
|
||||
|
||||
Vector<Variant> captures;
|
||||
|
||||
@@ -51,6 +53,7 @@ class GDScriptLambdaCallable : public CallableCustom {
|
||||
static bool compare_less(const CallableCustom *p_a, const CallableCustom *p_b);
|
||||
|
||||
public:
|
||||
bool is_valid() const override;
|
||||
uint32_t hash() const override;
|
||||
String get_as_text() const override;
|
||||
CompareEqualFunc get_compare_equal_func() const override;
|
||||
@@ -60,7 +63,7 @@ public:
|
||||
void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const override;
|
||||
|
||||
GDScriptLambdaCallable(Ref<GDScript> p_script, GDScriptFunction *p_function, const Vector<Variant> &p_captures);
|
||||
virtual ~GDScriptLambdaCallable() = default;
|
||||
virtual ~GDScriptLambdaCallable();
|
||||
};
|
||||
|
||||
// Lambda callable that references a particular object, so it can use `self` in the body.
|
||||
@@ -69,6 +72,7 @@ class GDScriptLambdaSelfCallable : public CallableCustom {
|
||||
Ref<RefCounted> reference; // For objects that are RefCounted, keep a reference.
|
||||
Object *object = nullptr; // For non RefCounted objects, use a direct pointer.
|
||||
uint32_t h;
|
||||
GDScript::UpdatableFuncPtrElement updatable_func_ptr_element;
|
||||
|
||||
Vector<Variant> captures;
|
||||
|
||||
@@ -76,6 +80,7 @@ class GDScriptLambdaSelfCallable : public CallableCustom {
|
||||
static bool compare_less(const CallableCustom *p_a, const CallableCustom *p_b);
|
||||
|
||||
public:
|
||||
bool is_valid() const override;
|
||||
uint32_t hash() const override;
|
||||
String get_as_text() const override;
|
||||
CompareEqualFunc get_compare_equal_func() const override;
|
||||
@@ -85,7 +90,7 @@ public:
|
||||
|
||||
GDScriptLambdaSelfCallable(Ref<RefCounted> p_self, GDScriptFunction *p_function, const Vector<Variant> &p_captures);
|
||||
GDScriptLambdaSelfCallable(Object *p_self, GDScriptFunction *p_function, const Vector<Variant> &p_captures);
|
||||
virtual ~GDScriptLambdaSelfCallable() = default;
|
||||
virtual ~GDScriptLambdaSelfCallable();
|
||||
};
|
||||
|
||||
#endif // GDSCRIPT_LAMBDA_CALLABLE_H
|
||||
|
||||
Reference in New Issue
Block a user