summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/object.cpp121
-rw-r--r--core/object.h8
-rw-r--r--core/object_type_db.cpp2
-rw-r--r--core/script_language.cpp1
-rw-r--r--core/script_language.h6
5 files changed, 108 insertions, 30 deletions
diff --git a/core/object.cpp b/core/object.cpp
index 26319d42dd..b036efa501 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -59,30 +59,112 @@ struct _ObjectDebugLock {
#endif
+
+PropertyInfo::operator Dictionary() const {
+
+ Dictionary d;
+ d["name"]=name;
+ d["type"]=type;
+ d["hint"]=hint;
+ d["hint_string"]=hint_string;
+ d["usage"]=usage;
+ return d;
+
+}
+
+PropertyInfo PropertyInfo::from_dict(const Dictionary& p_dict) {
+
+ PropertyInfo pi;
+
+ if (p_dict.has("type"))
+ pi.type=Variant::Type(int(p_dict["type"]));
+
+ if (p_dict.has("name"))
+ pi.name=p_dict["name"];
+
+ if (p_dict.has("hint"))
+ pi.hint=PropertyHint(int(p_dict["hint"]));
+
+ if (p_dict.has("hint_string"))
+
+ pi.hint_string=p_dict["hint_string"];
+
+ if (p_dict.has("usage"))
+ pi.usage=p_dict["usage"];
+
+ return pi;
+}
+
+
Array convert_property_list(const List<PropertyInfo> * p_list) {
Array va;
for (const List<PropertyInfo>::Element *E=p_list->front();E;E=E->next()) {
- const PropertyInfo &pi = E->get();
- Dictionary d;
- d["name"]=pi.name;
- d["type"]=pi.type;
- d["hint"]=pi.hint;
- d["hint_string"]=pi.hint_string;
- d["usage"]=pi.usage;
- va.push_back(d);
+
+ va.push_back(Dictionary(E->get()));
}
return va;
}
+MethodInfo::operator Dictionary() const {
+
+
+ Dictionary d;
+ d["name"]=name;
+ d["args"]=convert_property_list(&arguments);
+ Array da;
+ for(int i=0;i<default_arguments.size();i++)
+ da.push_back(default_arguments[i]);
+ d["default_args"]=da;
+ d["flags"]=flags;
+ d["id"]=id;
+ Dictionary r = return_val;
+ d["return"]=r;
+ return d;
+
+}
+
MethodInfo::MethodInfo() {
id=0;
flags=METHOD_FLAG_NORMAL;
}
+MethodInfo MethodInfo::from_dict(const Dictionary& p_dict) {
+
+ MethodInfo mi;
+
+ if (p_dict.has("name"))
+ mi.name=p_dict["name"];
+ Array args;
+ if (p_dict.has("args")) {
+ args=p_dict["args"];
+ }
+
+ for(int i=0;i<args.size();i++) {
+ Dictionary d = args[i];
+ mi.arguments.push_back(PropertyInfo::from_dict(d));
+ }
+ Array defargs;
+ if (p_dict.has("default_args")) {
+ defargs=p_dict["default_args"];
+ }
+ for(int i=0;i<defargs.size();i++) {
+ mi.default_arguments.push_back(defargs[i]);
+ }
+
+ if (p_dict.has("return")) {
+ mi.return_val=PropertyInfo::from_dict(p_dict["return"]);
+ }
+
+ if (p_dict.has("flags"))
+ mi.flags=p_dict["flags"];
+
+ return mi;
+}
+
MethodInfo::MethodInfo(const String& p_name) {
id=0;
@@ -1012,25 +1094,6 @@ Array Object::_get_property_list_bind() const {
}
-static Dictionary _get_dict_from_method(const MethodInfo &mi) {
-
- Dictionary d;
- d["name"]=mi.name;
- d["args"]=convert_property_list(&mi.arguments);
- Array da;
- for(int i=0;i<mi.default_arguments.size();i++)
- da.push_back(mi.default_arguments[i]);
- d["default_args"]=da;
- d["flags"]=mi.flags;
- d["id"]=mi.id;
- Dictionary r;
- r["type"]=mi.return_val.type;
- r["hint"]=mi.return_val.hint;
- r["hint_string"]=mi.return_val.hint_string;
- d["return_type"]=r;
- return d;
-
-}
Array Object::_get_method_list_bind() const {
@@ -1040,7 +1103,7 @@ Array Object::_get_method_list_bind() const {
for(List<MethodInfo>::Element *E=ml.front();E;E=E->next()) {
- Dictionary d = _get_dict_from_method(E->get());
+ Dictionary d = E->get();
//va.push_back(d);
ret.push_back(d);
}
@@ -1305,7 +1368,7 @@ Array Object::_get_signal_list() const{
Array ret;
for (List<MethodInfo>::Element *E=signal_list.front();E;E=E->next()) {
- ret.push_back(_get_dict_from_method(E->get()));
+ ret.push_back(Dictionary(E->get()));
}
return ret;
diff --git a/core/object.h b/core/object.h
index 6ea794ec71..ac3fc51b3e 100644
--- a/core/object.h
+++ b/core/object.h
@@ -126,6 +126,11 @@ struct PropertyInfo {
_FORCE_INLINE_ PropertyInfo added_usage(int p_fl) const { PropertyInfo pi=*this; pi.usage|=p_fl; return pi; }
+
+ operator Dictionary() const;
+
+ static PropertyInfo from_dict(const Dictionary& p_dict);
+
PropertyInfo() { type=Variant::NIL; hint=PROPERTY_HINT_NONE; usage = PROPERTY_USAGE_DEFAULT; }
PropertyInfo( Variant::Type p_type, const String p_name, PropertyHint p_hint=PROPERTY_HINT_NONE, const String& p_hint_string="",uint32_t p_usage=PROPERTY_USAGE_DEFAULT) {
type=p_type; name=p_name; hint=p_hint; hint_string=p_hint_string; usage=p_usage;
@@ -150,6 +155,9 @@ struct MethodInfo {
inline bool operator<(const MethodInfo& p_method) const { return id==p_method.id?(name < p_method.name):(id<p_method.id); }
+ operator Dictionary() const;
+
+ static MethodInfo from_dict(const Dictionary& p_dict);
MethodInfo();
MethodInfo(const String& p_name);
MethodInfo(const String& p_name, const PropertyInfo& p_param1);
diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp
index ba98797a89..b6a69e3bd4 100644
--- a/core/object_type_db.cpp
+++ b/core/object_type_db.cpp
@@ -642,7 +642,7 @@ void ObjectTypeDB::get_property_list(StringName p_type, List<PropertyInfo> *p_li
TypeInfo *check=type;
while(check) {
- for(List<PropertyInfo>::Element *E=type->property_list.front();E;E=E->next()) {
+ for(List<PropertyInfo>::Element *E=check->property_list.front();E;E=E->next()) {
if (p_validator) {
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 75d8b6d285..fa1d01d3eb 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -33,6 +33,7 @@ int ScriptServer::_language_count=0;
bool ScriptServer::scripting_enabled=true;
bool ScriptServer::reload_scripts_on_save=false;
+ScriptEditRequestFunction ScriptServer::edit_request_func=NULL;
void Script::_notification( int p_what) {
diff --git a/core/script_language.h b/core/script_language.h
index 36ed11efec..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 {
@@ -50,6 +52,8 @@ class ScriptServer {
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();
@@ -88,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;