visual_script.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /**************************************************************************/
  2. /* visual_script.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. #ifndef VISUAL_SCRIPT_H
  31. #define VISUAL_SCRIPT_H
  32. #include "core/os/thread.h"
  33. #include "core/script_language.h"
  34. class VisualScriptInstance;
  35. class VisualScriptNodeInstance;
  36. class VisualScript;
  37. class VisualScriptNode : public Resource {
  38. GDCLASS(VisualScriptNode, Resource);
  39. friend class VisualScript;
  40. Set<VisualScript *> scripts_used;
  41. Array default_input_values;
  42. bool breakpoint;
  43. void _set_default_input_values(Array p_values);
  44. Array _get_default_input_values() const;
  45. void validate_input_default_values();
  46. protected:
  47. void ports_changed_notify();
  48. static void _bind_methods();
  49. public:
  50. Ref<VisualScript> get_visual_script() const;
  51. virtual int get_output_sequence_port_count() const = 0;
  52. virtual bool has_input_sequence_port() const = 0;
  53. virtual String get_output_sequence_port_text(int p_port) const = 0;
  54. virtual bool has_mixed_input_and_sequence_ports() const { return false; }
  55. virtual int get_input_value_port_count() const = 0;
  56. virtual int get_output_value_port_count() const = 0;
  57. virtual PropertyInfo get_input_value_port_info(int p_idx) const = 0;
  58. virtual PropertyInfo get_output_value_port_info(int p_idx) const = 0;
  59. void set_default_input_value(int p_port, const Variant &p_value);
  60. Variant get_default_input_value(int p_port) const;
  61. virtual String get_caption() const = 0;
  62. virtual String get_text() const;
  63. virtual String get_category() const = 0;
  64. //used by editor, this is not really saved
  65. void set_breakpoint(bool p_breakpoint);
  66. bool is_breakpoint() const;
  67. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) = 0;
  68. struct TypeGuess {
  69. Variant::Type type;
  70. StringName gdclass;
  71. Ref<Script> script;
  72. TypeGuess() {
  73. type = Variant::NIL;
  74. }
  75. };
  76. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  77. VisualScriptNode();
  78. };
  79. class VisualScriptNodeInstance {
  80. friend class VisualScriptInstance;
  81. friend class VisualScriptLanguage; //for debugger
  82. enum { //input argument addressing
  83. INPUT_SHIFT = 1 << 24,
  84. INPUT_MASK = INPUT_SHIFT - 1,
  85. INPUT_DEFAULT_VALUE_BIT = INPUT_SHIFT, // from unassigned input port, using default value (edited by user)
  86. };
  87. int id;
  88. int sequence_index;
  89. VisualScriptNodeInstance **sequence_outputs;
  90. int sequence_output_count;
  91. Vector<VisualScriptNodeInstance *> dependencies;
  92. int *input_ports;
  93. int input_port_count;
  94. int *output_ports;
  95. int output_port_count;
  96. int working_mem_idx;
  97. int pass_idx;
  98. VisualScriptNode *base;
  99. public:
  100. enum StartMode {
  101. START_MODE_BEGIN_SEQUENCE,
  102. START_MODE_CONTINUE_SEQUENCE,
  103. START_MODE_RESUME_YIELD
  104. };
  105. enum {
  106. STEP_SHIFT = 1 << 24,
  107. STEP_MASK = STEP_SHIFT - 1,
  108. STEP_FLAG_PUSH_STACK_BIT = STEP_SHIFT, //push bit to stack
  109. STEP_FLAG_GO_BACK_BIT = STEP_SHIFT << 1, //go back to previous node
  110. STEP_NO_ADVANCE_BIT = STEP_SHIFT << 2, //do not advance past this node
  111. STEP_EXIT_FUNCTION_BIT = STEP_SHIFT << 3, //return from function
  112. STEP_YIELD_BIT = STEP_SHIFT << 4, //yield (will find VisualScriptFunctionState state in first working memory)
  113. FLOW_STACK_PUSHED_BIT = 1 << 30, //in flow stack, means bit was pushed (must go back here if end of sequence)
  114. FLOW_STACK_MASK = FLOW_STACK_PUSHED_BIT - 1
  115. };
  116. _FORCE_INLINE_ int get_input_port_count() const { return input_port_count; }
  117. _FORCE_INLINE_ int get_output_port_count() const { return output_port_count; }
  118. _FORCE_INLINE_ int get_sequence_output_count() const { return sequence_output_count; }
  119. _FORCE_INLINE_ int get_id() const { return id; }
  120. virtual int get_working_memory_size() const { return 0; }
  121. virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) = 0; //do a step, return which sequence port to go out
  122. Ref<VisualScriptNode> get_base_node() { return Ref<VisualScriptNode>(base); }
  123. VisualScriptNodeInstance();
  124. virtual ~VisualScriptNodeInstance();
  125. };
  126. class VisualScript : public Script {
  127. GDCLASS(VisualScript, Script);
  128. RES_BASE_EXTENSION("vs");
  129. public:
  130. struct SequenceConnection {
  131. union {
  132. struct {
  133. uint64_t from_node : 24;
  134. uint64_t from_output : 16;
  135. uint64_t to_node : 24;
  136. };
  137. uint64_t id;
  138. };
  139. bool operator<(const SequenceConnection &p_connection) const {
  140. return id < p_connection.id;
  141. }
  142. };
  143. struct DataConnection {
  144. union {
  145. struct {
  146. uint64_t from_node : 24;
  147. uint64_t from_port : 8;
  148. uint64_t to_node : 24;
  149. uint64_t to_port : 8;
  150. };
  151. uint64_t id;
  152. };
  153. bool operator<(const DataConnection &p_connection) const {
  154. return id < p_connection.id;
  155. }
  156. };
  157. private:
  158. friend class VisualScriptInstance;
  159. StringName base_type;
  160. struct Argument {
  161. String name;
  162. Variant::Type type;
  163. };
  164. struct Function {
  165. struct NodeData {
  166. Point2 pos;
  167. Ref<VisualScriptNode> node;
  168. };
  169. Map<int, NodeData> nodes;
  170. Set<SequenceConnection> sequence_connections;
  171. Set<DataConnection> data_connections;
  172. int function_id;
  173. Vector2 scroll;
  174. Function() { function_id = -1; }
  175. };
  176. struct Variable {
  177. Map<int, Ref<VisualScriptNode>> nodes;
  178. PropertyInfo info;
  179. Variant default_value;
  180. bool _export;
  181. // add getter & setter options here
  182. };
  183. Map<StringName, Function> functions;
  184. Map<StringName, Variable> variables;
  185. Map<StringName, Vector<Argument>> custom_signals;
  186. Map<Object *, VisualScriptInstance *> instances;
  187. bool is_tool_script;
  188. #ifdef TOOLS_ENABLED
  189. Set<PlaceHolderScriptInstance *> placeholders;
  190. //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
  191. virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
  192. void _update_placeholders();
  193. #endif
  194. void _set_variable_info(const StringName &p_name, const Dictionary &p_info);
  195. Dictionary _get_variable_info(const StringName &p_name) const;
  196. void _set_data(const Dictionary &p_data);
  197. Dictionary _get_data() const;
  198. protected:
  199. void _node_ports_changed(int p_id);
  200. static void _bind_methods();
  201. public:
  202. bool inherits_script(const Ref<Script> &p_script) const;
  203. // TODO: Remove it in future when breaking changes are acceptable
  204. StringName get_default_func() const;
  205. void add_function(const StringName &p_name);
  206. bool has_function(const StringName &p_name) const;
  207. void remove_function(const StringName &p_name);
  208. void rename_function(const StringName &p_name, const StringName &p_new_name);
  209. void set_function_scroll(const StringName &p_name, const Vector2 &p_scroll);
  210. Vector2 get_function_scroll(const StringName &p_name) const;
  211. void get_function_list(List<StringName> *r_functions) const;
  212. int get_function_node_id(const StringName &p_name) const;
  213. void set_tool_enabled(bool p_enabled);
  214. void add_node(const StringName &p_func, int p_id, const Ref<VisualScriptNode> &p_node, const Point2 &p_pos = Point2());
  215. void remove_node(const StringName &p_func, int p_id);
  216. bool has_node(const StringName &p_func, int p_id) const;
  217. Ref<VisualScriptNode> get_node(const StringName &p_func, int p_id) const;
  218. void set_node_position(const StringName &p_func, int p_id, const Point2 &p_pos);
  219. Point2 get_node_position(const StringName &p_func, int p_id) const;
  220. void get_node_list(const StringName &p_func, List<int> *r_nodes) const;
  221. void sequence_connect(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node);
  222. void sequence_disconnect(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node);
  223. bool has_sequence_connection(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node) const;
  224. void get_sequence_connection_list(const StringName &p_func, List<SequenceConnection> *r_connection) const;
  225. void data_connect(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
  226. void data_disconnect(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
  227. bool has_data_connection(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const;
  228. void get_data_connection_list(const StringName &p_func, List<DataConnection> *r_connection) const;
  229. bool is_input_value_port_connected(const StringName &p_func, int p_node, int p_port) const;
  230. bool get_input_value_port_connection_source(const StringName &p_func, int p_node, int p_port, int *r_node, int *r_port) const;
  231. void add_variable(const StringName &p_name, const Variant &p_default_value = Variant(), bool p_export = false);
  232. bool has_variable(const StringName &p_name) const;
  233. void remove_variable(const StringName &p_name);
  234. void set_variable_default_value(const StringName &p_name, const Variant &p_value);
  235. Variant get_variable_default_value(const StringName &p_name) const;
  236. void set_variable_info(const StringName &p_name, const PropertyInfo &p_info);
  237. PropertyInfo get_variable_info(const StringName &p_name) const;
  238. void set_variable_export(const StringName &p_name, bool p_export);
  239. bool get_variable_export(const StringName &p_name) const;
  240. void get_variable_list(List<StringName> *r_variables) const;
  241. void rename_variable(const StringName &p_name, const StringName &p_new_name);
  242. void add_custom_signal(const StringName &p_name);
  243. bool has_custom_signal(const StringName &p_name) const;
  244. void custom_signal_add_argument(const StringName &p_func, Variant::Type p_type, const String &p_name, int p_index = -1);
  245. void custom_signal_set_argument_type(const StringName &p_func, int p_argidx, Variant::Type p_type);
  246. Variant::Type custom_signal_get_argument_type(const StringName &p_func, int p_argidx) const;
  247. void custom_signal_set_argument_name(const StringName &p_func, int p_argidx, const String &p_name);
  248. String custom_signal_get_argument_name(const StringName &p_func, int p_argidx) const;
  249. void custom_signal_remove_argument(const StringName &p_func, int p_argidx);
  250. int custom_signal_get_argument_count(const StringName &p_func) const;
  251. void custom_signal_swap_argument(const StringName &p_func, int p_argidx, int p_with_argidx);
  252. void remove_custom_signal(const StringName &p_name);
  253. void rename_custom_signal(const StringName &p_name, const StringName &p_new_name);
  254. Set<int> get_output_sequence_ports_connected(const String &edited_func, int from_node);
  255. void get_custom_signal_list(List<StringName> *r_custom_signals) const;
  256. int get_available_id() const;
  257. void set_instance_base_type(const StringName &p_type);
  258. virtual bool can_instance() const;
  259. virtual Ref<Script> get_base_script() const;
  260. virtual StringName get_instance_base_type() const;
  261. virtual ScriptInstance *instance_create(Object *p_this);
  262. virtual bool instance_has(const Object *p_this) const;
  263. virtual bool has_source_code() const;
  264. virtual String get_source_code() const;
  265. virtual void set_source_code(const String &p_code);
  266. virtual Error reload(bool p_keep_state = false);
  267. virtual bool is_tool() const;
  268. virtual bool is_valid() const;
  269. virtual ScriptLanguage *get_language() const;
  270. virtual bool has_script_signal(const StringName &p_signal) const;
  271. virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
  272. virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
  273. virtual void get_script_method_list(List<MethodInfo> *p_list) const;
  274. virtual bool has_method(const StringName &p_method) const;
  275. virtual MethodInfo get_method_info(const StringName &p_method) const;
  276. virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
  277. virtual int get_member_line(const StringName &p_member) const;
  278. #ifdef TOOLS_ENABLED
  279. virtual bool are_subnodes_edited() const;
  280. #endif
  281. VisualScript();
  282. ~VisualScript();
  283. };
  284. class VisualScriptInstance : public ScriptInstance {
  285. Object *owner;
  286. Ref<VisualScript> script;
  287. Map<StringName, Variant> variables; //using variable path, not script
  288. Map<int, VisualScriptNodeInstance *> instances;
  289. struct Function {
  290. int node;
  291. int max_stack;
  292. int trash_pos;
  293. int flow_stack_size;
  294. int pass_stack_size;
  295. int node_count;
  296. int argument_count;
  297. };
  298. Map<StringName, Function> functions;
  299. Vector<Variant> default_values;
  300. int max_input_args, max_output_args;
  301. StringName source;
  302. void _dependency_step(VisualScriptNodeInstance *node, int p_pass, int *pass_stack, const Variant **input_args, Variant **output_args, Variant *variant_stack, Variant::CallError &r_error, String &error_str, VisualScriptNodeInstance **r_error_node);
  303. Variant _call_internal(const StringName &p_method, void *p_stack, int p_stack_size, VisualScriptNodeInstance *p_node, int p_flow_stack_pos, int p_pass, bool p_resuming_yield, Variant::CallError &r_error);
  304. //Map<StringName,Function> functions;
  305. friend class VisualScriptFunctionState; //for yield
  306. friend class VisualScriptLanguage; //for debugger
  307. public:
  308. virtual bool set(const StringName &p_name, const Variant &p_value);
  309. virtual bool get(const StringName &p_name, Variant &r_ret) const;
  310. virtual void get_property_list(List<PropertyInfo> *p_properties) const;
  311. virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const;
  312. virtual void get_method_list(List<MethodInfo> *p_list) const;
  313. virtual bool has_method(const StringName &p_method) const;
  314. virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
  315. virtual void notification(int p_notification);
  316. String to_string(bool *r_valid);
  317. bool set_variable(const StringName &p_variable, const Variant &p_value) {
  318. Map<StringName, Variant>::Element *E = variables.find(p_variable);
  319. if (!E) {
  320. return false;
  321. }
  322. E->get() = p_value;
  323. return true;
  324. }
  325. bool get_variable(const StringName &p_variable, Variant *r_variable) const {
  326. const Map<StringName, Variant>::Element *E = variables.find(p_variable);
  327. if (!E) {
  328. return false;
  329. }
  330. *r_variable = E->get();
  331. return true;
  332. }
  333. virtual Ref<Script> get_script() const;
  334. _FORCE_INLINE_ VisualScript *get_script_ptr() { return script.ptr(); }
  335. _FORCE_INLINE_ Object *get_owner_ptr() { return owner; }
  336. void create(const Ref<VisualScript> &p_script, Object *p_owner);
  337. virtual ScriptLanguage *get_language();
  338. virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
  339. virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
  340. VisualScriptInstance();
  341. ~VisualScriptInstance();
  342. };
  343. class VisualScriptFunctionState : public Reference {
  344. GDCLASS(VisualScriptFunctionState, Reference);
  345. friend class VisualScriptInstance;
  346. ObjectID instance_id;
  347. ObjectID script_id;
  348. VisualScriptInstance *instance;
  349. StringName function;
  350. Vector<uint8_t> stack;
  351. int working_mem_index;
  352. int variant_stack_size;
  353. VisualScriptNodeInstance *node;
  354. int flow_stack_pos;
  355. int pass;
  356. Variant _signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
  357. protected:
  358. static void _bind_methods();
  359. public:
  360. void connect_to_signal(Object *p_obj, const String &p_signal, Array p_binds);
  361. bool is_valid() const;
  362. Variant resume(Array p_args);
  363. VisualScriptFunctionState();
  364. ~VisualScriptFunctionState();
  365. };
  366. typedef Ref<VisualScriptNode> (*VisualScriptNodeRegisterFunc)(const String &p_type);
  367. class VisualScriptLanguage : public ScriptLanguage {
  368. Map<String, VisualScriptNodeRegisterFunc> register_funcs;
  369. struct CallLevel {
  370. Variant *stack;
  371. Variant **work_mem;
  372. const StringName *function;
  373. VisualScriptInstance *instance;
  374. int *current_id;
  375. };
  376. int _debug_parse_err_node;
  377. String _debug_parse_err_file;
  378. String _debug_error;
  379. int _debug_call_stack_pos;
  380. int _debug_max_call_stack;
  381. CallLevel *_call_stack;
  382. public:
  383. StringName notification;
  384. StringName _get_output_port_unsequenced;
  385. StringName _step;
  386. StringName _subcall;
  387. static VisualScriptLanguage *singleton;
  388. Mutex lock;
  389. bool debug_break(const String &p_error, bool p_allow_continue = true);
  390. bool debug_break_parse(const String &p_file, int p_node, const String &p_error);
  391. _FORCE_INLINE_ void enter_function(VisualScriptInstance *p_instance, const StringName *p_function, Variant *p_stack, Variant **p_work_mem, int *current_id) {
  392. if (Thread::get_main_id() != Thread::get_caller_id()) {
  393. return; //no support for other threads than main for now
  394. }
  395. if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0) {
  396. ScriptDebugger::get_singleton()->set_depth(ScriptDebugger::get_singleton()->get_depth() + 1);
  397. }
  398. if (_debug_call_stack_pos >= _debug_max_call_stack) {
  399. //stack overflow
  400. _debug_error = "Stack Overflow (Stack Size: " + itos(_debug_max_call_stack) + ")";
  401. ScriptDebugger::get_singleton()->debug(this);
  402. return;
  403. }
  404. _call_stack[_debug_call_stack_pos].stack = p_stack;
  405. _call_stack[_debug_call_stack_pos].instance = p_instance;
  406. _call_stack[_debug_call_stack_pos].function = p_function;
  407. _call_stack[_debug_call_stack_pos].work_mem = p_work_mem;
  408. _call_stack[_debug_call_stack_pos].current_id = current_id;
  409. _debug_call_stack_pos++;
  410. }
  411. _FORCE_INLINE_ void exit_function() {
  412. if (Thread::get_main_id() != Thread::get_caller_id()) {
  413. return; //no support for other threads than main for now
  414. }
  415. if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0) {
  416. ScriptDebugger::get_singleton()->set_depth(ScriptDebugger::get_singleton()->get_depth() - 1);
  417. }
  418. if (_debug_call_stack_pos == 0) {
  419. _debug_error = "Stack Underflow (Engine Bug)";
  420. ScriptDebugger::get_singleton()->debug(this);
  421. return;
  422. }
  423. _debug_call_stack_pos--;
  424. }
  425. //////////////////////////////////////
  426. virtual String get_name() const;
  427. /* LANGUAGE FUNCTIONS */
  428. virtual void init();
  429. virtual String get_type() const;
  430. virtual String get_extension() const;
  431. virtual Error execute_file(const String &p_path);
  432. virtual void finish();
  433. /* EDITOR FUNCTIONS */
  434. virtual void get_reserved_words(List<String> *p_words) const;
  435. virtual bool is_control_flow_keyword(String p_keyword) const;
  436. virtual void get_comment_delimiters(List<String> *p_delimiters) const;
  437. virtual void get_string_delimiters(List<String> *p_delimiters) const;
  438. virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
  439. virtual bool is_using_templates();
  440. virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script);
  441. virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
  442. virtual Script *create_script() const;
  443. virtual bool has_named_classes() const;
  444. virtual bool supports_builtin_mode() const;
  445. virtual int find_function(const String &p_function, const String &p_code) const;
  446. virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
  447. virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
  448. virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
  449. /* DEBUGGER FUNCTIONS */
  450. virtual String debug_get_error() const;
  451. virtual int debug_get_stack_level_count() const;
  452. virtual int debug_get_stack_level_line(int p_level) const;
  453. virtual String debug_get_stack_level_function(int p_level) const;
  454. virtual String debug_get_stack_level_source(int p_level) const;
  455. 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);
  456. 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);
  457. virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
  458. virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1);
  459. virtual void reload_all_scripts();
  460. virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
  461. /* LOADER FUNCTIONS */
  462. virtual void get_recognized_extensions(List<String> *p_extensions) const;
  463. virtual void get_public_functions(List<MethodInfo> *p_functions) const;
  464. virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const;
  465. virtual void profiling_start();
  466. virtual void profiling_stop();
  467. virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
  468. virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
  469. void add_register_func(const String &p_name, VisualScriptNodeRegisterFunc p_func);
  470. void remove_register_func(const String &p_name);
  471. Ref<VisualScriptNode> create_node_from_name(const String &p_name);
  472. void get_registered_node_names(List<String> *r_names);
  473. VisualScriptLanguage();
  474. ~VisualScriptLanguage();
  475. };
  476. //aid for registering
  477. template <class T>
  478. static Ref<VisualScriptNode> create_node_generic(const String &p_name) {
  479. Ref<T> node;
  480. node.instance();
  481. return node;
  482. }
  483. #endif // VISUAL_SCRIPT_H