summaryrefslogtreecommitdiff
path: root/core/variant_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/variant_parser.cpp')
-rw-r--r--core/variant_parser.cpp54
1 files changed, 28 insertions, 26 deletions
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 402c8d41da..a2ecb1516d 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -27,11 +27,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "variant_parser.h"
+
#include "io/resource_loader.h"
#include "os/keyboard.h"
-
CharType VariantParser::StreamFile::get_char() {
return f->get_8();
@@ -430,7 +430,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String>& strings,
Token token;
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_PARENTHESIS_OPEN) {
- r_err_str="Expected '(' in old-style engine.cfg construct";
+ r_err_str="Expected '(' in old-style godot.cfg construct";
return ERR_PARSE_ERROR;
}
@@ -442,7 +442,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String>& strings,
CharType c=p_stream->get_char();
if (p_stream->is_eof()) {
- r_err_str="Unexpected EOF while parsing old-style engine.cfg construct";
+ r_err_str="Unexpected EOF while parsing old-style godot.cfg construct";
return ERR_PARSE_ERROR;
}
@@ -1328,7 +1328,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
value=arr;
return OK;
- } else if (id=="key") { // compatibility with engine.cfg
+ } else if (id=="key") { // compatibility with godot.cfg
Vector<String> params;
Error err = _parse_enginecfg(p_stream,params,line,r_err_str);
@@ -1364,7 +1364,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
value=ie;
return OK;
- } else if (id=="mbutton") { // compatibility with engine.cfg
+ } else if (id=="mbutton") { // compatibility with godot.cfg
Vector<String> params;
Error err = _parse_enginecfg(p_stream,params,line,r_err_str);
@@ -1379,7 +1379,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
value=ie;
return OK;
- } else if (id=="jbutton") { // compatibility with engine.cfg
+ } else if (id=="jbutton") { // compatibility with godot.cfg
Vector<String> params;
Error err = _parse_enginecfg(p_stream,params,line,r_err_str);
@@ -1394,7 +1394,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
value=ie;
return OK;
- } else if (id=="jaxis") { // compatibility with engine.cfg
+ } else if (id=="jaxis") { // compatibility with godot.cfg
Vector<String> params;
Error err = _parse_enginecfg(p_stream,params,line,r_err_str);
@@ -1412,19 +1412,19 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
value= ie;
return OK;
- } else if (id=="img") { // compatibility with engine.cfg
+ } else if (id=="img") { // compatibility with godot.cfg
- Token token;
+ Token token; // FIXME: no need for this declaration? the first argument in line 509 is a Token& token.
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_PARENTHESIS_OPEN) {
- r_err_str="Expected '(' in old-style engine.cfg construct";
+ r_err_str="Expected '(' in old-style godot.cfg construct";
return ERR_PARSE_ERROR;
}
while(true) {
CharType c = p_stream->get_char();
if (p_stream->is_eof()) {
- r_err_str="Unexpected EOF in old style engine.cfg img()";
+ r_err_str="Unexpected EOF in old style godot.cfg img()";
return ERR_PARSE_ERROR;
}
if (c==')')
@@ -1873,7 +1873,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
String str=p_variant;
- str="\""+str.c_escape()+"\"";
+ str="\""+str.c_escape_multiline()+"\"";
p_store_string_func(p_store_string_ud, str );
} break;
case Variant::VECTOR2: {
@@ -1989,7 +1989,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<uint8_t> data = img.get_data();
int len = data.size();
PoolVector<uint8_t>::Read r = data.read();
- const uint8_t *ptr=r.ptr();;
+ const uint8_t *ptr=r.ptr();
for (int i=0;i<len;i++) {
if (i>0)
@@ -2091,20 +2091,22 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
dict.get_key_list(&keys);
keys.sort();
- p_store_string_func(p_store_string_ud,"{ ");
+ p_store_string_func(p_store_string_ud,"{\n");
for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
- //if (!_check_type(dict[E->get()]))
- // continue;
+ /*
+ if (!_check_type(dict[E->get()]))
+ continue;
+ */
write(E->get(),p_store_string_func,p_store_string_ud,p_encode_res_func,p_encode_res_ud);
- p_store_string_func(p_store_string_ud,":");
+ p_store_string_func(p_store_string_ud,": ");
write(dict[E->get()],p_store_string_func,p_store_string_ud,p_encode_res_func,p_encode_res_ud);
if (E->next())
- p_store_string_func(p_store_string_ud,", ");
+ p_store_string_func(p_store_string_ud,",\n");
}
- p_store_string_func(p_store_string_ud," }");
+ p_store_string_func(p_store_string_ud,"\n}");
} break;
@@ -2131,7 +2133,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<uint8_t> data = p_variant;
int len = data.size();
PoolVector<uint8_t>::Read r = data.read();
- const uint8_t *ptr=r.ptr();;
+ const uint8_t *ptr=r.ptr();
for (int i=0;i<len;i++) {
if (i>0)
@@ -2150,7 +2152,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<int> data = p_variant;
int len = data.size();
PoolVector<int>::Read r = data.read();
- const int *ptr=r.ptr();;
+ const int *ptr=r.ptr();
for (int i=0;i<len;i++) {
@@ -2170,7 +2172,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<real_t> data = p_variant;
int len = data.size();
PoolVector<real_t>::Read r = data.read();
- const real_t *ptr=r.ptr();;
+ const real_t *ptr=r.ptr();
for (int i=0;i<len;i++) {
@@ -2188,7 +2190,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<String> data = p_variant;
int len = data.size();
PoolVector<String>::Read r = data.read();
- const String *ptr=r.ptr();;
+ const String *ptr=r.ptr();
String s;
//write_string("\n");
@@ -2211,7 +2213,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<Vector2> data = p_variant;
int len = data.size();
PoolVector<Vector2>::Read r = data.read();
- const Vector2 *ptr=r.ptr();;
+ const Vector2 *ptr=r.ptr();
for (int i=0;i<len;i++) {
@@ -2229,7 +2231,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<Vector3> data = p_variant;
int len = data.size();
PoolVector<Vector3>::Read r = data.read();
- const Vector3 *ptr=r.ptr();;
+ const Vector3 *ptr=r.ptr();
for (int i=0;i<len;i++) {
@@ -2248,7 +2250,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<Color> data = p_variant;
int len = data.size();
PoolVector<Color>::Read r = data.read();
- const Color *ptr=r.ptr();;
+ const Color *ptr=r.ptr();
for (int i=0;i<len;i++) {