/*************************************************************************/ /* script_language.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #ifndef SCRIPT_LANGUAGE_H #define SCRIPT_LANGUAGE_H #include "resource.h" #include "map.h" #include "pair.h" /** @author Juan Linietsky */ class ScriptLanguage; class ScriptServer { enum { MAX_LANGUAGES=4 }; static ScriptLanguage *_languages[MAX_LANGUAGES]; static int _language_count; static bool scripting_enabled; public: 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 init_languages(); }; class ScriptInstance; class PlaceHolderScriptInstance; class Script : public Resource { OBJ_TYPE( Script, Resource ); OBJ_SAVE_TYPE( Script ); protected: void _notification( int p_what); static void _bind_methods(); friend class PlaceHolderScriptInstance; virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {} public: virtual bool can_instance() const=0; 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; virtual bool has_source_code() const=0; virtual String get_source_code() const=0; virtual void set_source_code(const String& p_code)=0; virtual Error reload()=0; virtual bool is_tool() const=0; virtual String get_node_type() const=0; virtual ScriptLanguage *get_language() const=0; virtual bool has_script_signal(const StringName& p_signal) const=0; virtual void get_script_signal_list(List *r_signals) const=0; virtual void update_exports() {} //editor tool Script() {} }; 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 *p_properties) const=0; virtual void get_method_list(List *p_list) const=0; virtual bool has_method(const StringName& p_method) const=0; virtual Variant call(const StringName& p_method,VARIANT_ARG_LIST); virtual Variant call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error)=0; virtual void call_multilevel(const StringName& p_method,VARIANT_ARG_LIST); virtual void call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount); virtual void call_multilevel_reversed(const StringName& p_method,const Variant** p_args,int p_argcount); virtual void notification(int p_notification)=0; virtual Ref