GDScript: Lambda hot reloading
Co-authored-by: Adam Scott <ascott.ca@gmail.com>
This commit is contained in:
parent
30f2a6d611
commit
9fb8862d73
7 changed files with 309 additions and 3 deletions
|
|
@ -86,6 +86,8 @@ class GDScript : public Script {
|
|||
friend class GDScriptAnalyzer;
|
||||
friend class GDScriptCompiler;
|
||||
friend class GDScriptDocGen;
|
||||
friend class GDScriptLambdaCallable;
|
||||
friend class GDScriptLambdaSelfCallable;
|
||||
friend class GDScriptLanguage;
|
||||
friend struct GDScriptUtilityFunctionsDefinitions;
|
||||
|
||||
|
|
@ -108,6 +110,30 @@ class GDScript : public Script {
|
|||
HashMap<StringName, MethodInfo> _signals;
|
||||
Dictionary rpc_config;
|
||||
|
||||
struct LambdaInfo {
|
||||
int capture_count;
|
||||
bool use_self;
|
||||
};
|
||||
|
||||
HashMap<GDScriptFunction *, LambdaInfo> lambda_info;
|
||||
|
||||
// List is used here because a ptr to elements are stored, so the memory locations need to be stable
|
||||
struct UpdatableFuncPtr {
|
||||
List<GDScriptFunction **> ptrs;
|
||||
Mutex mutex;
|
||||
bool initialized = false;
|
||||
};
|
||||
struct UpdatableFuncPtrElement {
|
||||
List<GDScriptFunction **>::Element *element = nullptr;
|
||||
Mutex *mutex = nullptr;
|
||||
};
|
||||
static thread_local UpdatableFuncPtr func_ptrs_to_update_thread_local;
|
||||
List<UpdatableFuncPtr *> func_ptrs_to_update;
|
||||
Mutex func_ptrs_to_update_mutex;
|
||||
|
||||
UpdatableFuncPtrElement _add_func_ptr_to_update(GDScriptFunction **p_func_ptr_ptr);
|
||||
static void _remove_func_ptr_to_update(const UpdatableFuncPtrElement p_func_ptr_element);
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
// For static data storage during hot-reloading.
|
||||
HashMap<StringName, MemberInfo> old_static_variables_indices;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue