Use initializer list in Arrays

This commit is contained in:
kobewi
2024-03-22 22:53:26 +01:00
parent 594d64ec24
commit 75881f8322
72 changed files with 347 additions and 947 deletions

View File

@ -36,8 +36,7 @@
#define CHECK_END(arr, expected, what) ERR_FAIL_COND_V_MSG((uint32_t)arr.size() > (uint32_t)expected, false, String("Malformed ") + what + " message from script debugger, message too long. Expected size: " + itos(expected) + ", actual size: " + itos(arr.size()))
Array DebuggerMarshalls::ScriptStackDump::serialize() {
Array arr;
arr.push_back(frames.size() * 3);
Array arr = { frames.size() * 3 };
for (const ScriptLanguage::StackInfo &frame : frames) {
arr.push_back(frame.file);
arr.push_back(frame.line);
@ -64,10 +63,7 @@ bool DebuggerMarshalls::ScriptStackDump::deserialize(const Array &p_arr) {
}
Array DebuggerMarshalls::ScriptStackVariable::serialize(int max_size) {
Array arr;
arr.push_back(name);
arr.push_back(type);
arr.push_back(value.get_type());
Array arr = { name, type, value.get_type() };
Variant var = value;
if (value.get_type() == Variant::OBJECT && value.get_validated_object() == nullptr) {
@ -99,20 +95,20 @@ bool DebuggerMarshalls::ScriptStackVariable::deserialize(const Array &p_arr) {
}
Array DebuggerMarshalls::OutputError::serialize() {
Array arr;
arr.push_back(hr);
arr.push_back(min);
arr.push_back(sec);
arr.push_back(msec);
arr.push_back(source_file);
arr.push_back(source_func);
arr.push_back(source_line);
arr.push_back(error);
arr.push_back(error_descr);
arr.push_back(warning);
unsigned int size = callstack.size();
Array arr = {
hr,
min,
sec, msec,
source_file,
source_func,
source_line,
error,
error_descr,
warning,
size * 3
};
const ScriptLanguage::StackInfo *r = callstack.ptr();
arr.push_back(size * 3);
for (int i = 0; i < callstack.size(); i++) {
arr.push_back(r[i].file);
arr.push_back(r[i].func);

View File

@ -149,8 +149,7 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, bo
singleton = memnew(RemoteDebugger(Ref<RemoteDebuggerPeer>(peer)));
script_debugger = memnew(ScriptDebugger);
// Notify editor of our pid (to allow focus stealing).
Array msg;
msg.push_back(OS::get_singleton()->get_process_id());
Array msg = { OS::get_singleton()->get_process_id() };
singleton->send_message("set_pid", msg);
}
if (!singleton) {

View File

@ -95,10 +95,7 @@ public:
};
Error RemoteDebugger::_put_msg(const String &p_message, const Array &p_data) {
Array msg;
msg.push_back(p_message);
msg.push_back(Thread::get_caller_id());
msg.push_back(p_data);
Array msg = { p_message, Thread::get_caller_id(), p_data };
Error err = peer->put_message(msg);
if (err != OK) {
n_messages_dropped++;
@ -235,9 +232,7 @@ void RemoteDebugger::flush_output() {
types.push_back(MESSAGE_TYPE_LOG);
}
Array arr;
arr.push_back(strings);
arr.push_back(types);
Array arr = { strings, types };
_put_msg("output", arr);
output_strings.clear();
}
@ -418,11 +413,12 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
const String error_str = script_lang ? script_lang->debug_get_error() : "";
if (can_break) {
Array msg;
msg.push_back(p_can_continue);
msg.push_back(error_str);
msg.push_back(script_lang->debug_get_stack_level_count() > 0);
msg.push_back(Thread::get_caller_id());
Array msg = {
p_can_continue,
error_str,
script_lang->debug_get_stack_level_count() > 0,
Thread::get_caller_id()
};
if (allow_focus_steal_fn) {
allow_focus_steal_fn();
}
@ -514,8 +510,7 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
script_lang->debug_get_globals(&globals, &globals_vals);
ERR_FAIL_COND(globals.size() != globals_vals.size());
Array var_size;
var_size.push_back(local_vals.size() + member_vals.size() + globals_vals.size());
Array var_size = { local_vals.size() + member_vals.size() + globals_vals.size() };
send_message("stack_frame_vars", var_size);
_send_stack_vars(locals, local_vals, 0);
_send_stack_vars(members, member_vals, 1);