Add a const call mode to Object, Variant and Script.

For this to work safely (user not call queue_free or something in the expression), a const call mode was added to Object and Variant (and optionally Script).

This mode ensures only const functions can be called, making it safe to use from the editor.

Co-Authored-By: reduz <reduzio@gmail.com>
This commit is contained in:
K. S. Ernest (iFire) Lee 2022-06-27 13:10:04 -07:00
parent c41e4b10c3
commit 9ddebc0c22
23 changed files with 179 additions and 53 deletions

View file

@ -1196,7 +1196,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
String whitespace = line.substr(0, line.size() - line.strip_edges(true, false).size()); //extract the whitespace at the beginning
if (expression.parse(line) == OK) {
Variant result = expression.execute(Array(), Variant(), false);
Variant result = expression.execute(Array(), Variant(), false, true);
if (expression.get_error_text().is_empty()) {
results.push_back(whitespace + result.get_construct_string());
} else {