diff options
author | Zher Huei Lee <lee.zh.92@gmail.com> | 2016-10-26 13:05:00 +0100 |
---|---|---|
committer | Zher Huei Lee <lee.zh.92@gmail.com> | 2016-10-27 10:27:40 +0100 |
commit | 9a5ce099f1c3559cc46b923d4e192a7be781163c (patch) | |
tree | 2e85742d1381cc8e527289ef44dc369b9c83629d /modules | |
parent | c3b4686082bc92c70886ee848064009c8f628193 (diff) |
Changed RegEx to inherit Resource
Diffstat (limited to 'modules')
-rw-r--r-- | modules/regex/regex.cpp | 8 | ||||
-rw-r--r-- | modules/regex/regex.h | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index 388e6dfdec..a0f4b4934c 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -985,7 +985,9 @@ static bool RegEx_is_shorthand(CharType ch) { Error RegEx::compile(const String& p_pattern) { - if (pattern == p_pattern) + ERR_FAIL_COND_V(p_pattern.length() == 0, FAILED); + + if (pattern == p_pattern && root) return OK; clear(); @@ -1421,7 +1423,7 @@ void RegEx::clear() { if (root) memdelete(root); - pattern.clear(); + root = NULL; group_names.clear(); lookahead_depth = 0; } @@ -1494,5 +1496,7 @@ void RegEx::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_pattern"),&RegEx::get_pattern); ObjectTypeDB::bind_method(_MD("get_group_count"),&RegEx::get_group_count); ObjectTypeDB::bind_method(_MD("get_names"),&RegEx::get_names); + + ADD_PROPERTY(PropertyInfo(Variant::STRING, "pattern"), _SCS("compile"), _SCS("get_pattern")); } diff --git a/modules/regex/regex.h b/modules/regex/regex.h index 8d31b84773..803aa72b3f 100644 --- a/modules/regex/regex.h +++ b/modules/regex/regex.h @@ -78,9 +78,9 @@ public: }; -class RegEx : public Reference { +class RegEx : public Resource { - OBJ_TYPE(RegEx, Reference); + OBJ_TYPE(RegEx, Resource); RegExNode* root; Vector<Variant> group_names; |