mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
GDScript: Allow is
operator to test built-in types
This commit is contained in:
parent
653b4829f1
commit
4b974a36b7
5 changed files with 75 additions and 3 deletions
|
@ -191,6 +191,7 @@ static String _get_var_type(const Variant *p_type) {
|
|||
static const void *switch_table_ops[] = { \
|
||||
&&OPCODE_OPERATOR, \
|
||||
&&OPCODE_EXTENDS_TEST, \
|
||||
&&OPCODE_IS_BUILTIN, \
|
||||
&&OPCODE_SET, \
|
||||
&&OPCODE_GET, \
|
||||
&&OPCODE_SET_NAMED, \
|
||||
|
@ -536,6 +537,21 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_IS_BUILTIN) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
|
||||
GET_VARIANT_PTR(value, 1);
|
||||
Variant::Type var_type = (Variant::Type)_code_ptr[ip + 2];
|
||||
GET_VARIANT_PTR(dst, 3);
|
||||
|
||||
GD_ERR_BREAK(var_type < 0 || var_type >= Variant::VARIANT_MAX);
|
||||
|
||||
*dst = value->get_type() == var_type;
|
||||
ip += 4;
|
||||
}
|
||||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_SET) {
|
||||
|
||||
CHECK_SPACE(3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue