summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-09-02 02:13:12 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-09-02 02:13:12 -0300
commit89702d545b89a1f07d17fb2bd8e766c91574cd24 (patch)
tree29613fba90613ed71a1afb97409b7b30966157ab /core
parent65ae4976eb7dfaa472aba7a9931b5beb537fe21a (diff)
downloadredot-engine-89702d545b89a1f07d17fb2bd8e766c91574cd24.tar.gz
Basic type constants for visual script
Diffstat (limited to 'core')
-rw-r--r--core/variant.h2
-rw-r--r--core/variant_call.cpp12
2 files changed, 11 insertions, 3 deletions
diff --git a/core/variant.h b/core/variant.h
index b8b028a760..90be593bd9 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -426,7 +426,7 @@ public:
static void get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_list);
static void get_numeric_constants_for_type(Variant::Type p_type, List<StringName> *p_constants);
static bool has_numeric_constant(Variant::Type p_type, const StringName& p_value);
- static int get_numeric_constant_value(Variant::Type p_type, const StringName& p_value);
+ static int get_numeric_constant_value(Variant::Type p_type, const StringName& p_value,bool *r_valid=NULL);
typedef String (*ObjectDeConstruct)(const Variant& p_object,void *ud);
typedef void (*ObjectConstruct)(const String& p_text,void *ud,Variant& r_value);
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 069c20bc6e..5337b6ba04 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -1324,14 +1324,22 @@ bool Variant::has_numeric_constant(Variant::Type p_type, const StringName& p_val
return cd.value.has(p_value);
}
-int Variant::get_numeric_constant_value(Variant::Type p_type, const StringName& p_value) {
+int Variant::get_numeric_constant_value(Variant::Type p_type, const StringName& p_value, bool *r_valid) {
+
+ if (r_valid)
+ *r_valid=false;
ERR_FAIL_INDEX_V(p_type,Variant::VARIANT_MAX,0);
_VariantCall::ConstantData& cd = _VariantCall::constant_data[p_type];
Map<StringName,int>::Element *E = cd.value.find(p_value);
- ERR_FAIL_COND_V(!E,0);
+ if (!E) {
+ return -1;
+ }
+ if (r_valid)
+ *r_valid=true;
+
return E->get();
}