script_language.cpp 19 KB

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