mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
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:
parent
c41e4b10c3
commit
9ddebc0c22
23 changed files with 179 additions and 53 deletions
|
|
@ -2278,6 +2278,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
|||
push_error(vformat(R"(Too few arguments for %s constructor. Received %d but expected %d.)", Variant::get_type_name(builtin_type), p_call->arguments.size(), err.expected), p_call);
|
||||
break;
|
||||
case Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL:
|
||||
case Callable::CallError::CALL_ERROR_METHOD_NOT_CONST:
|
||||
break; // Can't happen in a builtin constructor.
|
||||
case Callable::CallError::CALL_OK:
|
||||
p_call->is_constant = true;
|
||||
|
|
@ -2380,6 +2381,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
|||
case Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS:
|
||||
push_error(vformat(R"*(Too few arguments for "%s()" call. Expected at least %d but received %d.)*", function_name, err.expected, p_call->arguments.size()), p_call);
|
||||
break;
|
||||
case Callable::CallError::CALL_ERROR_METHOD_NOT_CONST:
|
||||
case Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL:
|
||||
break; // Can't happen in a builtin constructor.
|
||||
case Callable::CallError::CALL_OK:
|
||||
|
|
@ -2422,6 +2424,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
|||
case Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS:
|
||||
push_error(vformat(R"*(Too few arguments for "%s()" call. Expected at least %d but received %d.)*", function_name, err.expected, p_call->arguments.size()), p_call);
|
||||
break;
|
||||
case Callable::CallError::CALL_ERROR_METHOD_NOT_CONST:
|
||||
case Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL:
|
||||
break; // Can't happen in a builtin constructor.
|
||||
case Callable::CallError::CALL_OK:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue