script_language.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /**************************************************************************/
  2. /* script_language.cpp */
  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. #include "script_language.h"
  31. #include "core/config/project_settings.h"
  32. #include "core/core_string_names.h"
  33. #include "core/debugger/engine_debugger.h"
  34. #include "core/debugger/script_debugger.h"
  35. #include "core/variant/typed_array.h"
  36. #include <stdint.h>
  37. ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES];
  38. int ScriptServer::_language_count = 0;
  39. bool ScriptServer::scripting_enabled = true;
  40. bool ScriptServer::reload_scripts_on_save = false;
  41. bool ScriptServer::languages_finished = false;
  42. ScriptEditRequestFunction ScriptServer::edit_request_func = nullptr;
  43. void Script::_notification(int p_what) {
  44. switch (p_what) {
  45. case NOTIFICATION_POSTINITIALIZE: {
  46. if (EngineDebugger::is_active()) {
  47. EngineDebugger::get_script_debugger()->set_break_language(get_language());
  48. }
  49. } break;
  50. }
  51. }
  52. Variant Script::_get_property_default_value(const StringName &p_property) {
  53. Variant ret;
  54. get_property_default_value(p_property, ret);
  55. return ret;
  56. }
  57. TypedArray<Dictionary> Script::_get_script_property_list() {
  58. TypedArray<Dictionary> ret;
  59. List<PropertyInfo> list;
  60. get_script_property_list(&list);
  61. for (const PropertyInfo &E : list) {
  62. ret.append(E.operator Dictionary());
  63. }
  64. return ret;
  65. }
  66. TypedArray<Dictionary> Script::_get_script_method_list() {
  67. TypedArray<Dictionary> ret;
  68. List<MethodInfo> list;
  69. get_script_method_list(&list);
  70. for (const MethodInfo &E : list) {
  71. ret.append(E.operator Dictionary());
  72. }
  73. return ret;
  74. }
  75. TypedArray<Dictionary> Script::_get_script_signal_list() {
  76. TypedArray<Dictionary> ret;
  77. List<MethodInfo> list;
  78. get_script_signal_list(&list);
  79. for (const MethodInfo &E : list) {
  80. ret.append(E.operator Dictionary());
  81. }
  82. return ret;
  83. }
  84. Dictionary Script::_get_script_constant_map() {
  85. Dictionary ret;
  86. HashMap<StringName, Variant> map;
  87. get_constants(&map);
  88. for (const KeyValue<StringName, Variant> &E : map) {
  89. ret[E.key] = E.value;
  90. }
  91. return ret;
  92. }
  93. #ifdef TOOLS_ENABLED
  94. PropertyInfo Script::get_class_category() const {
  95. String path = get_path();
  96. String scr_name;
  97. if (is_built_in()) {
  98. if (get_name().is_empty()) {
  99. scr_name = TTR("Built-in script");
  100. } else {
  101. scr_name = vformat("%s (%s)", get_name(), TTR("Built-in"));
  102. }
  103. } else {
  104. if (get_name().is_empty()) {
  105. scr_name = path.get_file();
  106. } else {
  107. scr_name = get_name();
  108. }
  109. }
  110. return PropertyInfo(Variant::NIL, scr_name, PROPERTY_HINT_NONE, path, PROPERTY_USAGE_CATEGORY);
  111. }
  112. #endif // TOOLS_ENABLED
  113. void Script::_bind_methods() {
  114. ClassDB::bind_method(D_METHOD("can_instantiate"), &Script::can_instantiate);
  115. //ClassDB::bind_method(D_METHOD("instance_create","base_object"),&Script::instance_create);
  116. ClassDB::bind_method(D_METHOD("instance_has", "base_object"), &Script::instance_has);
  117. ClassDB::bind_method(D_METHOD("has_source_code"), &Script::has_source_code);
  118. ClassDB::bind_method(D_METHOD("get_source_code"), &Script::get_source_code);
  119. ClassDB::bind_method(D_METHOD("set_source_code", "source"), &Script::set_source_code);
  120. ClassDB::bind_method(D_METHOD("reload", "keep_state"), &Script::reload, DEFVAL(false));
  121. ClassDB::bind_method(D_METHOD("get_base_script"), &Script::get_base_script);
  122. ClassDB::bind_method(D_METHOD("get_instance_base_type"), &Script::get_instance_base_type);
  123. ClassDB::bind_method(D_METHOD("has_script_signal", "signal_name"), &Script::has_script_signal);
  124. ClassDB::bind_method(D_METHOD("get_script_property_list"), &Script::_get_script_property_list);
  125. ClassDB::bind_method(D_METHOD("get_script_method_list"), &Script::_get_script_method_list);
  126. ClassDB::bind_method(D_METHOD("get_script_signal_list"), &Script::_get_script_signal_list);
  127. ClassDB::bind_method(D_METHOD("get_script_constant_map"), &Script::_get_script_constant_map);
  128. ClassDB::bind_method(D_METHOD("get_property_default_value", "property"), &Script::_get_property_default_value);
  129. ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool);
  130. ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_code", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_source_code", "get_source_code");
  131. }
  132. void ScriptServer::set_scripting_enabled(bool p_enabled) {
  133. scripting_enabled = p_enabled;
  134. }
  135. bool ScriptServer::is_scripting_enabled() {
  136. return scripting_enabled;
  137. }
  138. ScriptLanguage *ScriptServer::get_language(int p_idx) {
  139. ERR_FAIL_INDEX_V(p_idx, _language_count, nullptr);
  140. return _languages[p_idx];
  141. }
  142. void ScriptServer::register_language(ScriptLanguage *p_language) {
  143. ERR_FAIL_NULL(p_language);
  144. ERR_FAIL_COND(_language_count >= MAX_LANGUAGES);
  145. _languages[_language_count++] = p_language;
  146. }
  147. void ScriptServer::unregister_language(const ScriptLanguage *p_language) {
  148. for (int i = 0; i < _language_count; i++) {
  149. if (_languages[i] == p_language) {
  150. _language_count--;
  151. if (i < _language_count) {
  152. SWAP(_languages[i], _languages[_language_count]);
  153. }
  154. return;
  155. }
  156. }
  157. }
  158. void ScriptServer::init_languages() {
  159. { // Load global classes.
  160. global_classes_clear();
  161. #ifndef DISABLE_DEPRECATED
  162. if (ProjectSettings::get_singleton()->has_setting("_global_script_classes")) {
  163. Array script_classes = GLOBAL_GET("_global_script_classes");
  164. for (int i = 0; i < script_classes.size(); i++) {
  165. Dictionary c = script_classes[i];
  166. if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base")) {
  167. continue;
  168. }
  169. add_global_class(c["class"], c["base"], c["language"], c["path"]);
  170. }
  171. ProjectSettings::get_singleton()->clear("_global_script_classes");
  172. }
  173. #endif
  174. Array script_classes = ProjectSettings::get_singleton()->get_global_class_list();
  175. for (int i = 0; i < script_classes.size(); i++) {
  176. Dictionary c = script_classes[i];
  177. if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base")) {
  178. continue;
  179. }
  180. add_global_class(c["class"], c["base"], c["language"], c["path"]);
  181. }
  182. }
  183. for (int i = 0; i < _language_count; i++) {
  184. _languages[i]->init();
  185. }
  186. }
  187. void ScriptServer::finish_languages() {
  188. for (int i = 0; i < _language_count; i++) {
  189. _languages[i]->finish();
  190. }
  191. global_classes_clear();
  192. languages_finished = true;
  193. }
  194. void ScriptServer::set_reload_scripts_on_save(bool p_enable) {
  195. reload_scripts_on_save = p_enable;
  196. }
  197. bool ScriptServer::is_reload_scripts_on_save_enabled() {
  198. return reload_scripts_on_save;
  199. }
  200. void ScriptServer::thread_enter() {
  201. for (int i = 0; i < _language_count; i++) {
  202. _languages[i]->thread_enter();
  203. }
  204. }
  205. void ScriptServer::thread_exit() {
  206. for (int i = 0; i < _language_count; i++) {
  207. _languages[i]->thread_exit();
  208. }
  209. }
  210. HashMap<StringName, ScriptServer::GlobalScriptClass> ScriptServer::global_classes;
  211. void ScriptServer::global_classes_clear() {
  212. global_classes.clear();
  213. }
  214. void ScriptServer::add_global_class(const StringName &p_class, const StringName &p_base, const StringName &p_language, const String &p_path) {
  215. ERR_FAIL_COND_MSG(p_class == p_base || (global_classes.has(p_base) && get_global_class_native_base(p_base) == p_class), "Cyclic inheritance in script class.");
  216. GlobalScriptClass g;
  217. g.language = p_language;
  218. g.path = p_path;
  219. g.base = p_base;
  220. global_classes[p_class] = g;
  221. }
  222. void ScriptServer::remove_global_class(const StringName &p_class) {
  223. global_classes.erase(p_class);
  224. }
  225. void ScriptServer::remove_global_class_by_path(const String &p_path) {
  226. for (const KeyValue<StringName, GlobalScriptClass> &kv : global_classes) {
  227. if (kv.value.path == p_path) {
  228. global_classes.erase(kv.key);
  229. return;
  230. }
  231. }
  232. }
  233. bool ScriptServer::is_global_class(const StringName &p_class) {
  234. return global_classes.has(p_class);
  235. }
  236. StringName ScriptServer::get_global_class_language(const StringName &p_class) {
  237. ERR_FAIL_COND_V(!global_classes.has(p_class), StringName());
  238. return global_classes[p_class].language;
  239. }
  240. String ScriptServer::get_global_class_path(const String &p_class) {
  241. ERR_FAIL_COND_V(!global_classes.has(p_class), String());
  242. return global_classes[p_class].path;
  243. }
  244. StringName ScriptServer::get_global_class_base(const String &p_class) {
  245. ERR_FAIL_COND_V(!global_classes.has(p_class), String());
  246. return global_classes[p_class].base;
  247. }
  248. StringName ScriptServer::get_global_class_native_base(const String &p_class) {
  249. ERR_FAIL_COND_V(!global_classes.has(p_class), String());
  250. String base = global_classes[p_class].base;
  251. while (global_classes.has(base)) {
  252. base = global_classes[base].base;
  253. }
  254. return base;
  255. }
  256. void ScriptServer::get_global_class_list(List<StringName> *r_global_classes) {
  257. List<StringName> classes;
  258. for (const KeyValue<StringName, GlobalScriptClass> &E : global_classes) {
  259. classes.push_back(E.key);
  260. }
  261. classes.sort_custom<StringName::AlphCompare>();
  262. for (const StringName &E : classes) {
  263. r_global_classes->push_back(E);
  264. }
  265. }
  266. void ScriptServer::save_global_classes() {
  267. Dictionary class_icons;
  268. Array script_classes = ProjectSettings::get_singleton()->get_global_class_list();
  269. for (int i = 0; i < script_classes.size(); i++) {
  270. Dictionary d = script_classes[i];
  271. if (!d.has("name") || !d.has("icon")) {
  272. continue;
  273. }
  274. class_icons[d["name"]] = d["icon"];
  275. }
  276. List<StringName> gc;
  277. get_global_class_list(&gc);
  278. Array gcarr;
  279. for (const StringName &E : gc) {
  280. Dictionary d;
  281. d["class"] = E;
  282. d["language"] = global_classes[E].language;
  283. d["path"] = global_classes[E].path;
  284. d["base"] = global_classes[E].base;
  285. d["icon"] = class_icons.get(E, "");
  286. gcarr.push_back(d);
  287. }
  288. ProjectSettings::get_singleton()->store_global_class_list(gcarr);
  289. }
  290. ////////////////////
  291. Variant ScriptInstance::call_const(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
  292. return callp(p_method, p_args, p_argcount, r_error);
  293. }
  294. void ScriptInstance::get_property_state(List<Pair<StringName, Variant>> &state) {
  295. List<PropertyInfo> pinfo;
  296. get_property_list(&pinfo);
  297. for (const PropertyInfo &E : pinfo) {
  298. if (E.usage & PROPERTY_USAGE_STORAGE) {
  299. Pair<StringName, Variant> p;
  300. p.first = E.name;
  301. if (get(p.first, p.second)) {
  302. state.push_back(p);
  303. }
  304. }
  305. }
  306. }
  307. void ScriptInstance::property_set_fallback(const StringName &, const Variant &, bool *r_valid) {
  308. if (r_valid) {
  309. *r_valid = false;
  310. }
  311. }
  312. Variant ScriptInstance::property_get_fallback(const StringName &, bool *r_valid) {
  313. if (r_valid) {
  314. *r_valid = false;
  315. }
  316. return Variant();
  317. }
  318. ScriptInstance::~ScriptInstance() {
  319. }
  320. ScriptCodeCompletionCache *ScriptCodeCompletionCache::singleton = nullptr;
  321. ScriptCodeCompletionCache::ScriptCodeCompletionCache() {
  322. singleton = this;
  323. }
  324. void ScriptLanguage::get_core_type_words(List<String> *p_core_type_words) const {
  325. p_core_type_words->push_back("String");
  326. p_core_type_words->push_back("Vector2");
  327. p_core_type_words->push_back("Vector2i");
  328. p_core_type_words->push_back("Rect2");
  329. p_core_type_words->push_back("Rect2i");
  330. p_core_type_words->push_back("Vector3");
  331. p_core_type_words->push_back("Vector3i");
  332. p_core_type_words->push_back("Transform2D");
  333. p_core_type_words->push_back("Vector4");
  334. p_core_type_words->push_back("Vector4i");
  335. p_core_type_words->push_back("Plane");
  336. p_core_type_words->push_back("Quaternion");
  337. p_core_type_words->push_back("AABB");
  338. p_core_type_words->push_back("Basis");
  339. p_core_type_words->push_back("Transform3D");
  340. p_core_type_words->push_back("Projection");
  341. p_core_type_words->push_back("Color");
  342. p_core_type_words->push_back("StringName");
  343. p_core_type_words->push_back("NodePath");
  344. p_core_type_words->push_back("RID");
  345. p_core_type_words->push_back("Callable");
  346. p_core_type_words->push_back("Signal");
  347. p_core_type_words->push_back("Dictionary");
  348. p_core_type_words->push_back("Array");
  349. p_core_type_words->push_back("PackedByteArray");
  350. p_core_type_words->push_back("PackedInt32Array");
  351. p_core_type_words->push_back("PackedInt64Array");
  352. p_core_type_words->push_back("PackedFloat32Array");
  353. p_core_type_words->push_back("PackedFloat64Array");
  354. p_core_type_words->push_back("PackedStringArray");
  355. p_core_type_words->push_back("PackedVector2Array");
  356. p_core_type_words->push_back("PackedVector3Array");
  357. p_core_type_words->push_back("PackedColorArray");
  358. }
  359. void ScriptLanguage::frame() {
  360. }
  361. bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) {
  362. if (script->is_placeholder_fallback_enabled()) {
  363. return false;
  364. }
  365. if (values.has(p_name)) {
  366. Variant defval;
  367. if (script->get_property_default_value(p_name, defval)) {
  368. // The evaluate function ensures that a NIL variant is equal to e.g. an empty Resource.
  369. // Simply doing defval == p_value does not do this.
  370. if (Variant::evaluate(Variant::OP_EQUAL, defval, p_value)) {
  371. values.erase(p_name);
  372. return true;
  373. }
  374. }
  375. values[p_name] = p_value;
  376. return true;
  377. } else {
  378. Variant defval;
  379. if (script->get_property_default_value(p_name, defval)) {
  380. if (Variant::evaluate(Variant::OP_NOT_EQUAL, defval, p_value)) {
  381. values[p_name] = p_value;
  382. }
  383. return true;
  384. }
  385. }
  386. return false;
  387. }
  388. bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
  389. if (values.has(p_name)) {
  390. r_ret = values[p_name];
  391. return true;
  392. }
  393. if (constants.has(p_name)) {
  394. r_ret = constants[p_name];
  395. return true;
  396. }
  397. if (!script->is_placeholder_fallback_enabled()) {
  398. Variant defval;
  399. if (script->get_property_default_value(p_name, defval)) {
  400. r_ret = defval;
  401. return true;
  402. }
  403. }
  404. return false;
  405. }
  406. void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
  407. if (script->is_placeholder_fallback_enabled()) {
  408. for (const PropertyInfo &E : properties) {
  409. p_properties->push_back(E);
  410. }
  411. } else {
  412. for (const PropertyInfo &E : properties) {
  413. PropertyInfo pinfo = E;
  414. if (!values.has(pinfo.name)) {
  415. pinfo.usage |= PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE;
  416. }
  417. p_properties->push_back(E);
  418. }
  419. }
  420. }
  421. Variant::Type PlaceHolderScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
  422. if (values.has(p_name)) {
  423. if (r_is_valid) {
  424. *r_is_valid = true;
  425. }
  426. return values[p_name].get_type();
  427. }
  428. if (constants.has(p_name)) {
  429. if (r_is_valid) {
  430. *r_is_valid = true;
  431. }
  432. return constants[p_name].get_type();
  433. }
  434. if (r_is_valid) {
  435. *r_is_valid = false;
  436. }
  437. return Variant::NIL;
  438. }
  439. void PlaceHolderScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
  440. if (script->is_placeholder_fallback_enabled()) {
  441. return;
  442. }
  443. if (script.is_valid()) {
  444. script->get_script_method_list(p_list);
  445. }
  446. }
  447. bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const {
  448. if (script->is_placeholder_fallback_enabled()) {
  449. return false;
  450. }
  451. if (script.is_valid()) {
  452. return script->has_method(p_method);
  453. }
  454. return false;
  455. }
  456. void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, const HashMap<StringName, Variant> &p_values) {
  457. HashSet<StringName> new_values;
  458. for (const PropertyInfo &E : p_properties) {
  459. StringName n = E.name;
  460. new_values.insert(n);
  461. if (!values.has(n) || values[n].get_type() != E.type) {
  462. if (p_values.has(n)) {
  463. values[n] = p_values[n];
  464. }
  465. }
  466. }
  467. properties = p_properties;
  468. List<StringName> to_remove;
  469. for (KeyValue<StringName, Variant> &E : values) {
  470. if (!new_values.has(E.key)) {
  471. to_remove.push_back(E.key);
  472. }
  473. Variant defval;
  474. if (script->get_property_default_value(E.key, defval)) {
  475. //remove because it's the same as the default value
  476. if (defval == E.value) {
  477. to_remove.push_back(E.key);
  478. }
  479. }
  480. }
  481. while (to_remove.size()) {
  482. values.erase(to_remove.front()->get());
  483. to_remove.pop_front();
  484. }
  485. if (owner && owner->get_script_instance() == this) {
  486. owner->notify_property_list_changed();
  487. }
  488. //change notify
  489. constants.clear();
  490. script->get_constants(&constants);
  491. }
  492. void PlaceHolderScriptInstance::property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid) {
  493. if (script->is_placeholder_fallback_enabled()) {
  494. HashMap<StringName, Variant>::Iterator E = values.find(p_name);
  495. if (E) {
  496. E->value = p_value;
  497. } else {
  498. values.insert(p_name, p_value);
  499. }
  500. bool found = false;
  501. for (const PropertyInfo &F : properties) {
  502. if (F.name == p_name) {
  503. found = true;
  504. break;
  505. }
  506. }
  507. if (!found) {
  508. properties.push_back(PropertyInfo(p_value.get_type(), p_name, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_SCRIPT_VARIABLE));
  509. }
  510. }
  511. if (r_valid) {
  512. *r_valid = false; // Cannot change the value in either case
  513. }
  514. }
  515. Variant PlaceHolderScriptInstance::property_get_fallback(const StringName &p_name, bool *r_valid) {
  516. if (script->is_placeholder_fallback_enabled()) {
  517. HashMap<StringName, Variant>::ConstIterator E = values.find(p_name);
  518. if (E) {
  519. if (r_valid) {
  520. *r_valid = true;
  521. }
  522. return E->value;
  523. }
  524. E = constants.find(p_name);
  525. if (E) {
  526. if (r_valid) {
  527. *r_valid = true;
  528. }
  529. return E->value;
  530. }
  531. }
  532. if (r_valid) {
  533. *r_valid = false;
  534. }
  535. return Variant();
  536. }
  537. PlaceHolderScriptInstance::PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner) :
  538. owner(p_owner),
  539. language(p_language),
  540. script(p_script) {
  541. }
  542. PlaceHolderScriptInstance::~PlaceHolderScriptInstance() {
  543. if (script.is_valid()) {
  544. script->_placeholder_erased(this);
  545. }
  546. }