Debian Codegraph @

modules/mono/signal_awaiter_utils.h

raw symbols SCIP
1 /**************************************************************************/
2 /* signal_awaiter_utils.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "csharp_script.h"
34 #include "mono_gc_handle.h"
35
36 #include "core/object/ref_counted.h"
37
38 Error gd_mono_connect_signal_awaiter(Object *p_source, const StringName &p_signal, Object *p_target, GCHandleIntPtr p_awaiter_handle_ptr);
39
40 class BaseSignalCallable : public CallableCustom {
41 public:
42 virtual StringName get_signal() const = 0;
43 };
44
45 class SignalAwaiterCallable : public BaseSignalCallable {
46 ObjectID target_id;
47 MonoGCHandleData awaiter_handle;
48 StringName signal;
49
50 public:
51 static bool compare_equal(const CallableCustom *p_a, const CallableCustom *p_b);
52 static bool compare_less(const CallableCustom *p_a, const CallableCustom *p_b);
53
54 static constexpr CompareEqualFunc compare_equal_func_ptr = &SignalAwaiterCallable::compare_equal;
55 static constexpr CompareEqualFunc compare_less_func_ptr = &SignalAwaiterCallable::compare_less;
56
57 uint32_t hash() const override;
58
59 String get_as_text() const override;
60
61 CompareEqualFunc get_compare_equal_func() const override;
62 CompareLessFunc get_compare_less_func() const override;
63
64 ObjectID get_object() const override;
65
66 StringName get_signal() const override;
67
68 void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const override;
69
70 SignalAwaiterCallable(Object *p_target, MonoGCHandleData p_awaiter_handle, const StringName &p_signal);
71 ~SignalAwaiterCallable();
72 };
73
74 class EventSignalCallable : public BaseSignalCallable {
75 Object *owner = nullptr;
76 StringName event_signal_name;
77
78 public:
79 static bool compare_equal(const CallableCustom *p_a, const CallableCustom *p_b);
80 static bool compare_less(const CallableCustom *p_a, const CallableCustom *p_b);
81
82 static constexpr CompareEqualFunc compare_equal_func_ptr = &EventSignalCallable::compare_equal;
83 static constexpr CompareEqualFunc compare_less_func_ptr = &EventSignalCallable::compare_less;
84
85 uint32_t hash() const override;
86
87 String get_as_text() const override;
88
89 CompareEqualFunc get_compare_equal_func() const override;
90 CompareLessFunc get_compare_less_func() const override;
91
92 ObjectID get_object() const override;
93
94 StringName get_signal() const override;
95
96 void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const override;
97
98 EventSignalCallable(Object *p_owner, const StringName &p_event_signal_name);
99 };