2
2
3
3
#include < classes/json.hpp>
4
4
5
- bool JvmUserConfiguration::parse_configuration_json (const String& json_string, JvmUserConfiguration& json_config) {
5
+ bool JvmUserConfiguration::parse_configuration_json (const godot:: String& json_string, JvmUserConfiguration& json_config) {
6
6
bool is_invalid = false ;
7
7
godot::JSON json;
8
8
godot::Error error {json.parse (json_string)};
9
- Variant result {json.get_data ()};
9
+ godot:: Variant result {json.get_data ()};
10
10
11
- if (error != godot::OK || result.get_type () != Variant::DICTIONARY) {
11
+ if (error != godot::OK || result.get_type () != godot:: Variant::DICTIONARY) {
12
12
JVM_ERR_FAIL_V_MSG (true , " Error parsing Godot Kotlin configuration file! Falling back to default configuration" );
13
13
}
14
14
15
15
godot::Dictionary json_dict = result;
16
16
if (json_dict.has (VM_TYPE_JSON_IDENTIFIER)) {
17
- String value = json_dict[VM_TYPE_JSON_IDENTIFIER];
17
+ godot:: String value = json_dict[VM_TYPE_JSON_IDENTIFIER];
18
18
JVM_DEV_VERBOSE (" Value for json argument: %s -> %s" , VM_TYPE_JSON_IDENTIFIER, value);
19
19
if (value == AUTO_STRING) {
20
20
json_config.vm_type = jni::JvmType::NONE;
@@ -31,7 +31,7 @@ bool JvmUserConfiguration::parse_configuration_json(const String& json_string, J
31
31
json_dict.erase (VM_TYPE_JSON_IDENTIFIER);
32
32
}
33
33
if (json_dict.has (USE_DEBUG_JSON_IDENTIFIER)) {
34
- String boolean = json_dict[USE_DEBUG_JSON_IDENTIFIER];
34
+ godot:: String boolean = json_dict[USE_DEBUG_JSON_IDENTIFIER];
35
35
JVM_DEV_VERBOSE (" Value for json argument: %s -> %s" , USE_DEBUG_JSON_IDENTIFIER, boolean);
36
36
if (boolean == TRUE_STRING) {
37
37
json_config.use_debug = true ;
@@ -55,7 +55,7 @@ bool JvmUserConfiguration::parse_configuration_json(const String& json_string, J
55
55
json_dict.erase (DEBUG_PORT_JSON_IDENTIFIER);
56
56
}
57
57
if (json_dict.has (DEBUG_ADDRESS_JSON_IDENTIFIER)) {
58
- String address = json_dict[DEBUG_ADDRESS_JSON_IDENTIFIER];
58
+ godot:: String address = json_dict[DEBUG_ADDRESS_JSON_IDENTIFIER];
59
59
JVM_DEV_VERBOSE (" Value for json argument: %s -> %s" , DEBUG_ADDRESS_JSON_IDENTIFIER, address);
60
60
if (address.is_valid_ip_address () || address == " *" ) {
61
61
json_config.jvm_debug_address = address;
@@ -66,7 +66,7 @@ bool JvmUserConfiguration::parse_configuration_json(const String& json_string, J
66
66
json_dict.erase (DEBUG_ADDRESS_JSON_IDENTIFIER);
67
67
}
68
68
if (json_dict.has (WAIT_FOR_DEBUGGER_JSON_IDENTIFIER)) {
69
- String boolean = json_dict[WAIT_FOR_DEBUGGER_JSON_IDENTIFIER];
69
+ godot:: String boolean = json_dict[WAIT_FOR_DEBUGGER_JSON_IDENTIFIER];
70
70
JVM_DEV_VERBOSE (" Value for json argument: %s -> %s" , WAIT_FOR_DEBUGGER_JSON_IDENTIFIER, boolean);
71
71
if (boolean == TRUE_STRING) {
72
72
json_config.wait_for_debugger = true ;
@@ -101,7 +101,7 @@ bool JvmUserConfiguration::parse_configuration_json(const String& json_string, J
101
101
json_dict.erase (MAX_STRING_SIZE_JSON_IDENTIFIER);
102
102
}
103
103
if (json_dict.has (DISABLE_GC_JSON_IDENTIFIER)) {
104
- String boolean = json_dict[DISABLE_GC_JSON_IDENTIFIER];
104
+ godot:: String boolean = json_dict[DISABLE_GC_JSON_IDENTIFIER];
105
105
JVM_DEV_VERBOSE (" Value for json argument: %s -> %s" , DISABLE_GC_JSON_IDENTIFIER, boolean);
106
106
if (boolean == TRUE_STRING) {
107
107
json_config.disable_gc = true ;
@@ -120,7 +120,7 @@ bool JvmUserConfiguration::parse_configuration_json(const String& json_string, J
120
120
}
121
121
122
122
if (json_dict.has (VERSION_JSON_IDENTIFIER)) {
123
- String version {json_dict[VERSION_JSON_IDENTIFIER]};
123
+ godot:: String version {json_dict[VERSION_JSON_IDENTIFIER]};
124
124
JVM_DEV_VERBOSE (" Value for json argument: %s -> %s" , VERSION_JSON_IDENTIFIER, version);
125
125
if (version != JSON_ARGUMENT_VERSION) {
126
126
JVM_LOG_WARNING (" Your existing jvm json configuration file was made for an older version of this binding. A "
@@ -136,8 +136,8 @@ bool JvmUserConfiguration::parse_configuration_json(const String& json_string, J
136
136
if (!json_dict.is_empty ()) {
137
137
godot::Array keys = json_dict.keys ();
138
138
for (int i = 0 ; i < keys.size (); i++) {
139
- String key = keys[i];
140
- String value = json_dict[key];
139
+ godot:: String key = keys[i];
140
+ godot:: String value = json_dict[key];
141
141
JVM_LOG_WARNING (" Invalid json configuration argument name: %s" , key);
142
142
}
143
143
is_invalid = true ;
@@ -146,11 +146,11 @@ bool JvmUserConfiguration::parse_configuration_json(const String& json_string, J
146
146
return is_invalid;
147
147
}
148
148
149
- String JvmUserConfiguration::export_configuration_to_json (const JvmUserConfiguration& configuration) {
149
+ godot:: String JvmUserConfiguration::export_configuration_to_json (const JvmUserConfiguration& configuration) {
150
150
// This function assumes all values are valid.
151
151
godot::Dictionary json;
152
152
153
- String vm_type_value;
153
+ godot:: String vm_type_value;
154
154
switch (configuration.vm_type ) {
155
155
case jni::JvmType::NONE:
156
156
vm_type_value = AUTO_STRING;
@@ -184,7 +184,7 @@ String JvmUserConfiguration::export_configuration_to_json(const JvmUserConfigura
184
184
return godot::JSON::stringify (json, " " , true , false );
185
185
}
186
186
187
- godot::Error split_argument (const String& cmd_arg, String& identifier, String& value) {
187
+ godot::Error split_argument (const godot:: String& cmd_arg, godot:: String& identifier, godot:: String& value) {
188
188
godot::PackedStringArray jvm_debug_split {cmd_arg.split (" =" )};
189
189
190
190
if (jvm_debug_split.size () == 2 ) {
@@ -199,7 +199,7 @@ godot::Error split_argument(const String& cmd_arg, String& identifier, String& v
199
199
return godot::OK;
200
200
}
201
201
202
- bool get_cmd_bool_or_default (const String& value, bool default_if_empty) {
202
+ bool get_cmd_bool_or_default (const godot:: String& value, bool default_if_empty) {
203
203
if (value.is_empty ()) {
204
204
return default_if_empty;
205
205
} else if (value == TRUE_STRING) {
@@ -211,15 +211,15 @@ bool get_cmd_bool_or_default(const String& value, bool default_if_empty) {
211
211
}
212
212
}
213
213
214
- void JvmUserConfiguration::parse_command_line (const List<String>& args, godot::HashMap<String, Variant>& configuration_map) {
214
+ void JvmUserConfiguration::parse_command_line (const godot:: List<godot:: String>& args, godot::HashMap<godot:: String, godot:: Variant>& configuration_map) {
215
215
// We use a HashMap instead of JvmUserConfiguration so we can still make the difference between a
216
216
// JvmUserConfiguration default value and the absence of the matching command line argument. Knowing this is
217
217
// essential when merging with the json configuration later.
218
218
219
219
// Keep in sync with https://godot-kotl.in/en/latest/advanced/commandline-args/
220
220
for (const auto & arg : args) {
221
- String identifier;
222
- String value;
221
+ godot:: String identifier;
222
+ godot:: String value;
223
223
if (split_argument (arg, identifier, value) != godot::Error::OK) { continue ; }
224
224
225
225
if (identifier == VM_TYPE_CMD_IDENTIFIER) {
@@ -272,7 +272,7 @@ void JvmUserConfiguration::parse_command_line(const List<String>& args, godot::H
272
272
configuration_map[DISABLE_GC_CMD_IDENTIFIER] = get_cmd_bool_or_default (value, TRUE_STRING);
273
273
} else if (identifier == JVM_ARGUMENTS_CMD_IDENTIFIER) {
274
274
godot::Array arr {};
275
- for (String jvm_arg: value.split (" " )){
275
+ for (godot:: String jvm_arg: value.split (" " )){
276
276
arr.append (arg);
277
277
}
278
278
configuration_map[JVM_ARGUMENTS_CMD_IDENTIFIER] = arr;
@@ -285,11 +285,11 @@ void JvmUserConfiguration::parse_command_line(const List<String>& args, godot::H
285
285
}
286
286
287
287
template <typename T>
288
- void replace_json_value_by_cmd_value (const godot::HashMap<String, Variant>& map, T& json_value, const String& cmd_key) {
288
+ void replace_json_value_by_cmd_value (const godot::HashMap<godot:: String, godot:: Variant>& map, T& json_value, const godot:: String& cmd_key) {
289
289
if (map.has (cmd_key)) { json_value = godot::VariantCaster<T>::cast (map[cmd_key]); }
290
290
}
291
291
292
- void JvmUserConfiguration::merge_with_command_line (JvmUserConfiguration& json_config, const godot::HashMap<String, Variant>& cmd_map) {
292
+ void JvmUserConfiguration::merge_with_command_line (JvmUserConfiguration& json_config, const godot::HashMap<godot:: String, godot:: Variant>& cmd_map) {
293
293
replace_json_value_by_cmd_value (cmd_map, json_config.vm_type , VM_TYPE_CMD_IDENTIFIER);
294
294
replace_json_value_by_cmd_value (cmd_map, json_config.jvm_debug_port , DEBUG_PORT_CMD_IDENTIFIER);
295
295
replace_json_value_by_cmd_value (cmd_map, json_config.jvm_debug_address , DEBUG_ADDRESS_CMD_IDENTIFIER);
0 commit comments