visual_script.h 22 KB

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