diff options
Diffstat (limited to 'core/script_language.h')
-rw-r--r-- | core/script_language.h | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/core/script_language.h b/core/script_language.h index d8b4c61b6c..1b037e908c 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -38,6 +38,8 @@ class ScriptLanguage; +typedef void (*ScriptEditRequestFunction)(const String& p_path); + class ScriptServer { enum { @@ -47,13 +49,23 @@ class ScriptServer { static ScriptLanguage *_languages[MAX_LANGUAGES]; static int _language_count; static bool scripting_enabled; + static bool reload_scripts_on_save; public: + static ScriptEditRequestFunction edit_request_func; + static void set_scripting_enabled(bool p_enabled); static bool is_scripting_enabled(); static int get_language_count(); static ScriptLanguage *get_language(int p_idx); static void register_language(ScriptLanguage *p_language); + static void unregister_language(ScriptLanguage *p_language); + + static void set_reload_scripts_on_save(bool p_enable); + static bool is_reload_scripts_on_save_enabled(); + + static void thread_enter(); + static void thread_exit(); static void init_languages(); }; @@ -70,6 +82,7 @@ class Script : public Resource { protected: + virtual bool editor_can_reload_from_file() { return false; } // this is handled by editor better void _notification( int p_what); static void _bind_methods(); @@ -79,6 +92,8 @@ public: virtual bool can_instance() const=0; + virtual Ref<Script> get_base_script() const=0; //for script inheritance + virtual StringName get_instance_base_type() const=0; // this may not work in all scripts, will return empty if so virtual ScriptInstance* instance_create(Object *p_this)=0; virtual bool instance_has(const Object *p_this) const=0; @@ -89,6 +104,9 @@ public: virtual void set_source_code(const String& p_code)=0; virtual Error reload(bool p_keep_state=false)=0; + virtual bool has_method(const StringName& p_method) const=0; + virtual MethodInfo get_method_info(const StringName& p_method) const=0; + virtual bool is_tool() const=0; virtual String get_node_type() const=0; @@ -101,6 +119,8 @@ public: virtual bool get_property_default_value(const StringName& p_property,Variant& r_value) const=0; virtual void update_exports() {} //editor tool + virtual void get_script_method_list(List<MethodInfo> *p_list) const=0; + virtual void get_script_property_list(List<PropertyInfo> *p_list) const=0; Script() {} @@ -108,6 +128,8 @@ public: class ScriptInstance { public: + + virtual bool set(const StringName& p_name, const Variant& p_value)=0; virtual bool get(const StringName& p_name, Variant &r_ret) const=0; virtual void get_property_list(List<PropertyInfo> *p_properties) const=0; @@ -124,11 +146,28 @@ public: virtual void call_multilevel_reversed(const StringName& p_method,const Variant** p_args,int p_argcount); virtual void notification(int p_notification)=0; + //this is used by script languages that keep a reference counter of their own + //you can make make Ref<> not die when it reaches zero, so deleting the reference + //depends entirely from the script + + virtual void refcount_incremented() {} + virtual bool refcount_decremented() { return true; } //return true if it can die virtual Ref<Script> get_script() const=0; virtual bool is_placeholder() const { return false; } + enum RPCMode { + RPC_MODE_DISABLED, + RPC_MODE_REMOTE, + RPC_MODE_SYNC, + RPC_MODE_MASTER, + RPC_MODE_SLAVE, + }; + + virtual RPCMode get_rpc_mode(const StringName& p_method) const=0; + virtual RPCMode get_rset_mode(const StringName& p_variable) const=0; + virtual ScriptLanguage *get_language()=0; virtual ~ScriptInstance(); }; @@ -162,7 +201,7 @@ public: virtual void get_reserved_words(List<String> *p_words) const=0; virtual void get_comment_delimiters(List<String> *p_delimiters) const=0; virtual void get_string_delimiters(List<String> *p_delimiters) const=0; - virtual String get_template(const String& p_class_name, const String& p_base_class_name) const=0; + virtual Ref<Script> get_template(const String& p_class_name, const String& p_base_class_name) const=0; 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) const=0; virtual Script *create_script() const=0; virtual bool has_named_classes() const=0; @@ -172,6 +211,12 @@ public: virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const=0; virtual void add_global_constant(const StringName& p_variable,const Variant& p_value)=0; + /* MULTITHREAD FUNCTIONS */ + + //some VMs need to be notified of thread creation/exiting to allocate a stack + virtual void thread_enter() {} + virtual void thread_exit() {} + /* DEBUGGER FUNCTIONS */ virtual String debug_get_error() const=0; @@ -192,6 +237,7 @@ public: virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); } virtual void reload_all_scripts()=0; + virtual void reload_tool_script(const Ref<Script>& p_script,bool p_soft_reload)=0; /* LOADER FUNCTIONS */ virtual void get_recognized_extensions(List<String> *p_extensions) const=0; @@ -253,6 +299,9 @@ public: virtual bool is_placeholder() const { return true; } + virtual RPCMode get_rpc_mode(const StringName& p_method) const { return RPC_MODE_DISABLED; } + virtual RPCMode get_rset_mode(const StringName& p_variable) const { return RPC_MODE_DISABLED; } + PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script,Object *p_owner); ~PlaceHolderScriptInstance(); |