| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/extension/ext_wrappers.gen.inc" |
| 34 |
#include "core/object/gdvirtual.gen.inc" |
| 35 |
#include "core/object/script_language.h" |
| 36 |
#include "core/variant/native_ptr.h" |
| 37 |
#include "core/variant/typed_array.h" |
| 38 |
|
| 39 |
class ScriptExtension : public Script { |
| 40 |
GDCLASS(ScriptExtension, Script) |
| 41 |
|
| 42 |
protected: |
| 43 |
EXBIND0R(bool, editor_can_reload_from_file) |
| 44 |
|
| 45 |
GDVIRTUAL1(_placeholder_erased, GDExtensionPtr<void>) |
| 46 |
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override { |
| 47 |
GDVIRTUAL_CALL(_placeholder_erased, p_placeholder); |
| 48 |
} |
| 49 |
|
| 50 |
static void _bind_methods(); |
| 51 |
|
| 52 |
public: |
| 53 |
EXBIND0RC(bool, can_instantiate) |
| 54 |
EXBIND0RC(Ref<Script>, get_base_script) |
| 55 |
EXBIND0RC(StringName, get_global_name) |
| 56 |
EXBIND1RC(bool, inherits_script, const Ref<Script> &) |
| 57 |
EXBIND0RC(StringName, get_instance_base_type) |
| 58 |
|
| 59 |
GDVIRTUAL1RC_REQUIRED(GDExtensionPtr<void>, _instance_create, Object *) |
| 60 |
virtual ScriptInstance *instance_create(Object *p_this) override { |
| 61 |
GDExtensionPtr<void> ret = nullptr; |
| 62 |
GDVIRTUAL_CALL(_instance_create, p_this, ret); |
| 63 |
return reinterpret_cast<ScriptInstance *>(ret.operator void *()); |
| 64 |
} |
| 65 |
GDVIRTUAL1RC_REQUIRED(GDExtensionPtr<void>, _placeholder_instance_create, Object *) |
| 66 |
PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) override { |
| 67 |
GDExtensionPtr<void> ret = nullptr; |
| 68 |
GDVIRTUAL_CALL(_placeholder_instance_create, p_this, ret); |
| 69 |
return reinterpret_cast<PlaceHolderScriptInstance *>(ret.operator void *()); |
| 70 |
} |
| 71 |
|
| 72 |
EXBIND1RC(bool, instance_has, const Object *) |
| 73 |
EXBIND0RC(bool, has_source_code) |
| 74 |
EXBIND0RC(String, get_source_code) |
| 75 |
EXBIND1(set_source_code, const String &) |
| 76 |
EXBIND1R(Error, reload, bool) |
| 77 |
|
| 78 |
GDVIRTUAL0RC_REQUIRED(StringName, _get_doc_class_name) |
| 79 |
GDVIRTUAL0RC_REQUIRED(TypedArray<Dictionary>, _get_documentation) |
| 80 |
GDVIRTUAL0RC(String, _get_class_icon_path) |
| 81 |
#ifdef TOOLS_ENABLED |
| 82 |
virtual StringName get_doc_class_name() const override { |
| 83 |
StringName ret; |
| 84 |
GDVIRTUAL_CALL(_get_doc_class_name, ret); |
| 85 |
return ret; |
| 86 |
} |
| 87 |
|
| 88 |
virtual Vector<DocData::ClassDoc> get_documentation() const override { |
| 89 |
TypedArray<Dictionary> doc; |
| 90 |
GDVIRTUAL_CALL(_get_documentation, doc); |
| 91 |
|
| 92 |
Vector<DocData::ClassDoc> class_doc; |
| 93 |
for (int i = 0; i < doc.size(); i++) { |
| 94 |
class_doc.append(DocData::ClassDoc::from_dict(doc[i])); |
| 95 |
} |
| 96 |
|
| 97 |
return class_doc; |
| 98 |
} |
| 99 |
|
| 100 |
virtual String get_class_icon_path() const override { |
| 101 |
String ret; |
| 102 |
GDVIRTUAL_CALL(_get_class_icon_path, ret); |
| 103 |
return ret; |
| 104 |
} |
| 105 |
#endif |
| 106 |
|
| 107 |
EXBIND1RC(bool, has_method, const StringName &) |
| 108 |
EXBIND1RC(bool, has_static_method, const StringName &) |
| 109 |
|
| 110 |
GDVIRTUAL1RC(Variant, _get_script_method_argument_count, const StringName &) |
| 111 |
virtual int get_script_method_argument_count(const StringName &p_method, bool *r_is_valid = nullptr) const override { |
| 112 |
Variant ret; |
| 113 |
if (GDVIRTUAL_CALL(_get_script_method_argument_count, p_method, ret) && ret.get_type() == Variant::INT) { |
| 114 |
if (r_is_valid) { |
| 115 |
*r_is_valid = true; |
| 116 |
} |
| 117 |
return ret.operator int(); |
| 118 |
} |
| 119 |
|
| 120 |
return Script::get_script_method_argument_count(p_method, r_is_valid); |
| 121 |
} |
| 122 |
|
| 123 |
GDVIRTUAL1RC_REQUIRED(Dictionary, _get_method_info, const StringName &) |
| 124 |
virtual MethodInfo get_method_info(const StringName &p_method) const override { |
| 125 |
Dictionary mi; |
| 126 |
GDVIRTUAL_CALL(_get_method_info, p_method, mi); |
| 127 |
return MethodInfo::from_dict(mi); |
| 128 |
} |
| 129 |
|
| 130 |
EXBIND0RC(bool, is_tool) |
| 131 |
EXBIND0RC(bool, is_valid) |
| 132 |
|
| 133 |
virtual bool is_abstract() const override { |
| 134 |
bool abst; |
| 135 |
return GDVIRTUAL_CALL(_is_abstract, abst) && abst; |
| 136 |
} |
| 137 |
GDVIRTUAL0RC(bool, _is_abstract) |
| 138 |
|
| 139 |
EXBIND0RC(ScriptLanguage *, get_language) |
| 140 |
EXBIND1RC(bool, has_script_signal, const StringName &) |
| 141 |
|
| 142 |
GDVIRTUAL0RC_REQUIRED(TypedArray<Dictionary>, _get_script_signal_list) |
| 143 |
|
| 144 |
virtual void get_script_signal_list(List<MethodInfo> *r_signals) const override { |
| 145 |
TypedArray<Dictionary> sl; |
| 146 |
GDVIRTUAL_CALL(_get_script_signal_list, sl); |
| 147 |
for (int i = 0; i < sl.size(); i++) { |
| 148 |
r_signals->push_back(MethodInfo::from_dict(sl[i])); |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
GDVIRTUAL1RC_REQUIRED(bool, _has_property_default_value, const StringName &) |
| 153 |
GDVIRTUAL1RC_REQUIRED(Variant, _get_property_default_value, const StringName &) |
| 154 |
|
| 155 |
virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const override { |
| 156 |
bool has_dv = false; |
| 157 |
if (!GDVIRTUAL_CALL(_has_property_default_value, p_property, has_dv) || !has_dv) { |
| 158 |
return false; |
| 159 |
} |
| 160 |
Variant ret; |
| 161 |
GDVIRTUAL_CALL(_get_property_default_value, p_property, ret); |
| 162 |
r_value = ret; |
| 163 |
return true; |
| 164 |
} |
| 165 |
|
| 166 |
EXBIND0(update_exports) |
| 167 |
|
| 168 |
GDVIRTUAL0RC_REQUIRED(TypedArray<Dictionary>, _get_script_method_list) |
| 169 |
|
| 170 |
virtual void get_script_method_list(List<MethodInfo> *r_methods) const override { |
| 171 |
TypedArray<Dictionary> sl; |
| 172 |
GDVIRTUAL_CALL(_get_script_method_list, sl); |
| 173 |
for (int i = 0; i < sl.size(); i++) { |
| 174 |
r_methods->push_back(MethodInfo::from_dict(sl[i])); |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
GDVIRTUAL0RC_REQUIRED(TypedArray<Dictionary>, _get_script_property_list) |
| 179 |
|
| 180 |
virtual void get_script_property_list(List<PropertyInfo> *r_propertys) const override { |
| 181 |
TypedArray<Dictionary> sl; |
| 182 |
GDVIRTUAL_CALL(_get_script_property_list, sl); |
| 183 |
for (int i = 0; i < sl.size(); i++) { |
| 184 |
r_propertys->push_back(PropertyInfo::from_dict(sl[i])); |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
EXBIND1RC(int, get_member_line, const StringName &) |
| 189 |
|
| 190 |
GDVIRTUAL0RC_REQUIRED(Dictionary, _get_constants) |
| 191 |
|
| 192 |
virtual void get_constants(HashMap<StringName, Variant> *p_constants) override { |
| 193 |
Dictionary constants; |
| 194 |
GDVIRTUAL_CALL(_get_constants, constants); |
| 195 |
for (const KeyValue<Variant, Variant> &kv : constants) { |
| 196 |
p_constants->insert(kv.key, kv.value); |
| 197 |
} |
| 198 |
} |
| 199 |
GDVIRTUAL0RC_REQUIRED(TypedArray<StringName>, _get_members) |
| 200 |
virtual void get_members(HashSet<StringName> *p_members) override { |
| 201 |
TypedArray<StringName> members; |
| 202 |
GDVIRTUAL_CALL(_get_members, members); |
| 203 |
for (int i = 0; i < members.size(); i++) { |
| 204 |
p_members->insert(members[i]); |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
EXBIND0RC(bool, is_placeholder_fallback_enabled) |
| 209 |
|
| 210 |
GDVIRTUAL0RC_REQUIRED(Variant, _get_rpc_config) |
| 211 |
|
| 212 |
virtual const Variant get_rpc_config() const override { |
| 213 |
Variant ret; |
| 214 |
GDVIRTUAL_CALL(_get_rpc_config, ret); |
| 215 |
return ret; |
| 216 |
} |
| 217 |
}; |
| 218 |
|
| 219 |
typedef ScriptLanguage::ProfilingInfo ScriptLanguageExtensionProfilingInfo; |
| 220 |
|
| 221 |
GDVIRTUAL_NATIVE_PTR(ScriptLanguageExtensionProfilingInfo) |
| 222 |
|
| 223 |
class ScriptLanguageExtension : public ScriptLanguage { |
| 224 |
GDCLASS(ScriptLanguageExtension, ScriptLanguage) |
| 225 |
protected: |
| 226 |
static void _bind_methods(); |
| 227 |
|
| 228 |
public: |
| 229 |
EXBIND0RC(String, get_name) |
| 230 |
|
| 231 |
EXBIND0(init) |
| 232 |
EXBIND0RC(String, get_type) |
| 233 |
EXBIND0RC(String, get_extension) |
| 234 |
EXBIND0(finish) |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
GDVIRTUAL0RC_REQUIRED(Vector<String>, _get_reserved_words) |
| 239 |
|
| 240 |
virtual Vector<String> get_reserved_words() const override { |
| 241 |
Vector<String> ret; |
| 242 |
GDVIRTUAL_CALL(_get_reserved_words, ret); |
| 243 |
return ret; |
| 244 |
} |
| 245 |
EXBIND1RC(bool, is_control_flow_keyword, const String &) |
| 246 |
|
| 247 |
GDVIRTUAL0RC_REQUIRED(Vector<String>, _get_comment_delimiters) |
| 248 |
|
| 249 |
virtual Vector<String> get_comment_delimiters() const override { |
| 250 |
Vector<String> ret; |
| 251 |
GDVIRTUAL_CALL(_get_comment_delimiters, ret); |
| 252 |
return ret; |
| 253 |
} |
| 254 |
|
| 255 |
GDVIRTUAL0RC(Vector<String>, _get_doc_comment_delimiters) |
| 256 |
|
| 257 |
virtual Vector<String> get_doc_comment_delimiters() const override { |
| 258 |
Vector<String> ret; |
| 259 |
GDVIRTUAL_CALL(_get_doc_comment_delimiters, ret); |
| 260 |
return ret; |
| 261 |
} |
| 262 |
|
| 263 |
GDVIRTUAL0RC_REQUIRED(Vector<String>, _get_string_delimiters) |
| 264 |
|
| 265 |
virtual Vector<String> get_string_delimiters() const override { |
| 266 |
Vector<String> ret; |
| 267 |
GDVIRTUAL_CALL(_get_string_delimiters, ret); |
| 268 |
return ret; |
| 269 |
} |
| 270 |
|
| 271 |
EXBIND3RC(Ref<Script>, make_template, const String &, const String &, const String &) |
| 272 |
|
| 273 |
GDVIRTUAL1RC_REQUIRED(TypedArray<Dictionary>, _get_built_in_templates, StringName) |
| 274 |
|
| 275 |
virtual Vector<ScriptTemplate> get_built_in_templates(const StringName &p_object) override { |
| 276 |
TypedArray<Dictionary> ret; |
| 277 |
GDVIRTUAL_CALL(_get_built_in_templates, p_object, ret); |
| 278 |
Vector<ScriptTemplate> stret; |
| 279 |
for (int i = 0; i < ret.size(); i++) { |
| 280 |
Dictionary d = ret[i]; |
| 281 |
ScriptTemplate st; |
| 282 |
ERR_CONTINUE(!d.has("inherit")); |
| 283 |
st.inherit = d["inherit"]; |
| 284 |
ERR_CONTINUE(!d.has("name")); |
| 285 |
st.name = d["name"]; |
| 286 |
ERR_CONTINUE(!d.has("description")); |
| 287 |
st.description = d["description"]; |
| 288 |
ERR_CONTINUE(!d.has("content")); |
| 289 |
st.content = d["content"]; |
| 290 |
ERR_CONTINUE(!d.has("id")); |
| 291 |
st.id = d["id"]; |
| 292 |
ERR_CONTINUE(!d.has("origin")); |
| 293 |
st.origin = TemplateLocation(int(d["origin"])); |
| 294 |
stret.push_back(st); |
| 295 |
} |
| 296 |
return stret; |
| 297 |
} |
| 298 |
|
| 299 |
EXBIND0R(bool, is_using_templates) |
| 300 |
|
| 301 |
GDVIRTUAL6RC_REQUIRED(Dictionary, _validate, const String &, const String &, bool, bool, bool, bool) |
| 302 |
virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptError> *r_errors = nullptr, List<Warning> *r_warnings = nullptr, HashSet<int> *r_safe_lines = nullptr) const override { |
| 303 |
Dictionary ret; |
| 304 |
GDVIRTUAL_CALL(_validate, p_script, p_path, r_functions != nullptr, r_errors != nullptr, r_warnings != nullptr, r_safe_lines != nullptr, ret); |
| 305 |
if (!ret.has("valid")) { |
| 306 |
return false; |
| 307 |
} |
| 308 |
if (r_functions != nullptr && ret.has("functions")) { |
| 309 |
Vector<String> functions = ret["functions"]; |
| 310 |
for (int i = 0; i < functions.size(); i++) { |
| 311 |
r_functions->push_back(functions[i]); |
| 312 |
} |
| 313 |
} |
| 314 |
if (r_errors != nullptr && ret.has("errors")) { |
| 315 |
Array errors = ret["errors"]; |
| 316 |
for (const Variant &error : errors) { |
| 317 |
Dictionary err = error; |
| 318 |
ERR_CONTINUE(!err.has("line")); |
| 319 |
ERR_CONTINUE(!err.has("column")); |
| 320 |
ERR_CONTINUE(!err.has("message")); |
| 321 |
|
| 322 |
ScriptError serr; |
| 323 |
if (err.has("path")) { |
| 324 |
serr.path = err["path"]; |
| 325 |
} |
| 326 |
serr.line = err["line"]; |
| 327 |
serr.column = err["column"]; |
| 328 |
serr.message = err["message"]; |
| 329 |
|
| 330 |
r_errors->push_back(serr); |
| 331 |
} |
| 332 |
} |
| 333 |
if (r_warnings != nullptr && ret.has("warnings")) { |
| 334 |
ERR_FAIL_COND_V(!ret.has("warnings"), false); |
| 335 |
Array warnings = ret["warnings"]; |
| 336 |
for (const Variant &warning : warnings) { |
| 337 |
Dictionary warn = warning; |
| 338 |
ERR_CONTINUE(!warn.has("start_line")); |
| 339 |
ERR_CONTINUE(!warn.has("end_line")); |
| 340 |
ERR_CONTINUE(!warn.has("code")); |
| 341 |
ERR_CONTINUE(!warn.has("string_code")); |
| 342 |
ERR_CONTINUE(!warn.has("message")); |
| 343 |
|
| 344 |
Warning swarn; |
| 345 |
swarn.start_line = warn["start_line"]; |
| 346 |
swarn.end_line = warn["end_line"]; |
| 347 |
swarn.code = warn["code"]; |
| 348 |
swarn.string_code = warn["string_code"]; |
| 349 |
swarn.message = warn["message"]; |
| 350 |
|
| 351 |
r_warnings->push_back(swarn); |
| 352 |
} |
| 353 |
} |
| 354 |
if (r_safe_lines != nullptr && ret.has("safe_lines")) { |
| 355 |
PackedInt32Array safe_lines = ret["safe_lines"]; |
| 356 |
for (int i = 0; i < safe_lines.size(); i++) { |
| 357 |
r_safe_lines->insert(safe_lines[i]); |
| 358 |
} |
| 359 |
} |
| 360 |
return ret["valid"]; |
| 361 |
} |
| 362 |
|
| 363 |
EXBIND1RC(String, validate_path, const String &) |
| 364 |
GDVIRTUAL0RC_REQUIRED(Object *, _create_script) |
| 365 |
Script *create_script() const override { |
| 366 |
Object *ret = nullptr; |
| 367 |
GDVIRTUAL_CALL(_create_script, ret); |
| 368 |
return Object::cast_to<Script>(ret); |
| 369 |
} |
| 370 |
#ifndef DISABLE_DEPRECATED |
| 371 |
GDVIRTUAL0RC(bool, _has_named_classes) |
| 372 |
#endif |
| 373 |
EXBIND0RC(bool, supports_builtin_mode) |
| 374 |
EXBIND0RC(bool, supports_documentation) |
| 375 |
EXBIND0RC(bool, can_inherit_from_file) |
| 376 |
|
| 377 |
EXBIND2RC(int, find_function, const String &, const String &) |
| 378 |
EXBIND3RC(String, make_function, const String &, const String &, const PackedStringArray &) |
| 379 |
EXBIND0RC(bool, can_make_function) |
| 380 |
EXBIND3R(Error, open_in_external_editor, const Ref<Script> &, int, int) |
| 381 |
EXBIND0R(bool, overrides_external_editor) |
| 382 |
|
| 383 |
GDVIRTUAL0RC(ScriptNameCasing, _preferred_file_name_casing); |
| 384 |
|
| 385 |
virtual ScriptNameCasing preferred_file_name_casing() const override { |
| 386 |
ScriptNameCasing ret; |
| 387 |
if (GDVIRTUAL_CALL(_preferred_file_name_casing, ret)) { |
| 388 |
return ret; |
| 389 |
} |
| 390 |
return ScriptNameCasing::SCRIPT_NAME_CASING_SNAKE_CASE; |
| 391 |
} |
| 392 |
|
| 393 |
GDVIRTUAL3RC_REQUIRED(Dictionary, _complete_code, const String &, const String &, Object *) |
| 394 |
|
| 395 |
virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<CodeCompletionOption> *r_options, bool &r_force, String &r_call_hint) override { |
| 396 |
Dictionary ret; |
| 397 |
GDVIRTUAL_CALL(_complete_code, p_code, p_path, p_owner, ret); |
| 398 |
if (!ret.has("result")) { |
| 399 |
return ERR_UNAVAILABLE; |
| 400 |
} |
| 401 |
|
| 402 |
if (r_options != nullptr && ret.has("options")) { |
| 403 |
Array options = ret["options"]; |
| 404 |
for (const Variant &var : options) { |
| 405 |
Dictionary op = var; |
| 406 |
CodeCompletionOption option; |
| 407 |
ERR_CONTINUE(!op.has("kind")); |
| 408 |
option.kind = CodeCompletionKind(int(op["kind"])); |
| 409 |
ERR_CONTINUE(!op.has("display")); |
| 410 |
option.display = op["display"]; |
| 411 |
ERR_CONTINUE(!op.has("insert_text")); |
| 412 |
option.insert_text = op["insert_text"]; |
| 413 |
ERR_CONTINUE(!op.has("font_color")); |
| 414 |
option.font_color = op["font_color"]; |
| 415 |
ERR_CONTINUE(!op.has("icon")); |
| 416 |
option.icon = op["icon"]; |
| 417 |
ERR_CONTINUE(!op.has("default_value")); |
| 418 |
option.default_value = op["default_value"]; |
| 419 |
ERR_CONTINUE(!op.has("location")); |
| 420 |
option.location = op["location"]; |
| 421 |
if (op.has("matches")) { |
| 422 |
PackedInt32Array matches = op["matches"]; |
| 423 |
ERR_CONTINUE(matches.size() & 1); |
| 424 |
for (int j = 0; j < matches.size(); j += 2) { |
| 425 |
option.matches.push_back(Pair<int, int>(matches[j], matches[j + 1])); |
| 426 |
} |
| 427 |
} |
| 428 |
option.matches_dirty = true; |
| 429 |
r_options->push_back(option); |
| 430 |
} |
| 431 |
} |
| 432 |
|
| 433 |
ERR_FAIL_COND_V(!ret.has("force"), ERR_UNAVAILABLE); |
| 434 |
r_force = ret["force"]; |
| 435 |
ERR_FAIL_COND_V(!ret.has("call_hint"), ERR_UNAVAILABLE); |
| 436 |
r_call_hint = ret["call_hint"]; |
| 437 |
ERR_FAIL_COND_V(!ret.has("result"), ERR_UNAVAILABLE); |
| 438 |
Error result = Error(int(ret["result"])); |
| 439 |
|
| 440 |
return result; |
| 441 |
} |
| 442 |
|
| 443 |
GDVIRTUAL4RC_REQUIRED(Dictionary, _lookup_code, const String &, const String &, const String &, Object *) |
| 444 |
|
| 445 |
virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) override { |
| 446 |
Dictionary ret; |
| 447 |
GDVIRTUAL_CALL(_lookup_code, p_code, p_symbol, p_path, p_owner, ret); |
| 448 |
|
| 449 |
ERR_FAIL_COND_V(!ret.has("result"), ERR_UNAVAILABLE); |
| 450 |
const Error result = Error(int(ret["result"])); |
| 451 |
|
| 452 |
ERR_FAIL_COND_V(!ret.has("type"), ERR_UNAVAILABLE); |
| 453 |
r_result.type = LookupResultType(int(ret["type"])); |
| 454 |
|
| 455 |
r_result.class_name = ret.get("class_name", ""); |
| 456 |
r_result.class_member = ret.get("class_member", ""); |
| 457 |
|
| 458 |
r_result.description = ret.get("description", ""); |
| 459 |
r_result.is_deprecated = ret.get("is_deprecated", false); |
| 460 |
r_result.deprecated_message = ret.get("deprecated_message", ""); |
| 461 |
r_result.is_experimental = ret.get("is_experimental", false); |
| 462 |
r_result.experimental_message = ret.get("experimental_message", ""); |
| 463 |
|
| 464 |
r_result.doc_type = ret.get("doc_type", ""); |
| 465 |
r_result.enumeration = ret.get("enumeration", ""); |
| 466 |
r_result.is_bitfield = ret.get("is_bitfield", false); |
| 467 |
|
| 468 |
r_result.value = ret.get("value", ""); |
| 469 |
|
| 470 |
r_result.script = ret.get("script", Ref<Script>()); |
| 471 |
r_result.script_path = ret.get("script_path", ""); |
| 472 |
r_result.location = ret.get("location", -1); |
| 473 |
|
| 474 |
return result; |
| 475 |
} |
| 476 |
|
| 477 |
GDVIRTUAL3RC_REQUIRED(String, _auto_indent_code, const String &, int, int) |
| 478 |
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const override { |
| 479 |
String ret; |
| 480 |
GDVIRTUAL_CALL(_auto_indent_code, p_code, p_from_line, p_to_line, ret); |
| 481 |
p_code = ret; |
| 482 |
} |
| 483 |
EXBIND2(add_global_constant, const StringName &, const Variant &) |
| 484 |
EXBIND2(add_named_global_constant, const StringName &, const Variant &) |
| 485 |
EXBIND1(remove_named_global_constant, const StringName &) |
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
EXBIND0(thread_enter) |
| 491 |
EXBIND0(thread_exit) |
| 492 |
|
| 493 |
EXBIND0RC(String, debug_get_error) |
| 494 |
EXBIND0RC(int, debug_get_stack_level_count) |
| 495 |
EXBIND1RC(int, debug_get_stack_level_line, int) |
| 496 |
EXBIND1RC(String, debug_get_stack_level_function, int) |
| 497 |
EXBIND1RC(String, debug_get_stack_level_source, int) |
| 498 |
|
| 499 |
GDVIRTUAL3R_REQUIRED(Dictionary, _debug_get_stack_level_locals, int, int, int) |
| 500 |
virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override { |
| 501 |
Dictionary ret; |
| 502 |
GDVIRTUAL_CALL(_debug_get_stack_level_locals, p_level, p_max_subitems, p_max_depth, ret); |
| 503 |
if (ret.is_empty()) { |
| 504 |
return; |
| 505 |
} |
| 506 |
if (p_locals != nullptr && ret.has("locals")) { |
| 507 |
PackedStringArray strings = ret["locals"]; |
| 508 |
for (int i = 0; i < strings.size(); i++) { |
| 509 |
p_locals->push_back(strings[i]); |
| 510 |
} |
| 511 |
} |
| 512 |
if (p_values != nullptr && ret.has("values")) { |
| 513 |
Array values = ret["values"]; |
| 514 |
for (const Variant &value : values) { |
| 515 |
p_values->push_back(value); |
| 516 |
} |
| 517 |
} |
| 518 |
} |
| 519 |
GDVIRTUAL3R_REQUIRED(Dictionary, _debug_get_stack_level_members, int, int, int) |
| 520 |
virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override { |
| 521 |
Dictionary ret; |
| 522 |
GDVIRTUAL_CALL(_debug_get_stack_level_members, p_level, p_max_subitems, p_max_depth, ret); |
| 523 |
if (ret.is_empty()) { |
| 524 |
return; |
| 525 |
} |
| 526 |
if (p_members != nullptr && ret.has("members")) { |
| 527 |
PackedStringArray strings = ret["members"]; |
| 528 |
for (int i = 0; i < strings.size(); i++) { |
| 529 |
p_members->push_back(strings[i]); |
| 530 |
} |
| 531 |
} |
| 532 |
if (p_values != nullptr && ret.has("values")) { |
| 533 |
Array values = ret["values"]; |
| 534 |
for (const Variant &value : values) { |
| 535 |
p_values->push_back(value); |
| 536 |
} |
| 537 |
} |
| 538 |
} |
| 539 |
GDVIRTUAL1R_REQUIRED(GDExtensionPtr<void>, _debug_get_stack_level_instance, int) |
| 540 |
|
| 541 |
virtual ScriptInstance *debug_get_stack_level_instance(int p_level) override { |
| 542 |
GDExtensionPtr<void> ret = nullptr; |
| 543 |
GDVIRTUAL_CALL(_debug_get_stack_level_instance, p_level, ret); |
| 544 |
return reinterpret_cast<ScriptInstance *>(ret.operator void *()); |
| 545 |
} |
| 546 |
GDVIRTUAL2R_REQUIRED(Dictionary, _debug_get_globals, int, int) |
| 547 |
virtual void debug_get_globals(List<String> *p_globals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override { |
| 548 |
Dictionary ret; |
| 549 |
GDVIRTUAL_CALL(_debug_get_globals, p_max_subitems, p_max_depth, ret); |
| 550 |
if (ret.is_empty()) { |
| 551 |
return; |
| 552 |
} |
| 553 |
if (p_globals != nullptr && ret.has("globals")) { |
| 554 |
PackedStringArray strings = ret["globals"]; |
| 555 |
for (int i = 0; i < strings.size(); i++) { |
| 556 |
p_globals->push_back(strings[i]); |
| 557 |
} |
| 558 |
} |
| 559 |
if (p_values != nullptr && ret.has("values")) { |
| 560 |
Array values = ret["values"]; |
| 561 |
for (const Variant &value : values) { |
| 562 |
p_values->push_back(value); |
| 563 |
} |
| 564 |
} |
| 565 |
} |
| 566 |
|
| 567 |
EXBIND4R(String, debug_parse_stack_level_expression, int, const String &, int, int) |
| 568 |
|
| 569 |
GDVIRTUAL0R_REQUIRED(TypedArray<Dictionary>, _debug_get_current_stack_info) |
| 570 |
virtual Vector<StackInfo> debug_get_current_stack_info() override { |
| 571 |
TypedArray<Dictionary> ret; |
| 572 |
GDVIRTUAL_CALL(_debug_get_current_stack_info, ret); |
| 573 |
Vector<StackInfo> sret; |
| 574 |
for (const Variant &var : ret) { |
| 575 |
StackInfo si; |
| 576 |
Dictionary d = var; |
| 577 |
ERR_CONTINUE(!d.has("file")); |
| 578 |
ERR_CONTINUE(!d.has("func")); |
| 579 |
ERR_CONTINUE(!d.has("line")); |
| 580 |
si.file = d["file"]; |
| 581 |
si.func = d["func"]; |
| 582 |
si.line = d["line"]; |
| 583 |
sret.push_back(si); |
| 584 |
} |
| 585 |
return sret; |
| 586 |
} |
| 587 |
|
| 588 |
EXBIND0(reload_all_scripts) |
| 589 |
EXBIND2(reload_scripts, const Array &, bool) |
| 590 |
EXBIND2(reload_tool_script, const Ref<Script> &, bool) |
| 591 |
|
| 592 |
|
| 593 |
GDVIRTUAL0RC_REQUIRED(PackedStringArray, _get_recognized_extensions) |
| 594 |
|
| 595 |
virtual void get_recognized_extensions(List<String> *p_extensions) const override { |
| 596 |
PackedStringArray ret; |
| 597 |
GDVIRTUAL_CALL(_get_recognized_extensions, ret); |
| 598 |
for (int i = 0; i < ret.size(); i++) { |
| 599 |
p_extensions->push_back(ret[i]); |
| 600 |
} |
| 601 |
} |
| 602 |
|
| 603 |
GDVIRTUAL0RC_REQUIRED(TypedArray<Dictionary>, _get_public_functions) |
| 604 |
virtual void get_public_functions(List<MethodInfo> *p_functions) const override { |
| 605 |
TypedArray<Dictionary> ret; |
| 606 |
GDVIRTUAL_CALL(_get_public_functions, ret); |
| 607 |
for (const Variant &var : ret) { |
| 608 |
MethodInfo mi = MethodInfo::from_dict(var); |
| 609 |
p_functions->push_back(mi); |
| 610 |
} |
| 611 |
} |
| 612 |
GDVIRTUAL0RC_REQUIRED(Dictionary, _get_public_constants) |
| 613 |
virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const override { |
| 614 |
Dictionary ret; |
| 615 |
GDVIRTUAL_CALL(_get_public_constants, ret); |
| 616 |
for (int i = 0; i < ret.size(); i++) { |
| 617 |
Dictionary d = ret[i]; |
| 618 |
ERR_CONTINUE(!d.has("name")); |
| 619 |
ERR_CONTINUE(!d.has("value")); |
| 620 |
p_constants->push_back(Pair<String, Variant>(d["name"], d["value"])); |
| 621 |
} |
| 622 |
} |
| 623 |
GDVIRTUAL0RC_REQUIRED(TypedArray<Dictionary>, _get_public_annotations) |
| 624 |
virtual void get_public_annotations(List<MethodInfo> *p_annotations) const override { |
| 625 |
TypedArray<Dictionary> ret; |
| 626 |
GDVIRTUAL_CALL(_get_public_annotations, ret); |
| 627 |
for (const Variant &var : ret) { |
| 628 |
MethodInfo mi = MethodInfo::from_dict(var); |
| 629 |
p_annotations->push_back(mi); |
| 630 |
} |
| 631 |
} |
| 632 |
|
| 633 |
EXBIND0(profiling_start) |
| 634 |
EXBIND0(profiling_stop) |
| 635 |
EXBIND1(profiling_set_save_native_calls, bool) |
| 636 |
|
| 637 |
GDVIRTUAL2R_REQUIRED(int, _profiling_get_accumulated_data, GDExtensionPtr<ScriptLanguageExtensionProfilingInfo>, int) |
| 638 |
|
| 639 |
virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) override { |
| 640 |
int ret = 0; |
| 641 |
GDVIRTUAL_CALL(_profiling_get_accumulated_data, p_info_arr, p_info_max, ret); |
| 642 |
return ret; |
| 643 |
} |
| 644 |
|
| 645 |
GDVIRTUAL2R_REQUIRED(int, _profiling_get_frame_data, GDExtensionPtr<ScriptLanguageExtensionProfilingInfo>, int) |
| 646 |
|
| 647 |
virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) override { |
| 648 |
int ret = 0; |
| 649 |
GDVIRTUAL_CALL(_profiling_get_frame_data, p_info_arr, p_info_max, ret); |
| 650 |
return ret; |
| 651 |
} |
| 652 |
|
| 653 |
EXBIND0(frame) |
| 654 |
|
| 655 |
EXBIND1RC(bool, handles_global_class_type, const String &) |
| 656 |
|
| 657 |
GDVIRTUAL1RC_REQUIRED(Dictionary, _get_global_class_name, const String &) |
| 658 |
|
| 659 |
virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr, bool *r_is_abstract = nullptr, bool *r_is_tool = nullptr) const override { |
| 660 |
Dictionary ret; |
| 661 |
GDVIRTUAL_CALL(_get_global_class_name, p_path, ret); |
| 662 |
if (!ret.has("name")) { |
| 663 |
return String(); |
| 664 |
} |
| 665 |
if (r_base_type != nullptr && ret.has("base_type")) { |
| 666 |
*r_base_type = ret["base_type"]; |
| 667 |
} |
| 668 |
if (r_icon_path != nullptr && ret.has("icon_path")) { |
| 669 |
*r_icon_path = ret["icon_path"]; |
| 670 |
} |
| 671 |
if (r_is_abstract != nullptr && ret.has("is_abstract")) { |
| 672 |
*r_is_abstract = ret["is_abstract"]; |
| 673 |
} |
| 674 |
if (r_is_tool != nullptr && ret.has("is_tool")) { |
| 675 |
*r_is_tool = ret["is_tool"]; |
| 676 |
} |
| 677 |
return ret["name"]; |
| 678 |
} |
| 679 |
}; |
| 680 |
|
| 681 |
VARIANT_ENUM_CAST(ScriptLanguageExtension::LookupResultType) |
| 682 |
VARIANT_ENUM_CAST(ScriptLanguageExtension::CodeCompletionKind) |
| 683 |
VARIANT_ENUM_CAST(ScriptLanguageExtension::CodeCompletionLocation) |
| 684 |
|
| 685 |
class ScriptInstanceExtension : public ScriptInstance { |
| 686 |
public: |
| 687 |
const GDExtensionScriptInstanceInfo3 *native_info; |
| 688 |
|
| 689 |
#ifndef DISABLE_DEPRECATED |
| 690 |
bool free_native_info = false; |
| 691 |
struct DeprecatedNativeInfo { |
| 692 |
GDExtensionScriptInstanceNotification notification_func = nullptr; |
| 693 |
GDExtensionScriptInstanceFreePropertyList free_property_list_func = nullptr; |
| 694 |
GDExtensionScriptInstanceFreeMethodList free_method_list_func = nullptr; |
| 695 |
}; |
| 696 |
DeprecatedNativeInfo *deprecated_native_info = nullptr; |
| 697 |
#endif |
| 698 |
|
| 699 |
GDExtensionScriptInstanceDataPtr instance = nullptr; |
| 700 |
|
| 701 |
GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wignored-qualifiers") |
| 702 |
|
| 703 |
virtual bool set(const StringName &p_name, const Variant &p_value) override { |
| 704 |
if (native_info->set_func) { |
| 705 |
return native_info->set_func(instance, (GDExtensionConstStringNamePtr)&p_name, (GDExtensionConstVariantPtr)&p_value); |
| 706 |
} |
| 707 |
return false; |
| 708 |
} |
| 709 |
virtual bool get(const StringName &p_name, Variant &r_ret) const override { |
| 710 |
if (native_info->get_func) { |
| 711 |
return native_info->get_func(instance, (GDExtensionConstStringNamePtr)&p_name, (GDExtensionVariantPtr)&r_ret); |
| 712 |
} |
| 713 |
return false; |
| 714 |
} |
| 715 |
virtual void get_property_list(List<PropertyInfo> *p_list) const override { |
| 716 |
if (native_info->get_property_list_func) { |
| 717 |
uint32_t pcount; |
| 718 |
const GDExtensionPropertyInfo *pinfo = native_info->get_property_list_func(instance, &pcount); |
| 719 |
|
| 720 |
#ifdef TOOLS_ENABLED |
| 721 |
if (pcount > 0) { |
| 722 |
if (native_info->get_class_category_func) { |
| 723 |
GDExtensionPropertyInfo gdext_class_category; |
| 724 |
if (native_info->get_class_category_func(instance, &gdext_class_category)) { |
| 725 |
p_list->push_back(PropertyInfo(gdext_class_category)); |
| 726 |
} |
| 727 |
} else { |
| 728 |
Ref<Script> script = get_script(); |
| 729 |
if (script.is_valid()) { |
| 730 |
p_list->push_back(script->get_class_category()); |
| 731 |
} |
| 732 |
} |
| 733 |
} |
| 734 |
#endif |
| 735 |
|
| 736 |
for (uint32_t i = 0; i < pcount; i++) { |
| 737 |
p_list->push_back(PropertyInfo(pinfo[i])); |
| 738 |
} |
| 739 |
if (native_info->free_property_list_func) { |
| 740 |
native_info->free_property_list_func(instance, pinfo, pcount); |
| 741 |
#ifndef DISABLE_DEPRECATED |
| 742 |
} else if (deprecated_native_info && deprecated_native_info->free_property_list_func) { |
| 743 |
deprecated_native_info->free_property_list_func(instance, pinfo); |
| 744 |
#endif |
| 745 |
} |
| 746 |
} |
| 747 |
} |
| 748 |
virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const override { |
| 749 |
if (native_info->get_property_type_func) { |
| 750 |
GDExtensionBool is_valid = 0; |
| 751 |
GDExtensionVariantType type = native_info->get_property_type_func(instance, (GDExtensionConstStringNamePtr)&p_name, &is_valid); |
| 752 |
if (r_is_valid) { |
| 753 |
*r_is_valid = is_valid != 0; |
| 754 |
} |
| 755 |
return Variant::Type(type); |
| 756 |
} |
| 757 |
return Variant::NIL; |
| 758 |
} |
| 759 |
virtual void validate_property(PropertyInfo &p_property) const override { |
| 760 |
if (native_info->validate_property_func) { |
| 761 |
|
| 762 |
StringName prop_name = p_property.name; |
| 763 |
GDExtensionPropertyInfo gdext_prop = { |
| 764 |
(GDExtensionVariantType)p_property.type, |
| 765 |
&prop_name, |
| 766 |
&p_property.class_name, |
| 767 |
(uint32_t)p_property.hint, |
| 768 |
&p_property.hint_string, |
| 769 |
p_property.usage, |
| 770 |
}; |
| 771 |
if (native_info->validate_property_func(instance, &gdext_prop)) { |
| 772 |
p_property.type = (Variant::Type)gdext_prop.type; |
| 773 |
p_property.name = *reinterpret_cast<StringName *>(gdext_prop.name); |
| 774 |
p_property.class_name = *reinterpret_cast<StringName *>(gdext_prop.class_name); |
| 775 |
p_property.hint = (PropertyHint)gdext_prop.hint; |
| 776 |
p_property.hint_string = *reinterpret_cast<String *>(gdext_prop.hint_string); |
| 777 |
p_property.usage = gdext_prop.usage; |
| 778 |
} |
| 779 |
} |
| 780 |
} |
| 781 |
|
| 782 |
virtual bool property_can_revert(const StringName &p_name) const override { |
| 783 |
if (native_info->property_can_revert_func) { |
| 784 |
return native_info->property_can_revert_func(instance, (GDExtensionConstStringNamePtr)&p_name); |
| 785 |
} |
| 786 |
return false; |
| 787 |
} |
| 788 |
virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const override { |
| 789 |
if (native_info->property_get_revert_func) { |
| 790 |
return native_info->property_get_revert_func(instance, (GDExtensionConstStringNamePtr)&p_name, (GDExtensionVariantPtr)&r_ret); |
| 791 |
} |
| 792 |
return false; |
| 793 |
} |
| 794 |
|
| 795 |
virtual Object *get_owner() override { |
| 796 |
if (native_info->get_owner_func) { |
| 797 |
return (Object *)native_info->get_owner_func(instance); |
| 798 |
} |
| 799 |
return nullptr; |
| 800 |
} |
| 801 |
static void _add_property_with_state(GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value, void *p_userdata) { |
| 802 |
List<Pair<StringName, Variant>> *state = (List<Pair<StringName, Variant>> *)p_userdata; |
| 803 |
state->push_back(Pair<StringName, Variant>(*(const StringName *)p_name, *(const Variant *)p_value)); |
| 804 |
} |
| 805 |
virtual void get_property_state(List<Pair<StringName, Variant>> &state) override { |
| 806 |
if (native_info->get_property_state_func) { |
| 807 |
native_info->get_property_state_func(instance, _add_property_with_state, &state); |
| 808 |
return; |
| 809 |
} |
| 810 |
ScriptInstance::get_property_state(state); |
| 811 |
} |
| 812 |
|
| 813 |
virtual void get_method_list(List<MethodInfo> *p_list) const override { |
| 814 |
if (native_info->get_method_list_func) { |
| 815 |
uint32_t mcount; |
| 816 |
const GDExtensionMethodInfo *minfo = native_info->get_method_list_func(instance, &mcount); |
| 817 |
for (uint32_t i = 0; i < mcount; i++) { |
| 818 |
p_list->push_back(MethodInfo(minfo[i])); |
| 819 |
} |
| 820 |
if (native_info->free_method_list_func) { |
| 821 |
native_info->free_method_list_func(instance, minfo, mcount); |
| 822 |
#ifndef DISABLE_DEPRECATED |
| 823 |
} else if (deprecated_native_info && deprecated_native_info->free_method_list_func) { |
| 824 |
deprecated_native_info->free_method_list_func(instance, minfo); |
| 825 |
#endif |
| 826 |
} |
| 827 |
} |
| 828 |
} |
| 829 |
virtual bool has_method(const StringName &p_method) const override { |
| 830 |
if (native_info->has_method_func) { |
| 831 |
return native_info->has_method_func(instance, (GDExtensionStringNamePtr)&p_method); |
| 832 |
} |
| 833 |
return false; |
| 834 |
} |
| 835 |
|
| 836 |
virtual int get_method_argument_count(const StringName &p_method, bool *r_is_valid = nullptr) const override { |
| 837 |
if (native_info->get_method_argument_count_func) { |
| 838 |
GDExtensionBool is_valid = 0; |
| 839 |
GDExtensionInt ret = native_info->get_method_argument_count_func(instance, (GDExtensionStringNamePtr)&p_method, &is_valid); |
| 840 |
if (r_is_valid) { |
| 841 |
*r_is_valid = is_valid != 0; |
| 842 |
} |
| 843 |
return ret; |
| 844 |
} |
| 845 |
|
| 846 |
return ScriptInstance::get_method_argument_count(p_method, r_is_valid); |
| 847 |
} |
| 848 |
|
| 849 |
virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override { |
| 850 |
Variant ret; |
| 851 |
if (native_info->call_func) { |
| 852 |
GDExtensionCallError ce; |
| 853 |
native_info->call_func(instance, (GDExtensionConstStringNamePtr)&p_method, (GDExtensionConstVariantPtr *)p_args, p_argcount, (GDExtensionVariantPtr)&ret, &ce); |
| 854 |
r_error.error = Callable::CallError::Error(ce.error); |
| 855 |
r_error.argument = ce.argument; |
| 856 |
r_error.expected = ce.expected; |
| 857 |
} |
| 858 |
return ret; |
| 859 |
} |
| 860 |
|
| 861 |
virtual void notification(int p_notification, bool p_reversed = false) override { |
| 862 |
if (native_info->notification_func) { |
| 863 |
native_info->notification_func(instance, p_notification, p_reversed); |
| 864 |
#ifndef DISABLE_DEPRECATED |
| 865 |
} else if (deprecated_native_info && deprecated_native_info->notification_func) { |
| 866 |
deprecated_native_info->notification_func(instance, p_notification); |
| 867 |
#endif |
| 868 |
} |
| 869 |
} |
| 870 |
|
| 871 |
virtual String to_string(bool *r_valid) override { |
| 872 |
if (native_info->to_string_func) { |
| 873 |
GDExtensionBool valid; |
| 874 |
String ret; |
| 875 |
native_info->to_string_func(instance, &valid, reinterpret_cast<GDExtensionStringPtr>(&ret)); |
| 876 |
if (r_valid) { |
| 877 |
*r_valid = valid != 0; |
| 878 |
} |
| 879 |
return ret; |
| 880 |
} |
| 881 |
return String(); |
| 882 |
} |
| 883 |
|
| 884 |
virtual void refcount_incremented() override { |
| 885 |
if (native_info->refcount_incremented_func) { |
| 886 |
native_info->refcount_incremented_func(instance); |
| 887 |
} |
| 888 |
} |
| 889 |
virtual bool refcount_decremented() override { |
| 890 |
if (native_info->refcount_decremented_func) { |
| 891 |
return native_info->refcount_decremented_func(instance); |
| 892 |
} |
| 893 |
return false; |
| 894 |
} |
| 895 |
|
| 896 |
virtual Ref<Script> get_script() const override { |
| 897 |
if (native_info->get_script_func) { |
| 898 |
GDExtensionObjectPtr script = native_info->get_script_func(instance); |
| 899 |
return Ref<Script>(reinterpret_cast<Script *>(script)); |
| 900 |
} |
| 901 |
return Ref<Script>(); |
| 902 |
} |
| 903 |
|
| 904 |
virtual bool is_placeholder() const override { |
| 905 |
if (native_info->is_placeholder_func) { |
| 906 |
return native_info->is_placeholder_func(instance); |
| 907 |
} |
| 908 |
return false; |
| 909 |
} |
| 910 |
|
| 911 |
virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid) override { |
| 912 |
if (native_info->set_fallback_func) { |
| 913 |
bool ret = native_info->set_fallback_func(instance, (GDExtensionConstStringNamePtr)&p_name, (GDExtensionConstVariantPtr)&p_value); |
| 914 |
if (r_valid) { |
| 915 |
*r_valid = ret; |
| 916 |
} |
| 917 |
} |
| 918 |
} |
| 919 |
virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid) override { |
| 920 |
Variant ret; |
| 921 |
if (native_info->get_fallback_func) { |
| 922 |
bool valid = native_info->get_fallback_func(instance, (GDExtensionConstStringNamePtr)&p_name, (GDExtensionVariantPtr)&ret); |
| 923 |
if (r_valid) { |
| 924 |
*r_valid = valid; |
| 925 |
} |
| 926 |
} |
| 927 |
return ret; |
| 928 |
} |
| 929 |
|
| 930 |
virtual ScriptLanguage *get_language() override { |
| 931 |
if (native_info->get_language_func) { |
| 932 |
GDExtensionScriptLanguagePtr lang = native_info->get_language_func(instance); |
| 933 |
return reinterpret_cast<ScriptLanguage *>(lang); |
| 934 |
} |
| 935 |
return nullptr; |
| 936 |
} |
| 937 |
virtual ~ScriptInstanceExtension() { |
| 938 |
if (native_info->free_func) { |
| 939 |
native_info->free_func(instance); |
| 940 |
} |
| 941 |
#ifndef DISABLE_DEPRECATED |
| 942 |
if (free_native_info) { |
| 943 |
memfree(const_cast<GDExtensionScriptInstanceInfo3 *>(native_info)); |
| 944 |
} |
| 945 |
if (deprecated_native_info) { |
| 946 |
memfree(deprecated_native_info); |
| 947 |
} |
| 948 |
#endif |
| 949 |
} |
| 950 |
|
| 951 |
GODOT_GCC_WARNING_POP |
| 952 |
}; |