summaryrefslogtreecommitdiff
path: root/modules/gdscript/gd_parser.cpp
diff options
context:
space:
mode:
authoreska <eska@eska.me>2015-12-11 15:15:57 +0100
committereska <eska@eska.me>2015-12-14 17:32:31 +0100
commit897cf2140c6e11f8d1ba5adfd00efd3aa1ca2121 (patch)
treea3718c670eebe90014ad81da3773af62aa88ed70 /modules/gdscript/gd_parser.cpp
parentef0c05430ce9ff0adc031c4d9fbc950b88547a4f (diff)
Add GDScript export hint for named bit flags
Syntax: `export( int, FLAGS, "A Flag", "Another Flag" ) var flags`
Diffstat (limited to 'modules/gdscript/gd_parser.cpp')
-rw-r--r--modules/gdscript/gd_parser.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 20fe207ac1..4339a13edf 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -2381,10 +2381,48 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint=PROPERTY_HINT_ALL_FLAGS;
tokenizer->advance();
- if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
- _set_error("Expected ')' in hint.");
+
+ if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ break;
+ }
+ if (tokenizer->get_token()!=GDTokenizer::TK_COMMA)
+ {
+ _set_error("Expected ')' or ',' in bit flags hint.");
return;
}
+
+ current_export.hint=PROPERTY_HINT_FLAGS;
+ tokenizer->advance();
+
+ bool first = true;
+ while(true) {
+
+ if (tokenizer->get_token()!=GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type()!=Variant::STRING) {
+ current_export=PropertyInfo();
+ _set_error("Expected a string constant in named bit flags hint.");
+ return;
+ }
+
+ String c = tokenizer->get_token_constant();
+ if (!first)
+ current_export.hint_string+=",";
+ else
+ first=false;
+
+ current_export.hint_string+=c.xml_escape();
+
+ tokenizer->advance();
+ if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE)
+ break;
+
+ if (tokenizer->get_token()!=GDTokenizer::TK_COMMA) {
+ current_export=PropertyInfo();
+ _set_error("Expected ')' or ',' in named bit flags hint.");
+ return;
+ }
+ tokenizer->advance();
+ }
+
break;
}