Path: blob/master/thirdparty/metal-cpp/Foundation/NSDefines.hpp
21066 views
//-------------------------------------------------------------------------------------------------------------------------------------------------------------1//2// Foundation/NSDefines.hpp3//4// Copyright 2020-2024 Apple Inc.5//6// Licensed under the Apache License, Version 2.0 (the "License");7// you may not use this file except in compliance with the License.8// You may obtain a copy of the License at9//10// http://www.apache.org/licenses/LICENSE-2.011//12// Unless required by applicable law or agreed to in writing, software13// distributed under the License is distributed on an "AS IS" BASIS,14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15// See the License for the specific language governing permissions and16// limitations under the License.17//18//-------------------------------------------------------------------------------------------------------------------------------------------------------------1920#pragma once2122//-------------------------------------------------------------------------------------------------------------------------------------------------------------2324// Forward declarations to avoid conflicts with Godot types (String, Object, Error)25namespace NS {26class Array;27class Dictionary;28class Error;29class Object;30class String;31class URL;32} // namespace NS3334#define _NS_WEAK_IMPORT __attribute__((weak_import))35#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN36#define _NS_EXPORT __attribute__((visibility("hidden")))37#else38#define _NS_EXPORT __attribute__((visibility("default")))39#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN40#define _NS_EXTERN extern "C" _NS_EXPORT41#define _NS_INLINE inline __attribute__((always_inline))42#define _NS_PACKED __attribute__((packed))4344#define _NS_CONST(type, name) _NS_EXTERN type const name45#define _NS_ENUM(type, name) enum name : type46#define _NS_OPTIONS(type, name) \47using name = type; \48enum : name4950#define _NS_CAST_TO_UINT(value) static_cast<NS::UInteger>(value)51#define _NS_VALIDATE_SIZE(ns, name) static_assert(sizeof(ns::name) == sizeof(ns##name), "size mismatch " #ns "::" #name)52#define _NS_VALIDATE_ENUM(ns, name) static_assert(_NS_CAST_TO_UINT(ns::name) == _NS_CAST_TO_UINT(ns##name), "value mismatch " #ns "::" #name)5354//-------------------------------------------------------------------------------------------------------------------------------------------------------------555657