/**************************************************************************/ /* marshalls.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #include "marshalls.h" #include "core/io/resource_loader.h" #include "core/object/ref_counted.h" #include "core/object/script_language.h" #include #include void EncodedObjectAsID::_bind_methods() { ClassDB::bind_method(D_METHOD("set_object_id", "id"), &EncodedObjectAsID::set_object_id); ClassDB::bind_method(D_METHOD("get_object_id"), &EncodedObjectAsID::get_object_id); ADD_PROPERTY(PropertyInfo(Variant::INT, "object_id"), "set_object_id", "get_object_id"); } void EncodedObjectAsID::set_object_id(ObjectID p_id) { id = p_id; } ObjectID EncodedObjectAsID::get_object_id() const { return id; } #define ERR_FAIL_ADD_OF(a, b, err) ERR_FAIL_COND_V(((int32_t)(b)) < 0 || ((int32_t)(a)) < 0 || ((int32_t)(a)) > INT_MAX - ((int32_t)(b)), err) #define ERR_FAIL_MUL_OF(a, b, err) ERR_FAIL_COND_V(((int32_t)(a)) < 0 || ((int32_t)(b)) <= 0 || ((int32_t)(a)) > INT_MAX / ((int32_t)(b)), err) // Byte 0: `Variant::Type`, byte 1: unused, bytes 2 and 3: additional data. #define HEADER_TYPE_MASK 0xFF // For `Variant::INT`, `Variant::FLOAT` and other math types. #define HEADER_DATA_FLAG_64 (1 << 16) // For `Variant::OBJECT`. #define HEADER_DATA_FLAG_OBJECT_AS_ID (1 << 16) // For `Variant::ARRAY`. // Occupies bits 16 and 17. #define HEADER_DATA_FIELD_TYPED_ARRAY_MASK (0b11 << 16) #define HEADER_DATA_FIELD_TYPED_ARRAY_SHIFT 16 // For `Variant::DICTIONARY`. // Occupies bits 16 and 17. #define HEADER_DATA_FIELD_TYPED_DICTIONARY_KEY_MASK (0b11 << 16) #define HEADER_DATA_FIELD_TYPED_DICTIONARY_KEY_SHIFT 16 // Occupies bits 18 and 19. #define HEADER_DATA_FIELD_TYPED_DICTIONARY_VALUE_MASK (0b11 << 18) #define HEADER_DATA_FIELD_TYPED_DICTIONARY_VALUE_SHIFT 18 enum ContainerTypeKind { CONTAINER_TYPE_KIND_NONE = 0b00, CONTAINER_TYPE_KIND_BUILTIN = 0b01, CONTAINER_TYPE_KIND_CLASS_NAME = 0b10, CONTAINER_TYPE_KIND_SCRIPT = 0b11, }; struct ContainerType { Variant::Type builtin_type = Variant::NIL; StringName class_name; Ref