Add GDExtension support to Script
* Ability to create script languages from GDExtension * Some additions to gdnative_extension.h to make this happen * Moved the GDExtension binder to core This now allows creating scripting languages from GDExtension, with the same ease as if it was a module. It replaces the old PluginScript from Godot 3.x. Warning: GodotCPP will need to be updated to support this (it may be a bit of work as ScriptInstance needs to be created over there again).
This commit is contained in:
@ -132,7 +132,7 @@ public:
|
||||
virtual Error reload(bool p_keep_state = false) = 0;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
virtual const Vector<DocData::ClassDoc> &get_documentation() const = 0;
|
||||
virtual Vector<DocData::ClassDoc> get_documentation() const = 0;
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
virtual bool has_method(const StringName &p_method) const = 0;
|
||||
@ -212,44 +212,12 @@ public:
|
||||
virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid);
|
||||
virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid);
|
||||
|
||||
virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const = 0;
|
||||
virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const { return get_script()->get_rpc_methods(); }
|
||||
|
||||
virtual ScriptLanguage *get_language() = 0;
|
||||
virtual ~ScriptInstance();
|
||||
};
|
||||
|
||||
struct ScriptCodeCompletionOption {
|
||||
/* Keep enum in Sync with: */
|
||||
/* /scene/gui/code_edit.h - CodeEdit::CodeCompletionKind */
|
||||
enum Kind {
|
||||
KIND_CLASS,
|
||||
KIND_FUNCTION,
|
||||
KIND_SIGNAL,
|
||||
KIND_VARIABLE,
|
||||
KIND_MEMBER,
|
||||
KIND_ENUM,
|
||||
KIND_CONSTANT,
|
||||
KIND_NODE_PATH,
|
||||
KIND_FILE_PATH,
|
||||
KIND_PLAIN_TEXT,
|
||||
};
|
||||
Kind kind = KIND_PLAIN_TEXT;
|
||||
String display;
|
||||
String insert_text;
|
||||
Color font_color;
|
||||
RES icon;
|
||||
Variant default_value;
|
||||
Vector<Pair<int, int>> matches;
|
||||
|
||||
ScriptCodeCompletionOption() {}
|
||||
|
||||
ScriptCodeCompletionOption(const String &p_text, Kind p_kind) {
|
||||
display = p_text;
|
||||
insert_text = p_text;
|
||||
kind = p_kind;
|
||||
}
|
||||
};
|
||||
|
||||
class ScriptCodeCompletionCache {
|
||||
static ScriptCodeCompletionCache *singleton;
|
||||
|
||||
@ -261,7 +229,8 @@ public:
|
||||
virtual ~ScriptCodeCompletionCache() {}
|
||||
};
|
||||
|
||||
class ScriptLanguage {
|
||||
class ScriptLanguage : public Object {
|
||||
GDCLASS(ScriptLanguage, Object)
|
||||
public:
|
||||
virtual String get_name() const = 0;
|
||||
|
||||
@ -326,19 +295,55 @@ public:
|
||||
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
|
||||
virtual bool overrides_external_editor() { return false; }
|
||||
|
||||
virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_force, String &r_call_hint) { return ERR_UNAVAILABLE; }
|
||||
/* Keep enum in Sync with: */
|
||||
/* /scene/gui/code_edit.h - CodeEdit::CodeCompletionKind */
|
||||
enum CodeCompletionKind {
|
||||
CODE_COMPLETION_KIND_CLASS,
|
||||
CODE_COMPLETION_KIND_FUNCTION,
|
||||
CODE_COMPLETION_KIND_SIGNAL,
|
||||
CODE_COMPLETION_KIND_VARIABLE,
|
||||
CODE_COMPLETION_KIND_MEMBER,
|
||||
CODE_COMPLETION_KIND_ENUM,
|
||||
CODE_COMPLETION_KIND_CONSTANT,
|
||||
CODE_COMPLETION_KIND_NODE_PATH,
|
||||
CODE_COMPLETION_KIND_FILE_PATH,
|
||||
CODE_COMPLETION_KIND_PLAIN_TEXT,
|
||||
CODE_COMPLETION_KIND_MAX
|
||||
};
|
||||
|
||||
struct CodeCompletionOption {
|
||||
CodeCompletionKind kind = CODE_COMPLETION_KIND_PLAIN_TEXT;
|
||||
String display;
|
||||
String insert_text;
|
||||
Color font_color;
|
||||
RES icon;
|
||||
Variant default_value;
|
||||
Vector<Pair<int, int>> matches;
|
||||
|
||||
CodeCompletionOption() {}
|
||||
|
||||
CodeCompletionOption(const String &p_text, CodeCompletionKind p_kind) {
|
||||
display = p_text;
|
||||
insert_text = p_text;
|
||||
kind = p_kind;
|
||||
}
|
||||
};
|
||||
|
||||
virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<CodeCompletionOption> *r_options, bool &r_force, String &r_call_hint) { return ERR_UNAVAILABLE; }
|
||||
|
||||
enum LookupResultType {
|
||||
LOOKUP_RESULT_SCRIPT_LOCATION,
|
||||
LOOKUP_RESULT_CLASS,
|
||||
LOOKUP_RESULT_CLASS_CONSTANT,
|
||||
LOOKUP_RESULT_CLASS_PROPERTY,
|
||||
LOOKUP_RESULT_CLASS_METHOD,
|
||||
LOOKUP_RESULT_CLASS_ENUM,
|
||||
LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE,
|
||||
LOOKUP_RESULT_MAX
|
||||
};
|
||||
|
||||
struct LookupResult {
|
||||
enum Type {
|
||||
RESULT_SCRIPT_LOCATION,
|
||||
RESULT_CLASS,
|
||||
RESULT_CLASS_CONSTANT,
|
||||
RESULT_CLASS_PROPERTY,
|
||||
RESULT_CLASS_METHOD,
|
||||
RESULT_CLASS_ENUM,
|
||||
RESULT_CLASS_TBD_GLOBALSCOPE
|
||||
};
|
||||
Type type;
|
||||
LookupResultType type;
|
||||
Ref<Script> script;
|
||||
String class_name;
|
||||
String class_member;
|
||||
|
||||
Reference in New Issue
Block a user