From 024737aebca49dc37c904dfb453ab263ba9e4548 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 24 May 2022 18:47:16 +0800 Subject: [PATCH] fixed #11195: Rename cc::optional, cc::any, cc::variant to ccstd::optional, ccstd::any, ccstd::variant (#11197) * Move Any.h/Optional.h/Variant.h to base/std and rename them to lowercase. * fixed #11195: Rename cc::optional, cc::any, cc::variant to ccstd::optional, ccstd::any, ccstd::variant * Format code. --- native/CMakeLists.txt | 6 +- native/cocos/3d/assets/Mesh.cpp | 52 +++--- native/cocos/3d/assets/Mesh.h | 26 +-- native/cocos/3d/assets/Morph.cpp | 2 - native/cocos/3d/assets/Morph.h | 16 +- native/cocos/3d/assets/MorphRendering.cpp | 4 +- native/cocos/3d/assets/MorphRendering.h | 6 +- native/cocos/3d/assets/Skeleton.h | 2 +- native/cocos/3d/assets/Types.h | 6 +- native/cocos/3d/misc/Buffer.cpp | 16 +- native/cocos/3d/misc/Buffer.h | 12 +- native/cocos/3d/misc/BufferBlob.cpp | 4 +- native/cocos/3d/misc/BufferBlob.h | 4 +- native/cocos/3d/misc/CreateMesh.cpp | 4 +- native/cocos/3d/misc/CreateMesh.h | 4 +- native/cocos/3d/models/BakedSkinningModel.cpp | 8 +- native/cocos/3d/models/BakedSkinningModel.h | 10 +- .../SkeletalAnimationUtils.cpp | 8 +- .../SkeletalAnimationUtils.h | 16 +- native/cocos/application/BaseGame.cpp | 56 +++---- native/cocos/audio/AudioEngine.cpp | 2 +- native/cocos/base/{Any.h => std/any.h} | 8 +- .../cocos/base/{Optional.h => std/optional.h} | 8 +- .../cocos/base/{Variant.h => std/variant.h} | 8 +- .../cocos/bindings/event/EventDispatcher.cpp | 15 +- native/cocos/bindings/event/EventDispatcher.h | 10 +- .../cocos/bindings/manual/jsb_conversions.h | 56 +++---- .../bindings/manual/jsb_conversions_spec.cpp | 24 +-- .../bindings/manual/jsb_conversions_spec.h | 30 ++-- native/cocos/core/DataView.cpp | 4 +- native/cocos/core/DataView.h | 4 +- native/cocos/core/TypedArray.cpp | 88 +++++----- native/cocos/core/TypedArray.h | 32 ++-- native/cocos/core/Types.h | 5 +- native/cocos/core/assets/Asset.cpp | 2 +- native/cocos/core/assets/Asset.h | 18 +-- native/cocos/core/assets/BufferAsset.cpp | 6 +- native/cocos/core/assets/BufferAsset.h | 4 +- native/cocos/core/assets/EffectAsset.cpp | 18 +-- native/cocos/core/assets/EffectAsset.h | 152 +++++++++--------- native/cocos/core/assets/ImageAsset.cpp | 6 +- native/cocos/core/assets/ImageAsset.h | 4 +- native/cocos/core/assets/Material.cpp | 34 ++-- native/cocos/core/assets/Material.h | 22 +-- native/cocos/core/assets/RenderTexture.cpp | 2 +- native/cocos/core/assets/RenderTexture.h | 6 +- native/cocos/core/assets/RenderingSubMesh.cpp | 4 +- native/cocos/core/assets/RenderingSubMesh.h | 18 +-- native/cocos/core/assets/SceneAsset.cpp | 2 +- native/cocos/core/assets/SceneAsset.h | 2 +- native/cocos/core/assets/Texture2D.cpp | 10 +- native/cocos/core/assets/Texture2D.h | 16 +- native/cocos/core/assets/TextureBase.cpp | 8 +- native/cocos/core/assets/TextureBase.h | 8 +- native/cocos/core/assets/TextureCube.cpp | 12 +- native/cocos/core/assets/TextureCube.h | 6 +- .../deserializer/EffectAssetDeserializer.cpp | 4 +- native/cocos/core/geometry/Intersect.cpp | 8 +- native/cocos/core/geometry/Spec.h | 10 +- native/cocos/core/platform/Debug.cpp | 14 +- native/cocos/core/platform/Debug.h | 20 +-- native/cocos/core/scene-graph/Node.h | 2 +- .../core/scene-graph/NodeEventProcessor.h | 6 +- native/cocos/engine/Engine.cpp | 4 +- .../platform/java/jni/glue/JniNativeGlue.h | 2 +- .../platform/linux/modules/SystemWindow.h | 5 +- .../cocos/platform/mac/modules/SystemWindow.h | 5 +- .../platform/win32/modules/SystemWindow.cpp | 4 +- .../platform/win32/modules/SystemWindow.h | 5 +- native/cocos/primitive/Box.cpp | 4 +- native/cocos/primitive/Box.h | 14 +- native/cocos/primitive/Capsule.cpp | 4 +- native/cocos/primitive/Capsule.h | 2 +- native/cocos/primitive/Circle.cpp | 4 +- native/cocos/primitive/Circle.h | 2 +- native/cocos/primitive/Cone.cpp | 2 +- native/cocos/primitive/Cone.h | 2 +- native/cocos/primitive/Cylinder.cpp | 4 +- native/cocos/primitive/Cylinder.h | 2 +- native/cocos/primitive/Plane.cpp | 2 +- native/cocos/primitive/Plane.h | 2 +- native/cocos/primitive/Primitive.cpp | 18 +-- native/cocos/primitive/Primitive.h | 8 +- native/cocos/primitive/PrimitiveDefine.h | 48 +++--- native/cocos/primitive/Quad.cpp | 2 +- native/cocos/primitive/Quad.h | 2 +- native/cocos/primitive/Sphere.cpp | 2 +- native/cocos/primitive/Sphere.h | 2 +- native/cocos/primitive/Torus.cpp | 2 +- native/cocos/primitive/Torus.h | 2 +- native/cocos/primitive/Transform.cpp | 4 +- native/cocos/primitive/Transform.h | 4 +- native/cocos/renderer/core/MaterialInstance.h | 2 +- native/cocos/renderer/core/PassInstance.cpp | 2 +- native/cocos/renderer/core/PassInstance.h | 4 +- native/cocos/renderer/core/PassUtils.cpp | 60 +++---- native/cocos/renderer/core/PassUtils.h | 8 +- native/cocos/renderer/core/ProgramLib.cpp | 52 +++--- native/cocos/renderer/core/ProgramLib.h | 4 +- .../cocos/renderer/core/TextureBufferPool.h | 8 +- native/cocos/renderer/gfx-gles3/GLES3Device.h | 2 +- .../renderer/pipeline/RenderBatchedQueue.cpp | 2 +- .../pipeline/RenderInstancedQueue.cpp | 4 +- .../renderer/pipeline/custom/GraphTypes.h | 10 +- .../pipeline/custom/LayoutGraphGraphs.h | 20 +-- .../pipeline/custom/RenderGraphGraphs.h | 18 +-- native/cocos/scene/Camera.h | 6 +- native/cocos/scene/Fog.cpp | 6 +- native/cocos/scene/Model.cpp | 6 +- native/cocos/scene/Model.h | 2 +- native/cocos/scene/Pass.cpp | 10 +- native/cocos/scene/Pass.h | 2 +- native/cocos/scene/RenderWindow.h | 4 +- native/cocos/scene/Skybox.cpp | 6 +- 114 files changed, 693 insertions(+), 688 deletions(-) rename native/cocos/base/{Any.h => std/any.h} (96%) rename native/cocos/base/{Optional.h => std/optional.h} (95%) rename native/cocos/base/{Variant.h => std/variant.h} (95%) diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index d9729146f9..28bccb19d6 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -289,7 +289,6 @@ endif() ##### base cocos_source_files( cocos/base/Agent.h - cocos/base/Any.h cocos/base/astc.cpp cocos/base/astc.h cocos/base/base64.cpp @@ -308,7 +307,6 @@ cocos_source_files( cocos/base/Locked.h cocos/base/Macros.h cocos/base/Object.h - cocos/base/Optional.h cocos/base/Ptr.h cocos/base/Random.h cocos/base/RefCounted.cpp @@ -325,7 +323,9 @@ cocos_source_files( cocos/base/ThreadPool.cpp cocos/base/ThreadPool.h cocos/base/TypeDef.h - cocos/base/Variant.h + cocos/base/std/any.h + cocos/base/std/optional.h + cocos/base/std/variant.h cocos/base/std/container/array.h cocos/base/std/container/deque.h cocos/base/std/container/list.h diff --git a/native/cocos/3d/assets/Mesh.cpp b/native/cocos/3d/assets/Mesh.cpp index 5b26bf23ab..b7210763b6 100644 --- a/native/cocos/3d/assets/Mesh.cpp +++ b/native/cocos/3d/assets/Mesh.cpp @@ -119,9 +119,9 @@ DataWritterCallback getWriter(DataView &dataView, gfx::Format format) { switch (info.type) { case gfx::FormatType::UNORM: { switch (stride) { - case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint8(offset, cc::get(value)); }; - case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint16(offset, cc::get(value)); }; - case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint32(offset, cc::get(value)); }; + case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint8(offset, ccstd::get(value)); }; + case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint16(offset, ccstd::get(value)); }; + case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint32(offset, ccstd::get(value)); }; default: break; } @@ -129,9 +129,9 @@ DataWritterCallback getWriter(DataView &dataView, gfx::Format format) { } case gfx::FormatType::SNORM: { switch (stride) { - case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt8(offset, cc::get(value)); }; - case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt16(offset, cc::get(value)); }; - case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt32(offset, cc::get(value)); }; + case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt8(offset, ccstd::get(value)); }; + case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt16(offset, ccstd::get(value)); }; + case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt32(offset, ccstd::get(value)); }; default: break; } @@ -139,9 +139,9 @@ DataWritterCallback getWriter(DataView &dataView, gfx::Format format) { } case gfx::FormatType::INT: { switch (stride) { - case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt8(offset, cc::get(value)); }; - case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt16(offset, cc::get(value)); }; - case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt32(offset, cc::get(value)); }; + case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt8(offset, ccstd::get(value)); }; + case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt16(offset, ccstd::get(value)); }; + case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setInt32(offset, ccstd::get(value)); }; default: break; } @@ -149,16 +149,16 @@ DataWritterCallback getWriter(DataView &dataView, gfx::Format format) { } case gfx::FormatType::UINT: { switch (stride) { - case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint8(offset, cc::get(value)); }; - case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint16(offset, cc::get(value)); }; - case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint32(offset, cc::get(value)); }; + case 1: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint8(offset, ccstd::get(value)); }; + case 2: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint16(offset, ccstd::get(value)); }; + case 4: return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setUint32(offset, ccstd::get(value)); }; default: break; } break; } case gfx::FormatType::FLOAT: { - return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setFloat32(offset, cc::get(value)); }; + return [&](uint32_t offset, const TypedArrayElementType &value) { dataView.setFloat32(offset, ccstd::get(value)); }; } default: break; @@ -171,12 +171,12 @@ DataWritterCallback getWriter(DataView &dataView, gfx::Format format) { Mesh::~Mesh() = default; -cc::any Mesh::getNativeAsset() const { +ccstd::any Mesh::getNativeAsset() const { return _data; //cjh FIXME: need copy? could be _data pointer? } -void Mesh::setNativeAsset(const cc::any &obj) { - auto *p = cc::any_cast(obj); +void Mesh::setNativeAsset(const ccstd::any &obj) { + auto *p = ccstd::any_cast(obj); if (p != nullptr) { _data = Uint8Array(p); } @@ -659,23 +659,23 @@ bool Mesh::merge(Mesh *mesh, const Mat4 *worldMatrix /* = nullptr */, bool valid if (idxStride == prim.indexView.value().stride) { switch (idxStride) { case 2: - cc::get(ibView).set(cc::get(srcIBView)); + ccstd::get(ibView).set(ccstd::get(srcIBView)); break; case 1: - cc::get(ibView).set(cc::get(srcIBView)); + ccstd::get(ibView).set(ccstd::get(srcIBView)); break; default: - cc::get(ibView).set(cc::get(srcIBView)); + ccstd::get(ibView).set(ccstd::get(srcIBView)); break; } } else { for (uint32_t n = 0; n < prim.indexView.value().count; ++n) { if (idxStride == 2) { - cc::get(ibView)[n] = static_cast(getTypedArrayValue(srcIBView, n)); + ccstd::get(ibView)[n] = static_cast(getTypedArrayValue(srcIBView, n)); } else if (idxStride == 1) { - cc::get(ibView)[n] = static_cast(getTypedArrayValue(srcIBView, n)); + ccstd::get(ibView)[n] = static_cast(getTypedArrayValue(srcIBView, n)); } else { - cc::get(ibView)[n] = getTypedArrayValue(srcIBView, n); + ccstd::get(ibView)[n] = getTypedArrayValue(srcIBView, n); } } } @@ -692,13 +692,13 @@ bool Mesh::merge(Mesh *mesh, const Mat4 *worldMatrix /* = nullptr */, bool valid } for (uint32_t n = 0; n < dstPrim.indexView.value().count; ++n) { if (idxStride == 2) { - cc::get(ibView)[prim.indexView->count + n] = + ccstd::get(ibView)[prim.indexView->count + n] = vertBatchCount + static_cast(getTypedArrayValue(dstIBView, n)); } else if (idxStride == 1) { - cc::get(ibView)[prim.indexView->count + n] = + ccstd::get(ibView)[prim.indexView->count + n] = vertBatchCount + static_cast(getTypedArrayValue(dstIBView, n)); } else { - cc::get(ibView)[prim.indexView->count + n] = + ccstd::get(ibView)[prim.indexView->count + n] = vertBatchCount + getTypedArrayValue(dstIBView, n); } } @@ -1069,7 +1069,7 @@ gfx::BufferList Mesh::createVertexBuffers(gfx::Device *gfxDevice, ArrayBuffer *d return buffers; } -void Mesh::initDefault(const cc::optional &uuid) { +void Mesh::initDefault(const ccstd::optional &uuid) { Super::initDefault(uuid); reset({}); } diff --git a/native/cocos/3d/assets/Mesh.h b/native/cocos/3d/assets/Mesh.h index a79570f6db..4701fb783b 100644 --- a/native/cocos/3d/assets/Mesh.h +++ b/native/cocos/3d/assets/Mesh.h @@ -25,9 +25,9 @@ #pragma once -#include "3d/assets/MorphRendering.h" #include "3d/assets/Morph.h" -#include "cocos/base/Optional.h" +#include "3d/assets/MorphRendering.h" +#include "base/std/optional.h" #include "core/assets/Asset.h" #include "core/geometry/AABB.h" #include "math/Mat4.h" @@ -56,7 +56,7 @@ public: * 交错排列是指在实际数据的缓冲区中,每个顶点的所有属性总是依次排列,并总是出现在下一个顶点的所有属性之前。 */ struct IVertexBundle { - cc::optional _padding; // NOTE: avoid jsb cache map + ccstd::optional _padding; // NOTE: avoid jsb cache map /** * @en The actual value for all vertex attributes. * You must use DataView to access the data. @@ -94,14 +94,14 @@ public: * @en The index data of the sub mesh * @zh 此子网格使用的索引数据。 */ - cc::optional indexView; + ccstd::optional indexView; /** * @en The joint map index in [[IStruct.jointMaps]]. Could be absent * @zh 此子网格使用的关节索引映射表在 [[IStruct.jointMaps]] 中的索引。 * 如未定义或指向的映射表不存在,则默认 VB 内所有关节索引数据直接对应骨骼资源数据。 */ - cc::optional jointMapIndex; + ccstd::optional jointMapIndex; }; struct IDynamicInfo { @@ -159,32 +159,32 @@ public: * @en The minimum position of all vertices in the mesh * @zh (各分量都)小于等于此网格任何顶点位置的最大位置。 */ - cc::optional minPosition; + ccstd::optional minPosition; /** * @en The maximum position of all vertices in the mesh * @zh (各分量都)大于等于此网格任何顶点位置的最小位置。 */ - cc::optional maxPosition; + ccstd::optional maxPosition; /** * @en The joint index map list. * @zh 此网格使用的关节索引映射关系列表,数组长度应为子模型中实际使用到的所有关节, * 每个元素都对应一个原骨骼资源里的索引,按子模型 VB 内的实际索引排列。 */ - cc::optional>> jointMaps; + ccstd::optional>> jointMaps; /** * @en The morph information of the mesh * @zh 网格的形变数据 */ - cc::optional morph; + ccstd::optional morph; /** * @en The specific data of the dynamic mesh * @zh 动态网格特有数据 */ - cc::optional dynamic; + ccstd::optional dynamic; }; struct ICreateInfo { @@ -204,8 +204,8 @@ public: Mesh() = default; ~Mesh() override; - cc::any getNativeAsset() const override; - void setNativeAsset(const cc::any &obj) override; + ccstd::any getNativeAsset() const override; + void setNativeAsset(const ccstd::any &obj) override; void setAssetData(cc::ArrayBuffer *data) { _data = Uint8Array(data); @@ -422,7 +422,7 @@ private: gfx::BufferList createVertexBuffers(gfx::Device *gfxDevice, ArrayBuffer *data); - void initDefault(const cc::optional &uuid) override; + void initDefault(const ccstd::optional &uuid) override; bool validate() const override; static TypedArray createTypedArrayWithGFXFormat(gfx::Format format, uint32_t count); diff --git a/native/cocos/3d/assets/Morph.cpp b/native/cocos/3d/assets/Morph.cpp index 6b664b479f..ddb2144a12 100644 --- a/native/cocos/3d/assets/Morph.cpp +++ b/native/cocos/3d/assets/Morph.cpp @@ -28,6 +28,4 @@ namespace cc { - - } // namespace cc diff --git a/native/cocos/3d/assets/Morph.h b/native/cocos/3d/assets/Morph.h index 4336fca30a..0749e93428 100644 --- a/native/cocos/3d/assets/Morph.h +++ b/native/cocos/3d/assets/Morph.h @@ -59,16 +59,16 @@ struct SubMeshMorph { * Attributes to morph. */ ccstd::vector attributes; - + /** * Targets. */ ccstd::vector targets; - + /** * Initial weights of each target. */ - cc::optional weights; + ccstd::optional weights; }; /** @@ -84,18 +84,18 @@ struct Morph { /** * Morph data of each sub-mesh. */ - ccstd::vector> subMeshMorphs; - + ccstd::vector> subMeshMorphs; + /** * Common initial weights of each sub-mesh. */ - cc::optional weights; - + ccstd::optional weights; + /** * Name of each target of each sub-mesh morph. * This field is only meaningful if every sub-mesh has the same number of targets. */ - cc::optional> targetNames; + ccstd::optional> targetNames; }; } // namespace cc diff --git a/native/cocos/3d/assets/MorphRendering.cpp b/native/cocos/3d/assets/MorphRendering.cpp index be9d192659..799dfbaee0 100644 --- a/native/cocos/3d/assets/MorphRendering.cpp +++ b/native/cocos/3d/assets/MorphRendering.cpp @@ -412,7 +412,7 @@ public: void adaptPipelineState(gfx::DescriptorSet *descriptorSet) override { for (const auto &attribute : _attributes) { const auto &attributeName = attribute.attributeName; - cc::optional binding; + ccstd::optional binding; if (attributeName == gfx::ATTR_NAME_POSITION) { binding = uint32_t{pipeline::POSITIONMORPH::BINDING}; } else if (attributeName == gfx::ATTR_NAME_NORMAL) { @@ -470,7 +470,7 @@ public: void adaptPipelineState(gfx::DescriptorSet *descriptorSet) override { for (const auto &attribute : *_attributes) { const auto &attributeName = attribute.attributeName; - cc::optional binding; + ccstd::optional binding; if (attributeName == gfx::ATTR_NAME_POSITION) { binding = uint32_t{pipeline::POSITIONMORPH::BINDING}; } else if (attributeName == gfx::ATTR_NAME_NORMAL) { diff --git a/native/cocos/3d/assets/MorphRendering.h b/native/cocos/3d/assets/MorphRendering.h index d7452de3eb..e489045708 100644 --- a/native/cocos/3d/assets/MorphRendering.h +++ b/native/cocos/3d/assets/MorphRendering.h @@ -54,16 +54,16 @@ public: * @param weights */ virtual void setWeights(index_t subMeshIndex, const MeshWeightsType &weights) = 0; - + /** * Adapts pipeline state to do the rendering. * @param subMeshIndex * @param pipelineState */ virtual void adaptPipelineState(index_t subMeshIndex, gfx::DescriptorSet *descriptorSet) = 0; - + virtual ccstd::vector requiredPatches(index_t subMeshIndex) = 0; - + /** * Destroy the rendering instance. */ diff --git a/native/cocos/3d/assets/Skeleton.h b/native/cocos/3d/assets/Skeleton.h index b9beb4f8ed..b63090adaa 100644 --- a/native/cocos/3d/assets/Skeleton.h +++ b/native/cocos/3d/assets/Skeleton.h @@ -85,7 +85,7 @@ public: private: ccstd::vector _joints; ccstd::vector _bindposes; - cc::optional> _invBindposes; + ccstd::optional> _invBindposes; uint64_t _hash{0}; }; diff --git a/native/cocos/3d/assets/Types.h b/native/cocos/3d/assets/Types.h index 3d85a7ce50..0245fd61f3 100644 --- a/native/cocos/3d/assets/Types.h +++ b/native/cocos/3d/assets/Types.h @@ -27,7 +27,7 @@ #include #include "base/std/container/string.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "core/TypedArray.h" namespace cc { @@ -37,13 +37,13 @@ using MeshWeightsType = ccstd::vector; * @en Array views for index buffer * @zh 允许存储索引的数组视图 */ -using IBArray = cc::variant; +using IBArray = ccstd::variant; template T getIBArrayValue(const IBArray &arr, uint32_t idx) { #define IBARRAY_GET_VALUE(type) \ do { \ - auto *p = cc::get_if(&arr); \ + auto *p = ccstd::get_if(&arr); \ if (p != nullptr) { \ return static_cast((*p)[idx]); \ } \ diff --git a/native/cocos/3d/misc/Buffer.cpp b/native/cocos/3d/misc/Buffer.cpp index ee6840049d..7353b8be1e 100644 --- a/native/cocos/3d/misc/Buffer.cpp +++ b/native/cocos/3d/misc/Buffer.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "3d/misc/Buffer.h" -#include "cocos/base/Variant.h" +#include "base/std/variant.h" namespace cc { @@ -53,15 +53,15 @@ ccstd::string getDataViewType(const gfx::FormatInfo &info) { } // namespace -using DataVariant = cc::variant; +using DataVariant = ccstd::variant; using MapBufferCallback = std::function; DataView mapBuffer(DataView &target, const MapBufferCallback &callback, - cc::optional aFormat, - cc::optional aOffset, - cc::optional aLength, - cc::optional aStride, + ccstd::optional aFormat, + ccstd::optional aOffset, + ccstd::optional aLength, + ccstd::optional aStride, DataView *out) { gfx::Format format = aFormat.has_value() ? aFormat.value() : gfx::Format::R32F; uint32_t offset = aOffset.has_value() ? aOffset.value() : 0; @@ -102,11 +102,11 @@ DataView mapBuffer(DataView &target, const uint32_t y = x + componentBytesLength * iComponent; if (isFloat) { float cur = target.getFloat32(y); - out->setFloat32(y, cc::get<1>(callback(cur, iComponent, target))); + out->setFloat32(y, ccstd::get<1>(callback(cur, iComponent, target))); } else { int32_t cur = target.readInt(intReader, y); // iComponent is usually more useful than y - (target.*intWritter)(y, cc::get<0>(callback(cur, iComponent, target))); + (target.*intWritter)(y, ccstd::get<0>(callback(cur, iComponent, target))); } } } diff --git a/native/cocos/3d/misc/Buffer.h b/native/cocos/3d/misc/Buffer.h index 35228644a9..6daef27264 100644 --- a/native/cocos/3d/misc/Buffer.h +++ b/native/cocos/3d/misc/Buffer.h @@ -25,7 +25,7 @@ #pragma once #include -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "core/DataView.h" #include "renderer/gfx-base/GFXDef.h" @@ -112,15 +112,15 @@ void writeBuffer(DataView &target, } } -using DataVariant = cc::variant; +using DataVariant = ccstd::variant; using MapBufferCallback = std::function; DataView mapBuffer(DataView &target, const MapBufferCallback &callback, - cc::optional aFormat, - cc::optional aOffset, - cc::optional aLength, - cc::optional aStride, + ccstd::optional aFormat, + ccstd::optional aOffset, + ccstd::optional aLength, + ccstd::optional aStride, DataView *out); } // namespace cc diff --git a/native/cocos/3d/misc/BufferBlob.cpp b/native/cocos/3d/misc/BufferBlob.cpp index cbdb945dbf..5ab564cfc3 100644 --- a/native/cocos/3d/misc/BufferBlob.cpp +++ b/native/cocos/3d/misc/BufferBlob.cpp @@ -50,9 +50,9 @@ ArrayBuffer::Ptr BufferBlob::getCombined() { uint32_t counter = 0; for (const auto &arrayBufferOrPadding : _arrayBufferOrPaddings) { - if (const auto *p = cc::get_if(&arrayBufferOrPadding)) { + if (const auto *p = ccstd::get_if(&arrayBufferOrPadding)) { counter += *p; - } else if (const auto *p = cc::get_if(&arrayBufferOrPadding)) { + } else if (const auto *p = ccstd::get_if(&arrayBufferOrPadding)) { result.set(*p, counter); counter += (*p)->byteLength(); } diff --git a/native/cocos/3d/misc/BufferBlob.h b/native/cocos/3d/misc/BufferBlob.h index efa1a7275e..17a7a01aae 100644 --- a/native/cocos/3d/misc/BufferBlob.h +++ b/native/cocos/3d/misc/BufferBlob.h @@ -24,7 +24,7 @@ ****************************************************************************/ #pragma once -#include "cocos/base/Variant.h" +#include "base/std/variant.h" #include "cocos/base/std/container/vector.h" #include "core/ArrayBuffer.h" @@ -41,7 +41,7 @@ public: ArrayBuffer::Ptr getCombined(); private: - ccstd::vector> _arrayBufferOrPaddings; + ccstd::vector> _arrayBufferOrPaddings; uint32_t _length{0}; }; diff --git a/native/cocos/3d/misc/CreateMesh.cpp b/native/cocos/3d/misc/CreateMesh.cpp index 009938252a..0bcf588fb3 100644 --- a/native/cocos/3d/misc/CreateMesh.cpp +++ b/native/cocos/3d/misc/CreateMesh.cpp @@ -213,7 +213,7 @@ Mesh::ICreateInfo MeshUtils::createMeshInfo(const IGeometry &geometry, const ICr bufferBlob.addBuffer(indexBuffer); } - cc::optional minPosition = geometry.minPos; + ccstd::optional minPosition = geometry.minPos; if (!minPosition.has_value() && options.calculateBounds.has_value() && options.calculateBounds.value()) { minPosition = Vec3(std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity()); for (uint32_t iVertex = 0; iVertex < vertCount; ++iVertex) { @@ -221,7 +221,7 @@ Mesh::ICreateInfo MeshUtils::createMeshInfo(const IGeometry &geometry, const ICr } } - cc::optional maxPosition = geometry.maxPos; + ccstd::optional maxPosition = geometry.maxPos; if (!maxPosition.has_value() && options.calculateBounds.has_value() && options.calculateBounds.value()) { maxPosition = Vec3(-std::numeric_limits::infinity(), -std::numeric_limits::infinity(), -std::numeric_limits::infinity()); for (uint32_t iVertex = 0; iVertex < vertCount; ++iVertex) { diff --git a/native/cocos/3d/misc/CreateMesh.h b/native/cocos/3d/misc/CreateMesh.h index f003cde1ed..8e1f192668 100644 --- a/native/cocos/3d/misc/CreateMesh.h +++ b/native/cocos/3d/misc/CreateMesh.h @@ -24,7 +24,7 @@ ****************************************************************************/ #pragma once -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "3d/assets/Mesh.h" #include "primitive/PrimitiveDefine.h" @@ -36,7 +36,7 @@ struct ICreateMeshOptions { * @en calculate mesh's aabb or not * @zh 是否计算模型的包围盒。 */ - cc::optional calculateBounds; + ccstd::optional calculateBounds; }; struct ICreateDynamicMeshOptions { diff --git a/native/cocos/3d/models/BakedSkinningModel.cpp b/native/cocos/3d/models/BakedSkinningModel.cpp index 6853f869d4..6ca6565cbe 100644 --- a/native/cocos/3d/models/BakedSkinningModel.cpp +++ b/native/cocos/3d/models/BakedSkinningModel.cpp @@ -66,7 +66,7 @@ void BakedSkinningModel::destroy() { if (_jointMedium.texture.has_value()) { CC_SAFE_DELETE(_jointMedium.texture.value()); } - applyJointTexture(cc::nullopt); + applyJointTexture(ccstd::nullopt); Super::destroy(); } @@ -128,7 +128,7 @@ void BakedSkinningModel::updateUBOs(uint32_t stamp) { } } -void BakedSkinningModel::applyJointTexture(const cc::optional &texture) { +void BakedSkinningModel::applyJointTexture(const ccstd::optional &texture) { auto oldTex = _jointMedium.texture; if (oldTex.has_value() && texture.has_value() && (&oldTex.value() != &texture.value())) { // _dataPoolManager->jointTexturePool->releaseHandle(oldTex.value()); @@ -202,8 +202,8 @@ void BakedSkinningModel::syncAnimInfoForJS(gfx::Buffer *buffer, const Float32Arr _jointMedium.animInfo.dirtyForJSB = &dirty[0]; } -void BakedSkinningModel::syncDataForJS(const ccstd::vector> &boundsInfo, - const cc::optional &modelBound, +void BakedSkinningModel::syncDataForJS(const ccstd::vector> &boundsInfo, + const ccstd::optional &modelBound, float jointTextureInfo0, float jointTextureInfo1, float jointTextureInfo2, diff --git a/native/cocos/3d/models/BakedSkinningModel.h b/native/cocos/3d/models/BakedSkinningModel.h index 9f1ccddb30..7930b6c9c0 100644 --- a/native/cocos/3d/models/BakedSkinningModel.h +++ b/native/cocos/3d/models/BakedSkinningModel.h @@ -43,9 +43,9 @@ class DataPoolManager; struct BakedJointInfo { IntrusivePtr buffer; Float32Array jointTextureInfo; - cc::optional texture; + ccstd::optional texture; IAnimInfo animInfo; - ccstd::vector> boundsInfo; + ccstd::vector> boundsInfo; }; class BakedSkinningModel final : public MorphModel { @@ -75,8 +75,8 @@ public: } void syncAnimInfoForJS(gfx::Buffer *buffer, const Float32Array &data, Uint8Array &dirty); - void syncDataForJS(const ccstd::vector> &boundsInfo, - const cc::optional &modelBound, + void syncDataForJS(const ccstd::vector> &boundsInfo, + const ccstd::optional &modelBound, float jointTextureInfo0, float jointTextureInfo1, float jointTextureInfo2, @@ -87,7 +87,7 @@ public: void setUploadedAnimForJS(bool value) { _isUploadedAnim = value; } protected: - void applyJointTexture(const cc::optional &texture); + void applyJointTexture(const ccstd::optional &texture); private: BakedJointInfo _jointMedium; diff --git a/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp b/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp index e5091613f7..e563966bff 100644 --- a/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp +++ b/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp @@ -170,9 +170,9 @@ void JointTexturePool::registerCustomTextureLayouts(const ccstd::vector JointTexturePool::getDefaultPoseTexture(Skeleton *skeleton, Mesh *mesh, Node *skinningRoot) { +ccstd::optional JointTexturePool::getDefaultPoseTexture(Skeleton *skeleton, Mesh *mesh, Node *skinningRoot) { uint64_t hash = skeleton->getHash() ^ 0; // may not equal to skeleton.hash - cc::optional texture; + ccstd::optional texture; if (_textureBuffers.find(hash) != _textureBuffers.end()) { texture = _textureBuffers[hash]; } @@ -243,9 +243,9 @@ cc::optional JointTexturePool::getDefaultPoseTexture(Skel } // TODO(xwx): need to implement this function after define AnimationClip -// cc::optional JointTexturePool::getSequencePoseTexture(Skeleton *skeleton,AnimationClip *clip, Mesh *mesh, Node *skinningRoot) { +// ccstd::optional JointTexturePool::getSequencePoseTexture(Skeleton *skeleton,AnimationClip *clip, Mesh *mesh, Node *skinningRoot) { // uint64_t hash = skeleton->getHash() ^ clip->getHash(); -// cc::optional texture; +// ccstd::optional texture; // if (_textureBuffers.find(hash) != _textureBuffers.end()) { // texture = _textureBuffers[hash]; // if (texture->bounds.find(mesh->getHash()) != texture->bounds.end()) { diff --git a/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.h b/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.h index 80882bbaab..fc5d7128e1 100644 --- a/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.h +++ b/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.h @@ -25,7 +25,7 @@ #pragma once #include "base/std/container/unordered_map.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "3d/assets/Skeleton.h" #include "core/TypedArray.h" @@ -52,10 +52,10 @@ struct ICustomJointTextureLayout { }; struct IInternalJointAnimInfo { - cc::optional downstream; // downstream default pose, if present - cc::optional> curveData; // the nearest animation curve, if present - index_t bindposeIdx{0}; // index of the actual bindpose to use - cc::optional bindposeCorrection; // correction factor from the original bindpose + ccstd::optional downstream; // downstream default pose, if present + ccstd::optional> curveData; // the nearest animation curve, if present + index_t bindposeIdx{0}; // index of the actual bindpose to use + ccstd::optional bindposeCorrection; // correction factor from the original bindpose }; class IJointTextureHandle { @@ -67,7 +67,7 @@ public: bool readyToBeDeleted{false}; ITextureBufferHandle handle; ccstd::unordered_map> bounds; - cc::optional> animInfos; + ccstd::optional> animInfos; static IJointTextureHandle *createJoinTextureHandle() { return ccnew IJointTextureHandle(); @@ -95,7 +95,7 @@ public: * @zh * 获取默认姿势的骨骼贴图。 */ - cc::optional getDefaultPoseTexture(Skeleton *skeleton, Mesh *mesh, Node *skinningRoot); + ccstd::optional getDefaultPoseTexture(Skeleton *skeleton, Mesh *mesh, Node *skinningRoot); /** * @en @@ -103,7 +103,7 @@ public: * @zh * 获取指定动画片段的骨骼贴图。 */ - // cc::optional getSequencePoseTexture(Skeleton *skeleton, AnimationClip *clip, Mesh *mesh, Node *skinningRoot); + // ccstd::optional getSequencePoseTexture(Skeleton *skeleton, AnimationClip *clip, Mesh *mesh, Node *skinningRoot); void releaseHandle(IJointTextureHandle *handle); diff --git a/native/cocos/application/BaseGame.cpp b/native/cocos/application/BaseGame.cpp index 4cad2516a2..eef0decfd1 100644 --- a/native/cocos/application/BaseGame.cpp +++ b/native/cocos/application/BaseGame.cpp @@ -31,38 +31,38 @@ namespace cc { int BaseGame::init() { cc::pipeline::GlobalDSManager::setDescriptorSetLayout(); #if CC_PLATFORM == CC_PLATFORM_WINDOWS || CC_PLATFORM == CC_PLATFORM_LINUX || CC_PLATFORM == CC_PLATFORM_QNX || CC_PLATFORM == CC_PLATFORM_MAC_OSX - // override default value - //_windowInfo.x = _windowInfo.x == -1 ? 0 : _windowInfo.x; - //_windowInfo.y = _windowInfo.y == -1 ? 0 : _windowInfo.y; - _windowInfo.width = _windowInfo.width == -1 ? 800 : _windowInfo.width; - _windowInfo.height = _windowInfo.height == -1 ? 600 : _windowInfo.height; - _windowInfo.flags = _windowInfo.flags == -1 ? cc::ISystemWindow::CC_WINDOW_SHOWN | - cc::ISystemWindow::CC_WINDOW_RESIZABLE | - cc::ISystemWindow::CC_WINDOW_INPUT_FOCUS - : _windowInfo.flags; - std::call_once(_windowCreateFlag, [&]() { - if (_windowInfo.x == -1 || _windowInfo.y == -1) { - createWindow(_windowInfo.title.c_str(), _windowInfo.width, _windowInfo.height, _windowInfo.flags); - } else { - createWindow(_windowInfo.title.c_str(), - _windowInfo.x, _windowInfo.y, _windowInfo.width, _windowInfo.height, _windowInfo.flags); - } - }); + // override default value + //_windowInfo.x = _windowInfo.x == -1 ? 0 : _windowInfo.x; + //_windowInfo.y = _windowInfo.y == -1 ? 0 : _windowInfo.y; + _windowInfo.width = _windowInfo.width == -1 ? 800 : _windowInfo.width; + _windowInfo.height = _windowInfo.height == -1 ? 600 : _windowInfo.height; + _windowInfo.flags = _windowInfo.flags == -1 ? cc::ISystemWindow::CC_WINDOW_SHOWN | + cc::ISystemWindow::CC_WINDOW_RESIZABLE | + cc::ISystemWindow::CC_WINDOW_INPUT_FOCUS + : _windowInfo.flags; + std::call_once(_windowCreateFlag, [&]() { + if (_windowInfo.x == -1 || _windowInfo.y == -1) { + createWindow(_windowInfo.title.c_str(), _windowInfo.width, _windowInfo.height, _windowInfo.flags); + } else { + createWindow(_windowInfo.title.c_str(), + _windowInfo.x, _windowInfo.y, _windowInfo.width, _windowInfo.height, _windowInfo.flags); + } + }); #endif - if (_debuggerInfo.enabled) { - setDebugIpAndPort(_debuggerInfo.address, _debuggerInfo.port, _debuggerInfo.pauseOnStart); - } + if (_debuggerInfo.enabled) { + setDebugIpAndPort(_debuggerInfo.address, _debuggerInfo.port, _debuggerInfo.pauseOnStart); + } - int ret = cc::CocosApplication::init(); - if (ret != 0) { - return ret; - } + int ret = cc::CocosApplication::init(); + if (ret != 0) { + return ret; + } - setXXTeaKey(_xxteaKey); - runScript("jsb-adapter/jsb-builtin.js"); - runScript("main.js"); - return 0; + setXXTeaKey(_xxteaKey); + runScript("jsb-adapter/jsb-builtin.js"); + runScript("main.js"); + return 0; } } // namespace cc diff --git a/native/cocos/audio/AudioEngine.cpp b/native/cocos/audio/AudioEngine.cpp index fa6896a3d2..5be9c9b4d2 100644 --- a/native/cocos/audio/AudioEngine.cpp +++ b/native/cocos/audio/AudioEngine.cpp @@ -246,7 +246,7 @@ int AudioEngine::play2d(const ccstd::string &filePath, bool loop, float volume, audioRef.volume = volume; audioRef.loop = loop; audioRef.filePath = &it->first; - audioRef.state = AudioState::PLAYING; + audioRef.state = AudioState::PLAYING; if (profileHelper) { profileHelper->lastPlayTime = std::chrono::high_resolution_clock::now(); diff --git a/native/cocos/base/Any.h b/native/cocos/base/std/any.h similarity index 96% rename from native/cocos/base/Any.h rename to native/cocos/base/std/any.h index d8d5552f76..ef7945b5e4 100644 --- a/native/cocos/base/Any.h +++ b/native/cocos/base/std/any.h @@ -29,18 +29,18 @@ #include -namespace cc { +namespace ccstd { using std::any; using std::any_cast; -} // namespace cc +} // namespace ccstd #else #include "boost/any.hpp" -namespace cc { +namespace ccstd { class any : public boost::any { // NOLINT // use std style public: @@ -76,5 +76,5 @@ inline ValueType any_cast(any &&operand) { // NOLINT // use std style return boost::any_cast(operand); } -} // namespace cc +} // namespace ccstd #endif diff --git a/native/cocos/base/Optional.h b/native/cocos/base/std/optional.h similarity index 95% rename from native/cocos/base/Optional.h rename to native/cocos/base/std/optional.h index ffdedd06b4..e59a096db6 100644 --- a/native/cocos/base/Optional.h +++ b/native/cocos/base/std/optional.h @@ -29,25 +29,25 @@ #include -namespace cc { +namespace ccstd { using std::nullopt; using std::nullopt_t; using std::optional; -}; // namespace cc +}; // namespace ccstd #else #include "base/std/container/string.h" #include "boost/none.hpp" #include "boost/optional.hpp" -namespace cc { +namespace ccstd { using boost::optional; using nullopt_t = boost::none_t; const nullopt_t nullopt((boost::none_t::init_tag())); // NOLINT // use std style -}; // namespace cc +}; // namespace ccstd #endif diff --git a/native/cocos/base/Variant.h b/native/cocos/base/std/variant.h similarity index 95% rename from native/cocos/base/Variant.h rename to native/cocos/base/std/variant.h index 1ee1602373..41c047bfdb 100644 --- a/native/cocos/base/Variant.h +++ b/native/cocos/base/std/variant.h @@ -29,7 +29,7 @@ #include -namespace cc { +namespace ccstd { using std::get; using std::get_if; @@ -38,13 +38,13 @@ using std::monostate; using std::variant; using std::visit; -}; // namespace cc +}; // namespace ccstd #else #include "boost/variant2/variant.hpp" -namespace cc { +namespace ccstd { using boost::variant2::get; using boost::variant2::get_if; @@ -53,5 +53,5 @@ using boost::variant2::monostate; using boost::variant2::variant; using boost::variant2::visit; -}; // namespace cc +}; // namespace ccstd #endif diff --git a/native/cocos/bindings/event/EventDispatcher.cpp b/native/cocos/bindings/event/EventDispatcher.cpp index fa9f3260ae..8a99bb9f89 100644 --- a/native/cocos/bindings/event/EventDispatcher.cpp +++ b/native/cocos/bindings/event/EventDispatcher.cpp @@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include #include "EventDispatcher.h" +#include #include "cocos/application/ApplicationManager.h" #include "cocos/bindings/event/CustomEventTypes.h" #include "cocos/bindings/jswrapper/SeApi.h" @@ -228,7 +228,6 @@ void EventDispatcher::dispatchKeyboardEvent(const KeyboardEvent &keyboardEvent) se::ValueArray args; args.emplace_back(se::Value(jsKeyboardEventObj)); EventDispatcher::doDispatchJsEvent(eventName, args); - } void EventDispatcher::dispatchTickEvent(float /*dt*/) { @@ -261,7 +260,7 @@ void EventDispatcher::dispatchResizeEvent(int width, int height) { jsResizeEventObj->setProperty("width", se::Value(width)); jsResizeEventObj->setProperty("height", se::Value(height)); - + se::ValueArray args; args.emplace_back(se::Value(jsResizeEventObj)); EventDispatcher::doDispatchJsEvent("onResize", args); @@ -320,17 +319,16 @@ void EventDispatcher::dispatchCloseEvent() { void EventDispatcher::dispatchDestroyWindowEvent() { #if CC_PLATFORM == CC_PLATFORM_WINDOWS EventDispatcher::dispatchCustomEvent(EVENT_DESTROY_WINDOW, 1, - reinterpret_cast(CC_GET_PLATFORM_INTERFACE(ISystemWindow)->getWindowHandler())); + reinterpret_cast(CC_GET_PLATFORM_INTERFACE(ISystemWindow)->getWindowHandler())); #else EventDispatcher::dispatchCustomEvent(EVENT_DESTROY_WINDOW, 0); #endif - } void EventDispatcher::dispatchRecreateWindowEvent() { #if CC_PLATFORM == CC_PLATFORM_WINDOWS EventDispatcher::dispatchCustomEvent(EVENT_RECREATE_WINDOW, 1, - reinterpret_cast(CC_GET_PLATFORM_INTERFACE(ISystemWindow)->getWindowHandler())); + reinterpret_cast(CC_GET_PLATFORM_INTERFACE(ISystemWindow)->getWindowHandler())); #else EventDispatcher::dispatchCustomEvent(EVENT_RECREATE_WINDOW, 0); #endif @@ -431,7 +429,7 @@ void EventDispatcher::removeAllEventListeners() { void EventDispatcher::dispatchCustomEvent(const char *eventName, int argNum, ...) { CC_ASSERT(eventName && (strcmp(eventName, "") != 0)); CustomEvent event; - event.name = eventName; + event.name = eventName; va_list vl; va_start(vl, argNum); // Step through the list. @@ -441,8 +439,7 @@ void EventDispatcher::dispatchCustomEvent(const char *eventName, int argNum, ... va_end(vl); dispatchCustomEvent(event); } -void EventDispatcher::dispatchCustomEvent(const CustomEvent& event) { - +void EventDispatcher::dispatchCustomEvent(const CustomEvent &event) { auto iter = listeners.find(event.name); if (iter != listeners.end()) { Node *next = nullptr; diff --git a/native/cocos/bindings/event/EventDispatcher.h b/native/cocos/bindings/event/EventDispatcher.h index ae4eaf3fd4..3c1b75f3c2 100644 --- a/native/cocos/bindings/event/EventDispatcher.h +++ b/native/cocos/bindings/event/EventDispatcher.h @@ -221,12 +221,12 @@ public: // TODO(mingo): support caps lock? }; union EventParameterType { - void * ptrVal; - int32_t longVal; - int intVal; + void *ptrVal; + int32_t longVal; + int intVal; int16_t shortVal; - char charVal; - bool boolVal; + char charVal; + bool boolVal; }; class CustomEvent : public OSEvent { diff --git a/native/cocos/bindings/manual/jsb_conversions.h b/native/cocos/bindings/manual/jsb_conversions.h index b3f7d9874f..02b10c02e7 100644 --- a/native/cocos/bindings/manual/jsb_conversions.h +++ b/native/cocos/bindings/manual/jsb_conversions.h @@ -29,16 +29,16 @@ #include #include #include +#include "base/Macros.h" +#include "base/Ptr.h" +#include "base/RefCounted.h" +#include "base/std/any.h" +#include "base/std/container/vector.h" +#include "base/std/optional.h" +#include "base/std/variant.h" #include "bindings/jswrapper/HandleObject.h" #include "bindings/jswrapper/SeApi.h" #include "bindings/manual/jsb_classtype.h" -#include "base/Any.h" -#include "base/Macros.h" -#include "base/Optional.h" -#include "base/RefCounted.h" -#include "base/Ptr.h" -#include "base/Variant.h" -#include "base/std/container/vector.h" #include "jsb_conversions_spec.h" #if CC_USE_SPINE @@ -609,9 +609,9 @@ struct HolderType, true> { }; //template -//struct HolderType, true> { +//struct HolderType, true> { // using NonconstT = typename std::remove_const::type; -// using type = cc::optional; +// using type = ccstd::optional; // using local_type = NonconstT; // local_type data; // std::remove_const_t *ptr = nullptr; @@ -625,18 +625,18 @@ template struct is_optional : std::false_type {}; // NOLINT template -struct is_optional> : std::true_type {}; // NOLINT +struct is_optional> : std::true_type {}; // NOLINT template struct is_variant : std::false_type {}; // NOLINT template -struct is_variant> : std::true_type {}; // NOLINT +struct is_variant> : std::true_type {}; // NOLINT template inline typename std::enable_if_t::value && !std::is_pointer::value && !is_jsb_object_v, bool> sevalue_to_native(const se::Value & /*from*/, T * /*to*/, se::Object * /*unused*/) { // NOLINT(readability-identifier-naming) SE_LOGE("Can not convert type ???\n - [[ %s ]]\n", typeid(T).name()); - CC_STATIC_ASSERT(!is_variant::value, "should not match cc::variant"); + CC_STATIC_ASSERT(!is_variant::value, "should not match ccstd::variant"); CC_STATIC_ASSERT((std::is_same::value), "sevalue_to_native not implemented for T"); return false; } @@ -664,12 +664,12 @@ sevalue_to_native(const se::Value &from, T *to, se::Object *ctx) { // NOLINT(rea //////////////////////////////// forward declaration : sevalue_to_native //////////////////////////////// -// cc::variant<...>>ss +// ccstd::variant<...>>ss template -bool sevalue_to_native(const se::Value &from, cc::variant *to, se::Object *ctx); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, ccstd::variant *to, se::Object *ctx); // NOLINT(readability-identifier-naming) template -bool sevalue_to_native(const se::Value &from, cc::optional *to, se::Object *ctx); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, ccstd::optional *to, se::Object *ctx); // NOLINT(readability-identifier-naming) /// ccstd::unordered_map template bool sevalue_to_native(const se::Value &from, ccstd::unordered_map *to, se::Object *ctx); //NOLINT(readability-identifier-naming) @@ -744,7 +744,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::array *to, se } template -bool sevalue_to_native(const se::Value &from, cc::variant> *to, se::Object *ctx) { // NOLINT +bool sevalue_to_native(const se::Value &from, ccstd::variant> *to, se::Object *ctx) { // NOLINT se::Object *array = from.toObject(); if (array->isArray()) { ccstd::vector result; @@ -881,10 +881,10 @@ inline bool sevalue_to_native(const se::Value &from, std::function * return true; } -//////////////////////// cc::variant +//////////////////////// ccstd::variant template -inline bool sevalue_to_native(const se::Value & /*from*/, cc::variant * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) +inline bool sevalue_to_native(const se::Value & /*from*/, ccstd::variant * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) static_assert(sizeof...(Args) == 0, "should not pass variant from js -> native"); CC_ASSERT(false); return false; @@ -1087,9 +1087,9 @@ bool sevalue_to_native(const se::Value &from, ccstd::unordered_map -bool sevalue_to_native(const se::Value &from, cc::optional *to, se::Object *ctx) { //NOLINT +bool sevalue_to_native(const se::Value &from, ccstd::optional *to, se::Object *ctx) { //NOLINT static_assert(!is_optional::value, "bad match ?"); if (from.isNullOrUndefined()) { to->reset(); @@ -1118,10 +1118,10 @@ template inline bool nativevalue_to_se(T &&from, se::Value &to); // NOLINT(readability-identifier-naming) template -bool nativevalue_to_se(const cc::variant &from, se::Value &to, se::Object *ctx); // NOLINT +bool nativevalue_to_se(const ccstd::variant &from, se::Value &to, se::Object *ctx); // NOLINT template -bool nativevalue_to_se(const cc::variant *from, se::Value &to, se::Object *ctx) { // NOLINT +bool nativevalue_to_se(const ccstd::variant *from, se::Value &to, se::Object *ctx) { // NOLINT return nativevalue_to_se(*from, to, ctx); } @@ -1201,9 +1201,9 @@ inline bool nativevalue_to_se(const ccstd::unordered_map &from, se::Value template inline bool nativevalue_to_se(const cc::TypedArrayTemp &typedArray, se::Value &to, se::Object *ctx); // NOLINT -/// nativevalue_to_se cc::optional +/// nativevalue_to_se ccstd::optional template -bool nativevalue_to_se(const cc::optional &from, se::Value &to, se::Object *ctx) { // NOLINT +bool nativevalue_to_se(const ccstd::optional &from, se::Value &to, se::Object *ctx) { // NOLINT if (!from.has_value()) { to.setUndefined(); return true; @@ -1321,12 +1321,12 @@ bool nativevalue_to_se_args(se::ValueArray &array, T &x) { // NOLINT(readability return nativevalue_to_se(x, array[i], nullptr); } template -bool nativevalue_to_se_args(se::ValueArray &array, T &x, Args &... args) { // NOLINT(readability-identifier-naming) +bool nativevalue_to_se_args(se::ValueArray &array, T &x, Args &...args) { // NOLINT(readability-identifier-naming) return nativevalue_to_se_args(array, x) && nativevalue_to_se_args(array, args...); } template -bool nativevalue_to_se_args_v(se::ValueArray &array, Args &... args) { // NOLINT(readability-identifier-naming) +bool nativevalue_to_se_args_v(se::ValueArray &array, Args &...args) { // NOLINT(readability-identifier-naming) return nativevalue_to_se_args<0, Args...>(array, args...); } @@ -1418,9 +1418,9 @@ inline bool nativevalue_to_se(T &&from, se::Value &to) { // NOLINT(readability-i } template -bool nativevalue_to_se(const cc::variant &from, se::Value &to, se::Object *ctx) { // NOLINT(readability-identifier-naming) +bool nativevalue_to_se(const ccstd::variant &from, se::Value &to, se::Object *ctx) { // NOLINT(readability-identifier-naming) bool ok = false; - cc::visit( + ccstd::visit( [&](auto param) { ok = nativevalue_to_se(param, to, ctx); }, diff --git a/native/cocos/bindings/manual/jsb_conversions_spec.cpp b/native/cocos/bindings/manual/jsb_conversions_spec.cpp index 8edc656012..1087e67988 100644 --- a/native/cocos/bindings/manual/jsb_conversions_spec.cpp +++ b/native/cocos/bindings/manual/jsb_conversions_spec.cpp @@ -785,7 +785,7 @@ bool sevalue_to_native(const se::Value &from, cc::scene::SkyboxInfo *to, se::Obj return true; } -// cc::variant; +// ccstd::variant; // NOLINTNEXTLINE(readability-identifier-naming) bool sevalue_to_native(const se::Value &from, cc::MacroValue *to, se::Object * /*ctx*/) { if (from.isBoolean()) { @@ -841,7 +841,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::vector *to // NOLINTNEXTLINE(readability-identifier-naming) bool sevalue_to_native(const se::Value &from, cc::MaterialProperty *to, se::Object *ctx) { if (from.isNullOrUndefined()) { - *to = cc::monostate(); + *to = ccstd::monostate(); return true; } @@ -994,7 +994,7 @@ bool sevalue_to_native(const se::Value &from, cc::IPreCompileInfoValueType *to, } // NOLINTNEXTLINE(readability-identifier-naming) -bool sevalue_to_native(const se::Value &from, cc::variant, ccstd::string> *to, se::Object * /*ctx*/) { +bool sevalue_to_native(const se::Value &from, ccstd::variant, ccstd::string> *to, se::Object * /*ctx*/) { if (from.isObject() && from.toObject()->isArray()) { uint32_t len = 0; bool ok = from.toObject()->getArrayLength(&len); @@ -1019,7 +1019,7 @@ bool sevalue_to_native(const se::Value &from, cc::variant, } // NOLINTNEXTLINE(readability-identifier-naming) -bool sevalue_to_native(const se::Value &from, cc::variant *to, se::Object *ctx) { +bool sevalue_to_native(const se::Value &from, ccstd::variant *to, se::Object *ctx) { bool ok = false; if (from.isObject() && from.toObject()->isArray()) { cc::MaterialPropertyList propertyList{}; @@ -1152,21 +1152,21 @@ bool sevalue_to_native(const se::Value &from, cc::TypedArray *to, se::Object * / } } - cc::visit(make_overloaded( - [&](auto &typedArray) { - typedArray.setJSTypedArray(from.toObject()); - }, - [](cc::monostate /*unused*/) {}), - *to); + ccstd::visit(make_overloaded( + [&](auto &typedArray) { + typedArray.setJSTypedArray(from.toObject()); + }, + [](ccstd::monostate /*unused*/) {}), + *to); return true; } // NOLINTNEXTLINE(readability-identifier-naming) bool sevalue_to_native(const se::Value &from, cc::IBArray *to, se::Object * /*ctx*/) { - cc::visit([&](auto &typedArray) { + ccstd::visit([&](auto &typedArray) { typedArray.setJSTypedArray(from.toObject()); }, - *to); + *to); return true; } diff --git a/native/cocos/bindings/manual/jsb_conversions_spec.h b/native/cocos/bindings/manual/jsb_conversions_spec.h index 9743fe421b..561e8e21dc 100644 --- a/native/cocos/bindings/manual/jsb_conversions_spec.h +++ b/native/cocos/bindings/manual/jsb_conversions_spec.h @@ -23,13 +23,13 @@ #include "base/Ptr.h" #include "base/Value.h" +#include "base/std/any.h" #include "base/std/container/unordered_map.h" +#include "base/std/optional.h" +#include "base/std/variant.h" #include "bindings/jswrapper/SeApi.h" -#include "cocos/base/Any.h" -#include "cocos/base/Optional.h" -#include "cocos/base/Variant.h" -#include "cocos/core/assets/AssetsModuleHeader.h" #include "core/TypedArray.h" +#include "core/assets/AssetsModuleHeader.h" #include "core/assets/RenderingSubMesh.h" #if CC_USE_PHYSICS_PHYSX @@ -153,8 +153,8 @@ bool seval_to_DownloaderHints(const se::Value &v, cc::network::DownloaderHints * bool sevalue_to_native(const se::Value &from, cc::MacroValue *to, se::Object *ctx); // NOLINT(readability-identifier-naming) bool sevalue_to_native(const se::Value &from, cc::IPreCompileInfoValueType *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) -// cc::any -bool sevalue_to_native(const se::Value &from, cc::any *to, se::Object *ctx); //NOLINT(readability-identifier-naming) +// ccstd::any +bool sevalue_to_native(const se::Value &from, ccstd::any *to, se::Object *ctx); //NOLINT(readability-identifier-naming) ////////////////// ArrayBuffer bool sevalue_to_native(const se::Value &from, cc::ArrayBuffer *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) bool sevalue_to_native(const se::Value &from, cc::ArrayBuffer **to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) @@ -291,8 +291,8 @@ inline bool sevalue_to_native(const se::Value &from, ccstd::vector *t return true; } -////////////////// cc::any -inline bool sevalue_to_native(const se::Value & /*from*/, cc::any * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) +////////////////// ccstd::any +inline bool sevalue_to_native(const se::Value & /*from*/, ccstd::any * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) CC_ASSERT(false); SE_LOGE("Can not convert any to specific types"); return false; @@ -334,13 +334,13 @@ inline bool sevalue_to_native(const se::Value &from, cc::ValueMap *to, se::Objec bool sevalue_to_native(const se::Value &from, ccstd::vector *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) -bool sevalue_to_native(const se::Value &from, ccstd::vector *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) -bool sevalue_to_native(const se::Value &from, cc::variant, ccstd::string> *to, se::Object *ctx); // NOLINT(readability-identifier-naming) -inline bool sevalue_to_native(const se::Value & /*from*/, cc::monostate * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, ccstd::vector *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, ccstd::variant, ccstd::string> *to, se::Object *ctx); // NOLINT(readability-identifier-naming) +inline bool sevalue_to_native(const se::Value & /*from*/, ccstd::monostate * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) // nothing todo return false; } -bool sevalue_to_native(const se::Value &from, cc::variant *to, se::Object *ctx); // NOLINT(readability-identifier-naming) +bool sevalue_to_native(const se::Value &from, ccstd::variant *to, se::Object *ctx); // NOLINT(readability-identifier-naming) //////////////////////// scene info bool sevalue_to_native(const se::Value &from, cc::scene::FogInfo *, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) @@ -495,14 +495,14 @@ inline bool nativevalue_to_se(const cc::network::DownloadTask &from, se::Value & return DownloadTask_to_seval(from, &to); } -inline bool nativevalue_to_se(const cc::monostate & /*from*/, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) +inline bool nativevalue_to_se(const ccstd::monostate & /*from*/, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) to.setUndefined(); return true; } -inline bool nativevalue_to_se(const cc::any &from, se::Value &to, se::Object *ctx) { //NOLINT +inline bool nativevalue_to_se(const ccstd::any &from, se::Value &to, se::Object *ctx) { //NOLINT CC_ASSERT(false); - SE_LOGE("should not convert cc::any"); + SE_LOGE("should not convert ccstd::any"); return true; } diff --git a/native/cocos/core/DataView.cpp b/native/cocos/core/DataView.cpp index 3fb85bf21d..2790b9ed7c 100644 --- a/native/cocos/core/DataView.cpp +++ b/native/cocos/core/DataView.cpp @@ -49,10 +49,10 @@ ccstd::unordered_map DataView::intWritterMa }; int32_t DataView::readInt(ReaderVariant &readerVariant, uint32_t offset) { - return cc::visit([offset, this](auto &reader) { + return ccstd::visit([offset, this](auto &reader) { return static_cast((this->*reader)(offset)); }, - readerVariant); + readerVariant); } DataView::DataView(ArrayBuffer *buffer) : DataView(buffer, 0) {} diff --git a/native/cocos/core/DataView.h b/native/cocos/core/DataView.h index 04692cc1b0..c6c0ccc411 100644 --- a/native/cocos/core/DataView.h +++ b/native/cocos/core/DataView.h @@ -27,7 +27,7 @@ #include "base/Macros.h" #include "base/TypeDef.h" -#include "base/Variant.h" +#include "base/std/variant.h" #include "core/ArrayBuffer.h" namespace cc { @@ -73,7 +73,7 @@ public: using UInt16Reader = uint16_t (DataView::*)(uint32_t) const; using Int8Reader = int8_t (DataView::*)(uint32_t) const; using UInt8Reader = uint8_t (DataView::*)(uint32_t) const; - using ReaderVariant = cc::variant; + using ReaderVariant = ccstd::variant; static ccstd::unordered_map intReaderMap; int32_t readInt(ReaderVariant &readerVariant, uint32_t offset); diff --git a/native/cocos/core/TypedArray.cpp b/native/cocos/core/TypedArray.cpp index 649d027e4c..3ddc8605a4 100644 --- a/native/cocos/core/TypedArray.cpp +++ b/native/cocos/core/TypedArray.cpp @@ -28,12 +28,12 @@ namespace cc { uint32_t getTypedArrayLength(const TypedArray &arr) { -#define TYPEDARRAY_GET_SIZE(type) \ - do { \ - auto *p = cc::get_if(&arr); \ - if (p != nullptr) { \ - return p->length(); \ - } \ +#define TYPEDARRAY_GET_SIZE(type) \ + do { \ + auto *p = ccstd::get_if(&arr); \ + if (p != nullptr) { \ + return p->length(); \ + } \ } while (false) TYPEDARRAY_GET_SIZE(Float32Array); @@ -52,7 +52,7 @@ uint32_t getTypedArrayLength(const TypedArray &arr) { uint32_t getTypedArrayBytesPerElement(const TypedArray &arr) { #define TYPEDARRAY_GET_BYTES_PER_ELEMENT(type) \ do { \ - auto *p = cc::get_if(&arr); \ + auto *p = ccstd::get_if(&arr); \ if (p != nullptr) { \ return type::BYTES_PER_ELEMENT; \ } \ @@ -72,43 +72,43 @@ uint32_t getTypedArrayBytesPerElement(const TypedArray &arr) { } void setTypedArrayValue(TypedArray &arr, uint32_t idx, const TypedArrayElementType &value) { -#define TYPEDARRAY_SET_VALUE(type, elemType) \ - do { \ - auto *p = cc::get_if(&value); \ - if (p != nullptr) { \ - if (cc::holds_alternative(arr)) { \ - cc::get(arr)[idx] = static_cast(*p); \ - return; \ - } \ - if (cc::holds_alternative(arr)) { \ - cc::get(arr)[idx] = static_cast(*p); \ - return; \ - } \ - if (cc::holds_alternative(arr)) { \ - cc::get(arr)[idx] = static_cast(*p); \ - return; \ - } \ - if (cc::holds_alternative(arr)) { \ - cc::get(arr)[idx] = static_cast(*p); \ - return; \ - } \ - if (cc::holds_alternative(arr)) { \ - cc::get(arr)[idx] = static_cast(*p); \ - return; \ - } \ - if (cc::holds_alternative(arr)) { \ - cc::get(arr)[idx] = static_cast(*p); \ - return; \ - } \ - if (cc::holds_alternative(arr)) { \ - cc::get(arr)[idx] = static_cast(*p); \ - return; \ - } \ - if (cc::holds_alternative(arr)) { \ - cc::get(arr)[idx] = static_cast(*p); \ - return; \ - } \ - } \ +#define TYPEDARRAY_SET_VALUE(type, elemType) \ + do { \ + auto *p = ccstd::get_if(&value); \ + if (p != nullptr) { \ + if (ccstd::holds_alternative(arr)) { \ + ccstd::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (ccstd::holds_alternative(arr)) { \ + ccstd::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (ccstd::holds_alternative(arr)) { \ + ccstd::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (ccstd::holds_alternative(arr)) { \ + ccstd::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (ccstd::holds_alternative(arr)) { \ + ccstd::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (ccstd::holds_alternative(arr)) { \ + ccstd::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (ccstd::holds_alternative(arr)) { \ + ccstd::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + if (ccstd::holds_alternative(arr)) { \ + ccstd::get(arr)[idx] = static_cast(*p); \ + return; \ + } \ + } \ } while (false) TYPEDARRAY_SET_VALUE(Float32Array, float); diff --git a/native/cocos/core/TypedArray.h b/native/cocos/core/TypedArray.h index d633c67fcf..979680f7fe 100644 --- a/native/cocos/core/TypedArray.h +++ b/native/cocos/core/TypedArray.h @@ -29,8 +29,8 @@ #include #include #include "base/TypeDef.h" +#include "base/std/variant.h" #include "bindings/jswrapper/Object.h" -#include "cocos/base/Variant.h" #include "core/ArrayBuffer.h" namespace cc { @@ -304,8 +304,8 @@ using Uint16Array = TypedArrayTemp; using Uint32Array = TypedArrayTemp; using Float32Array = TypedArrayTemp; using Float64Array = TypedArrayTemp; -using TypedArray = cc::variant; -using TypedArrayElementType = cc::variant; +using TypedArray = ccstd::variant; +using TypedArrayElementType = ccstd::variant; uint32_t getTypedArrayLength(const TypedArray &arr); uint32_t getTypedArrayBytesPerElement(const TypedArray &arr); @@ -314,7 +314,7 @@ template T getTypedArrayValue(const TypedArray &arr, uint32_t idx) { #define TYPEDARRAY_GET_VALUE(type) \ do { \ - auto *p = cc::get_if(&arr); \ + auto *p = ccstd::get_if(&arr); \ if (p != nullptr) { \ return static_cast((*p)[idx]); \ } \ @@ -337,12 +337,12 @@ void setTypedArrayValue(TypedArray &arr, uint32_t idx, const TypedArrayElementTy template T &getTypedArrayValueRef(const TypedArray &arr, uint32_t idx) { -#define TYPEDARRAY_GET_VALUE_REF(type) \ - do { \ - auto *p = cc::get_if(&arr); \ - if (p != nullptr) { \ - return (*p)[idx]; \ - } \ +#define TYPEDARRAY_GET_VALUE_REF(type) \ + do { \ + auto *p = ccstd::get_if(&arr); \ + if (p != nullptr) { \ + return (*p)[idx]; \ + } \ } while (false) TYPEDARRAY_GET_VALUE_REF(Float32Array); @@ -358,12 +358,12 @@ T &getTypedArrayValueRef(const TypedArray &arr, uint32_t idx) { template T getTypedArrayElementValue(const TypedArrayElementType &element) { -#define CAST_TO_T(type) \ - do { \ - auto *p = cc::get_if(&element); \ - if (p != nullptr) { \ - return static_cast(*p); \ - } \ +#define CAST_TO_T(type) \ + do { \ + auto *p = ccstd::get_if(&element); \ + if (p != nullptr) { \ + return static_cast(*p); \ + } \ } while (false) CAST_TO_T(float); diff --git a/native/cocos/core/Types.h b/native/cocos/core/Types.h index 703624a6b9..45cd54d388 100644 --- a/native/cocos/core/Types.h +++ b/native/cocos/core/Types.h @@ -28,7 +28,7 @@ #include #include "base/std/container/string.h" #include "base/std/container/unordered_map.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include @@ -39,10 +39,9 @@ namespace cc { struct Error { - cc::optional msg; + ccstd::optional msg; }; - struct BoundingBox { Vec3 min; Vec3 max; diff --git a/native/cocos/core/assets/Asset.cpp b/native/cocos/core/assets/Asset.cpp index 9b8335b19b..ec0ca25cc5 100644 --- a/native/cocos/core/assets/Asset.cpp +++ b/native/cocos/core/assets/Asset.cpp @@ -89,7 +89,7 @@ void Asset::decAssetRef(bool autoRelease /* = true*/) { } } -void Asset::initDefault(const cc::optional &uuid) { +void Asset::initDefault(const ccstd::optional &uuid) { if (uuid.has_value()) { _uuid = uuid.value(); } diff --git a/native/cocos/core/assets/Asset.h b/native/cocos/core/assets/Asset.h index 2d6c52fae7..9aa9116f85 100644 --- a/native/cocos/core/assets/Asset.h +++ b/native/cocos/core/assets/Asset.h @@ -26,8 +26,8 @@ #pragma once #include -#include "cocos/base/Any.h" -#include "cocos/base/Optional.h" +#include "base/std/any.h" +#include "base/std/optional.h" #include "base/Macros.h" #include "core/Types.h" @@ -70,11 +70,11 @@ public: * @default null * @private */ - virtual cc::any getNativeAsset() const { + virtual ccstd::any getNativeAsset() const { return _file; } - virtual void setNativeAsset(const cc::any &obj) { + virtual void setNativeAsset(const ccstd::any &obj) { _file = obj; } @@ -99,9 +99,9 @@ public: virtual void onLoaded() {} - virtual void initDefault() { initDefault(cc::nullopt); } + virtual void initDefault() { initDefault(ccstd::nullopt); } - virtual void initDefault(const cc::optional &uuid); + virtual void initDefault(const ccstd::optional &uuid); virtual bool validate() const { return true; } @@ -114,13 +114,13 @@ public: /** * @return */ - virtual cc::any serialize(const cc::any & /*ctxForExporting*/) { return cc::any{}; }; + virtual ccstd::any serialize(const ccstd::any & /*ctxForExporting*/) { return ccstd::any{}; }; /** * * @param data */ - virtual void deserialize(const cc::any &serializedData, const cc::any &handle) {} + virtual void deserialize(const ccstd::any &serializedData, const ccstd::any &handle) {} ccstd::string toString() const override { return _nativeUrl; } @@ -146,7 +146,7 @@ public: protected: ccstd::string _uuid; - cc::any _file; + ccstd::any _file; uint32_t _assetRefCount{0}; bool _loaded{true}; diff --git a/native/cocos/core/assets/BufferAsset.cpp b/native/cocos/core/assets/BufferAsset.cpp index 74ab9fa7fd..de3c6c4165 100644 --- a/native/cocos/core/assets/BufferAsset.cpp +++ b/native/cocos/core/assets/BufferAsset.cpp @@ -27,12 +27,12 @@ namespace cc { -cc::any BufferAsset::getNativeAsset() const { +ccstd::any BufferAsset::getNativeAsset() const { return _buffer; } -void BufferAsset::setNativeAsset(const cc::any &obj) { - _buffer = cc::any_cast(obj); +void BufferAsset::setNativeAsset(const ccstd::any &obj) { + _buffer = ccstd::any_cast(obj); } } // namespace cc diff --git a/native/cocos/core/assets/BufferAsset.h b/native/cocos/core/assets/BufferAsset.h index fe4121a1ba..93f05a8d7e 100644 --- a/native/cocos/core/assets/BufferAsset.h +++ b/native/cocos/core/assets/BufferAsset.h @@ -37,8 +37,8 @@ public: inline ArrayBuffer *getBuffer() const { return _buffer; } - cc::any getNativeAsset() const override; - void setNativeAsset(const cc::any &obj) override; + ccstd::any getNativeAsset() const override; + void setNativeAsset(const ccstd::any &obj) override; bool validate() const override { return _buffer != nullptr; } private: diff --git a/native/cocos/core/assets/EffectAsset.cpp b/native/cocos/core/assets/EffectAsset.cpp index c6182553f5..4d5fb9c0e5 100644 --- a/native/cocos/core/assets/EffectAsset.cpp +++ b/native/cocos/core/assets/EffectAsset.cpp @@ -23,10 +23,10 @@ THE SOFTWARE. ****************************************************************************/ -#include "cocos.h" -#include "engine/BaseEngine.h" #include "core/assets/EffectAsset.h" +#include "cocos.h" #include "core/Root.h" +#include "engine/BaseEngine.h" #include "renderer/core/ProgramLib.h" namespace cc { @@ -152,7 +152,7 @@ bool EffectAsset::destroy() { return Super::destroy(); } -void EffectAsset::initDefault(const cc::optional &uuid) { +void EffectAsset::initDefault(const ccstd::optional &uuid) { Super::initDefault(uuid); const auto *effect = EffectAsset::get("unlit"); _name = "unlit"; @@ -240,19 +240,19 @@ ccstd::vector EffectAsset::doCombine(const ccstd::vector EffectAsset::generateRecords(const ccstd::string &key, const IPreCompileInfoValueType &infoValue) { ccstd::vector ret; - if (const auto *boolValues = cc::get_if>(&infoValue)) { + if (const auto *boolValues = ccstd::get_if>(&infoValue)) { for (const bool value : *boolValues) { MacroRecord record; record[key] = value; ret.emplace_back(record); } - } else if (const auto *intValues = cc::get_if>(&infoValue)) { + } else if (const auto *intValues = ccstd::get_if>(&infoValue)) { for (const int32_t value : *intValues) { MacroRecord record; record[key] = value; ret.emplace_back(record); } - } else if (const auto *stringValues = cc::get_if>(&infoValue)) { + } else if (const auto *stringValues = ccstd::get_if>(&infoValue)) { for (const ccstd::string &value : *stringValues) { MacroRecord record; record[key] = value; @@ -270,19 +270,19 @@ ccstd::vector EffectAsset::insertInfoValue(const ccstd::vector ret; for (const auto &record : records) { - if (const auto *boolValues = cc::get_if>(&infoValue)) { + if (const auto *boolValues = ccstd::get_if>(&infoValue)) { for (const bool value : *boolValues) { MacroRecord tmpRecord = record; tmpRecord[key] = value; ret.emplace_back(tmpRecord); } - } else if (const auto *intValues = cc::get_if>(&infoValue)) { + } else if (const auto *intValues = ccstd::get_if>(&infoValue)) { for (const int32_t value : *intValues) { MacroRecord tmpRecord = record; tmpRecord[key] = value; ret.emplace_back(tmpRecord); } - } else if (const auto *stringValues = cc::get_if>(&infoValue)) { + } else if (const auto *stringValues = ccstd::get_if>(&infoValue)) { for (const ccstd::string &value : *stringValues) { MacroRecord tmpRecord = record; tmpRecord[key] = value; diff --git a/native/cocos/core/assets/EffectAsset.h b/native/cocos/core/assets/EffectAsset.h index 3450cbe861..ed10dfbfa4 100644 --- a/native/cocos/core/assets/EffectAsset.h +++ b/native/cocos/core/assets/EffectAsset.h @@ -28,7 +28,7 @@ #include #include "base/std/container/string.h" #include "base/std/container/unordered_map.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "base/Value.h" #include "core/Types.h" @@ -42,33 +42,33 @@ namespace cc { using IPropertyHandleInfo = std::tuple; -using IPropertyValue = cc::optional, ccstd::string>>; +using IPropertyValue = ccstd::optional, ccstd::string>>; struct IPropertyInfo { - int32_t type; // auto-extracted from shader - cc::optional handleInfo; // auto-generated from 'target' - cc::optional samplerHash; // auto-generated from 'sampler' - IPropertyValue value; // default value - cc::optional linear; // whether to convert the input to linear space first before applying + int32_t type; // auto-extracted from shader + ccstd::optional handleInfo; // auto-generated from 'target' + ccstd::optional samplerHash; // auto-generated from 'sampler' + IPropertyValue value; // default value + ccstd::optional linear; // whether to convert the input to linear space first before applying }; struct IPassInfoFull; struct RasterizerStateInfo { - cc::optional isDiscard; - cc::optional isFrontFaceCCW; - cc::optional depthBiasEnabled; - cc::optional isDepthClip; - cc::optional isMultisample; + ccstd::optional isDiscard; + ccstd::optional isFrontFaceCCW; + ccstd::optional depthBiasEnabled; + ccstd::optional isDepthClip; + ccstd::optional isMultisample; - cc::optional polygonMode; - cc::optional shadeModel; - cc::optional cullMode; + ccstd::optional polygonMode; + ccstd::optional shadeModel; + ccstd::optional cullMode; - cc::optional depthBias; - cc::optional depthBiasClamp; - cc::optional depthBiasSlop; - cc::optional lineWidth; + ccstd::optional depthBias; + ccstd::optional depthBiasClamp; + ccstd::optional depthBiasSlop; + ccstd::optional lineWidth; void fromGFXRasterizerState(const gfx::RasterizerState &rs) { isDiscard = rs.isDiscard; @@ -128,27 +128,27 @@ struct RasterizerStateInfo { }; struct DepthStencilStateInfo { - cc::optional depthTest; - cc::optional depthWrite; - cc::optional stencilTestFront; - cc::optional stencilTestBack; + ccstd::optional depthTest; + ccstd::optional depthWrite; + ccstd::optional stencilTestFront; + ccstd::optional stencilTestBack; - cc::optional depthFunc; - cc::optional stencilFuncFront; - cc::optional stencilReadMaskFront; - cc::optional stencilWriteMaskFront; - cc::optional stencilFailOpFront; - cc::optional stencilZFailOpFront; - cc::optional stencilPassOpFront; - cc::optional stencilRefFront; + ccstd::optional depthFunc; + ccstd::optional stencilFuncFront; + ccstd::optional stencilReadMaskFront; + ccstd::optional stencilWriteMaskFront; + ccstd::optional stencilFailOpFront; + ccstd::optional stencilZFailOpFront; + ccstd::optional stencilPassOpFront; + ccstd::optional stencilRefFront; - cc::optional stencilFuncBack; - cc::optional stencilReadMaskBack; - cc::optional stencilWriteMaskBack; - cc::optional stencilFailOpBack; - cc::optional stencilZFailOpBack; - cc::optional stencilPassOpBack; - cc::optional stencilRefBack; + ccstd::optional stencilFuncBack; + ccstd::optional stencilReadMaskBack; + ccstd::optional stencilWriteMaskBack; + ccstd::optional stencilFailOpBack; + ccstd::optional stencilZFailOpBack; + ccstd::optional stencilPassOpBack; + ccstd::optional stencilRefBack; void fromGFXDepthStencilState(const gfx::DepthStencilState &ds) { depthTest = ds.depthTest; @@ -236,14 +236,14 @@ struct DepthStencilStateInfo { }; struct BlendTargetInfo { - cc::optional blend; - cc::optional blendSrc; - cc::optional blendDst; - cc::optional blendEq; - cc::optional blendSrcAlpha; - cc::optional blendDstAlpha; - cc::optional blendAlphaEq; - cc::optional blendColorMask; + ccstd::optional blend; + ccstd::optional blendSrc; + ccstd::optional blendDst; + ccstd::optional blendEq; + ccstd::optional blendSrcAlpha; + ccstd::optional blendDstAlpha; + ccstd::optional blendAlphaEq; + ccstd::optional blendColorMask; void fromGFXBlendTarget(const gfx::BlendTarget &target) { blend = target.blend; @@ -287,10 +287,10 @@ struct BlendTargetInfo { using BlendTargetInfoList = ccstd::vector; struct BlendStateInfo { - cc::optional isA2C; - cc::optional isIndepend; - cc::optional blendColor; - cc::optional targets; + ccstd::optional isA2C; + ccstd::optional isIndepend; + ccstd::optional blendColor; + ccstd::optional targets; void fromGFXBlendState(const gfx::BlendState &bs) { isA2C = bs.isA2C; @@ -331,14 +331,14 @@ struct BlendStateInfo { // Pass instance itself are compliant to IPassStates too struct IPassStates { - cc::optional priority; - cc::optional primitive; - cc::optional stage; - cc::optional rasterizerState; - cc::optional depthStencilState; - cc::optional blendState; - cc::optional dynamicStates; - cc::optional phase; + ccstd::optional priority; + ccstd::optional primitive; + ccstd::optional stage; + ccstd::optional rasterizerState; + ccstd::optional depthStencilState; + ccstd::optional blendState; + ccstd::optional dynamicStates; + ccstd::optional phase; IPassStates() = default; explicit IPassStates(const IPassInfoFull &o); @@ -351,26 +351,26 @@ using PassPropertyInfoMap = ccstd::unordered_map; struct IPassInfoFull final { //cjh } : public IPassInfo { // IPassStates - cc::optional priority; - cc::optional primitive; - cc::optional stage; - cc::optional rasterizerState; - cc::optional depthStencilState; - cc::optional blendState; - cc::optional dynamicStates; - cc::optional phase; + ccstd::optional priority; + ccstd::optional primitive; + ccstd::optional stage; + ccstd::optional rasterizerState; + ccstd::optional depthStencilState; + ccstd::optional blendState; + ccstd::optional dynamicStates; + ccstd::optional phase; // IPassInfo ccstd::string program; // auto-generated from 'vert' and 'frag' - cc::optional embeddedMacros; + ccstd::optional embeddedMacros; index_t propertyIndex{CC_INVALID_INDEX}; - cc::optional switch_; - cc::optional properties; + ccstd::optional switch_; + ccstd::optional properties; // IPassInfoFull // generated part index_t passIndex{0}; MacroRecord defines; - cc::optional stateOverrides; + ccstd::optional stateOverrides; IPassInfoFull() = default; explicit IPassInfoFull(const IPassStates &o) { @@ -393,7 +393,7 @@ using IPassInfo = IPassInfoFull; struct ITechniqueInfo { ccstd::vector passes; - cc::optional name; + ccstd::optional name; }; struct IBlockInfo { @@ -466,9 +466,9 @@ struct IAttributeInfo { struct IDefineInfo { ccstd::string name; ccstd::string type; - cc::optional> range; //cjh number is float? ?: number[]; - cc::optional> options; - cc::optional defaultVal; + ccstd::optional> range; //cjh number is float? ?: number[]; + ccstd::optional> options; + ccstd::optional defaultVal; }; struct IBuiltin { @@ -521,7 +521,7 @@ struct IShaderInfo { } }; -using IPreCompileInfoValueType = cc::variant, ccstd::vector, ccstd::vector>; +using IPreCompileInfoValueType = ccstd::variant, ccstd::vector, ccstd::vector>; using IPreCompileInfo = ccstd::unordered_map; class EffectAsset final : public Asset { @@ -576,7 +576,7 @@ public: */ void onLoaded() override; bool destroy() override; - void initDefault(const cc::optional &uuid) override; + void initDefault(const ccstd::optional &uuid) override; bool validate() const override; protected: diff --git a/native/cocos/core/assets/ImageAsset.cpp b/native/cocos/core/assets/ImageAsset.cpp index 2b47564375..1cbf88d5b9 100644 --- a/native/cocos/core/assets/ImageAsset.cpp +++ b/native/cocos/core/assets/ImageAsset.cpp @@ -37,9 +37,9 @@ ImageAsset::~ImageAsset() { } } -void ImageAsset::setNativeAsset(const cc::any &obj) { +void ImageAsset::setNativeAsset(const ccstd::any &obj) { if (obj.has_value()) { - auto **pImage = const_cast(cc::any_cast(&obj)); + auto **pImage = const_cast(ccstd::any_cast(&obj)); if (pImage != nullptr) { Image *image = *pImage; image->takeData(&_data); @@ -50,7 +50,7 @@ void ImageAsset::setNativeAsset(const cc::any &obj) { _format = static_cast(image->getRenderFormat()); _url = image->getFilePath(); } else { - const auto *imageSource = cc::any_cast(&obj); + const auto *imageSource = ccstd::any_cast(&obj); if (imageSource != nullptr) { _arrayBuffer = imageSource->data; _data = const_cast(_arrayBuffer->getData()); diff --git a/native/cocos/core/assets/ImageAsset.h b/native/cocos/core/assets/ImageAsset.h index 3bba586330..617995f7ed 100644 --- a/native/cocos/core/assets/ImageAsset.h +++ b/native/cocos/core/assets/ImageAsset.h @@ -58,8 +58,8 @@ public: ~ImageAsset() override; //minggo: do not need it in c++. - // cc::any getNativeAsset() const override { return cc::any(_nativeData); } - void setNativeAsset(const cc::any &obj) override; + // ccstd::any getNativeAsset() const override { return ccstd::any(_nativeData); } + void setNativeAsset(const ccstd::any &obj) override; /** * @en Image data. diff --git a/native/cocos/core/assets/Material.cpp b/native/cocos/core/assets/Material.cpp index 641dd940c2..23c8c28ced 100644 --- a/native/cocos/core/assets/Material.cpp +++ b/native/cocos/core/assets/Material.cpp @@ -231,20 +231,20 @@ const MaterialPropertyVariant *Material::getProperty(const ccstd::string &name, } void Material::fillInfo(const IMaterialInfo &info) { - if (info.technique != cc::nullopt) { + if (info.technique != ccstd::nullopt) { _techIdx = info.technique.value(); } if (info.effectAsset != nullptr) { _effectAsset = info.effectAsset; - } else if (info.effectName != cc::nullopt) { + } else if (info.effectName != ccstd::nullopt) { _effectAsset = EffectAsset::get(info.effectName.value()); } - if (info.defines != cc::nullopt) { + if (info.defines != ccstd::nullopt) { prepareInfo(info.defines.value(), _defines); } - if (info.states != cc::nullopt) { + if (info.states != ccstd::nullopt) { prepareInfo(info.states.value(), _states); } } @@ -364,18 +364,18 @@ bool Material::uploadProperty(scene::Pass *pass, const ccstd::string &name, cons const auto type = scene::Pass::getTypeFromHandle(handle); if (type < gfx::Type::SAMPLER1D) { if (val.index() == MATERIAL_PROPERTY_INDEX_LIST) { - pass->setUniformArray(handle, cc::get(val)); + pass->setUniformArray(handle, ccstd::get(val)); } else if (val.index() == MATERIAL_PROPERTY_INDEX_SINGLE) { const auto &passProps = pass->getProperties(); auto iter = passProps.find(name); if (iter != passProps.end() && iter->second.linear.has_value()) { - CC_ASSERT(cc::holds_alternative(val)); - const auto &prop = cc::get(val); + CC_ASSERT(ccstd::holds_alternative(val)); + const auto &prop = ccstd::get(val); Vec4 srgb; - if (cc::holds_alternative(prop)) { - srgb = cc::get(prop).toVec4(); - } else if (cc::holds_alternative(prop)) { - srgb = cc::get(prop); + if (ccstd::holds_alternative(prop)) { + srgb = ccstd::get(prop).toVec4(); + } else if (ccstd::holds_alternative(prop)) { + srgb = ccstd::get(prop); } else { CC_ASSERT(false); } @@ -385,18 +385,18 @@ bool Material::uploadProperty(scene::Pass *pass, const ccstd::string &name, cons linear.w = srgb.w; pass->setUniform(handle, linear); } else { - pass->setUniform(handle, cc::get(val)); + pass->setUniform(handle, ccstd::get(val)); } } else { pass->resetUniform(name); } } else if (val.index() == MATERIAL_PROPERTY_INDEX_LIST) { - const auto &textureArray = cc::get(val); + const auto &textureArray = ccstd::get(val); for (size_t i = 0; i < textureArray.size(); i++) { bindTexture(pass, handle, textureArray[i], static_cast(i)); } } else if (val.index() == MATERIAL_PROPERTY_INDEX_SINGLE) { - bindTexture(pass, handle, cc::get(val)); + bindTexture(pass, handle, ccstd::get(val)); } else { pass->resetTexture(name); } @@ -409,9 +409,9 @@ void Material::bindTexture(scene::Pass *pass, uint32_t handle, const MaterialPro } const uint32_t binding = scene::Pass::getBindingFromHandle(handle); - if (const auto *pTexture = cc::get_if>(&val)) { + if (const auto *pTexture = ccstd::get_if>(&val)) { pass->bindTexture(binding, const_cast(pTexture->get()), index); - } else if (const auto *pTextureBase = cc::get_if>(&val)) { + } else if (const auto *pTextureBase = ccstd::get_if>(&val)) { auto *textureBase = pTextureBase->get(); gfx::Texture *texture = nullptr; if (textureBase != nullptr) { @@ -432,7 +432,7 @@ void Material::bindTexture(scene::Pass *pass, uint32_t handle, const MaterialPro } } -void Material::initDefault(const cc::optional &uuid) { +void Material::initDefault(const ccstd::optional &uuid) { Super::initDefault(uuid); MacroRecord defines{{"USE_COLOR", true}}; IMaterialInfo info; diff --git a/native/cocos/core/assets/Material.h b/native/cocos/core/assets/Material.h index aba8ea4619..d29fa0a9fb 100644 --- a/native/cocos/core/assets/Material.h +++ b/native/cocos/core/assets/Material.h @@ -28,8 +28,8 @@ #include "base/Ptr.h" #include "base/std/container/string.h" #include "base/std/container/unordered_map.h" -#include "cocos/base/Optional.h" -#include "cocos/base/Variant.h" +#include "base/std/optional.h" +#include "base/std/variant.h" #include "core/assets/EffectAsset.h" namespace cc { @@ -57,25 +57,25 @@ struct IMaterialInfo { * @zh * 这个材质将使用的 EffectAsset,通过 effect 名指定,和 `effectAsset` 至少要指定一个。 */ - cc::optional effectName; + ccstd::optional effectName; /** * @en * The index of the technique to use. * @zh * 这个材质将使用第几个 technique,默认为 0。 */ - cc::optional technique; + ccstd::optional technique; - using DefinesType = cc::variant>; + using DefinesType = ccstd::variant>; /** * @en * The shader macro definitions. Default to 0 or the specified value in [[EffectAsset]]. * @zh * 这个材质定义的预处理宏,默认全为 0,或 [[EffectAsset]] 中的指定值。 */ - cc::optional defines; + ccstd::optional defines; - using PassOverridesType = cc::variant>; + using PassOverridesType = ccstd::variant>; /** * @en * The override values on top of the pipeline states specified in [[EffectAsset]]. @@ -83,7 +83,7 @@ struct IMaterialInfo { * 这个材质的自定义管线状态,将覆盖 effect 中的属性。
* 注意在可能的情况下请尽量少的自定义管线状态,以减小对渲染效率的影响。 */ - cc::optional states; + ccstd::optional states; }; class Material : public Asset { @@ -110,7 +110,7 @@ public: void initialize(const IMaterialInfo &info); void reset(const IMaterialInfo &info); - void initDefault(const cc::optional &uuid) override; + void initDefault(const ccstd::optional &uuid) override; bool validate() const override; /** @@ -321,7 +321,7 @@ protected: template void prepareInfo(const T1 &patch, ccstd::vector &cur) { - auto *pOneElement = cc::get_if(&patch); + auto *pOneElement = ccstd::get_if(&patch); if (pOneElement != nullptr) { size_t len = _effectAsset != nullptr ? _effectAsset->_techniques[_techIdx].passes.size() : 1; @@ -337,7 +337,7 @@ protected: cur[i] = patchArray[i]; } } else { - auto *pPatchArray = cc::get_if>(&patch); + auto *pPatchArray = ccstd::get_if>(&patch); if (pPatchArray != nullptr) { const auto &patchArray = *pPatchArray; size_t len = patchArray.size(); diff --git a/native/cocos/core/assets/RenderTexture.cpp b/native/cocos/core/assets/RenderTexture.cpp index b4507ca5ab..1f62648678 100644 --- a/native/cocos/core/assets/RenderTexture.cpp +++ b/native/cocos/core/assets/RenderTexture.cpp @@ -127,7 +127,7 @@ void RenderTexture::initWindow(const IRenderTextureCreateInfo &info) { } } -void RenderTexture::initDefault(const cc::optional &uuid) { +void RenderTexture::initDefault(const ccstd::optional &uuid) { Super::initDefault(uuid); _width = 1; _height = 1; diff --git a/native/cocos/core/assets/RenderTexture.h b/native/cocos/core/assets/RenderTexture.h index d4612f9314..d9afc37f5b 100644 --- a/native/cocos/core/assets/RenderTexture.h +++ b/native/cocos/core/assets/RenderTexture.h @@ -31,10 +31,10 @@ namespace cc { struct IRenderTextureCreateInfo { - cc::optional name; + ccstd::optional name; uint32_t width; uint32_t height; - cc::optional passInfo; + ccstd::optional passInfo; }; namespace scene { class RenderWindow; @@ -94,7 +94,7 @@ public: void initWindow(); void initWindow(const IRenderTextureCreateInfo &info); - void initDefault(const cc::optional &uuid) override; + void initDefault(const ccstd::optional &uuid) override; bool validate() const override; diff --git a/native/cocos/core/assets/RenderingSubMesh.cpp b/native/cocos/core/assets/RenderingSubMesh.cpp index 770180f0fc..04f416d0e4 100644 --- a/native/cocos/core/assets/RenderingSubMesh.cpp +++ b/native/cocos/core/assets/RenderingSubMesh.cpp @@ -85,7 +85,7 @@ const IGeometricInfo &RenderingSubMesh::getGeometricInfo() { auto index = static_cast(_subMeshIdx.value()); const auto &positionsVar = _mesh->readAttribute(index, gfx::ATTR_NAME_POSITION); - const auto *pPositions = cc::get_if(&positionsVar); + const auto *pPositions = ccstd::get_if(&positionsVar); if (pPositions != nullptr) { const auto &positions = *pPositions; const auto &indicesVar = _mesh->readIndices(index); @@ -257,7 +257,7 @@ const gfx::BufferList &RenderingSubMesh::getJointMappedBuffers() { mapBuffer( dataView, [&](const DataVariant &cur, uint32_t /*idx*/, const DataView & /*view*/) -> DataVariant { - auto iter = std::find(idxMap.begin(), idxMap.end(), cc::get<0>(cur)); + auto iter = std::find(idxMap.begin(), idxMap.end(), ccstd::get<0>(cur)); if (iter != idxMap.end()) { return static_cast(iter - idxMap.begin()); } diff --git a/native/cocos/core/assets/RenderingSubMesh.h b/native/cocos/core/assets/RenderingSubMesh.h index e18fc771c4..ff0fa599c4 100644 --- a/native/cocos/core/assets/RenderingSubMesh.h +++ b/native/cocos/core/assets/RenderingSubMesh.h @@ -28,7 +28,7 @@ #include "3d/assets/Types.h" #include "base/RefCounted.h" #include "base/RefVector.h" -#include "base/Variant.h" +#include "base/std/variant.h" #include "core/TypedArray.h" #include "core/Types.h" #include "renderer/gfx-base/GFXDef.h" @@ -52,13 +52,13 @@ struct IGeometricInfo { * @en Indices data * @zh 索引数据。 */ - cc::optional indices; + ccstd::optional indices; /** * @en Whether the geometry is treated as double sided * @zh 是否将图元按双面对待。 */ - cc::optional doubleSided; + ccstd::optional doubleSided; /** * @en The bounding box @@ -158,7 +158,7 @@ public: inline gfx::InputAssemblerInfo &getIaInfo() { return _iaInfo; } inline void setDrawInfo(const gfx::DrawInfo &info) { _drawInfo = info; } - inline cc::optional &getDrawInfo() { return _drawInfo; } + inline ccstd::optional &getDrawInfo() { return _drawInfo; } /** * @en The vertex buffer for joint after mapping @@ -181,14 +181,14 @@ public: inline Mesh *getMesh() const { return _mesh; } inline void setSubMeshIdx(uint32_t idx) { _subMeshIdx = idx; } - inline const cc::optional &getSubMeshIdx() const { return _subMeshIdx; } + inline const ccstd::optional &getSubMeshIdx() const { return _subMeshIdx; } private: gfx::Buffer *allocVertexIdBuffer(gfx::Device *device); // Mesh will includes RenderingSubMesh, so use Mesh* here. Mesh *_mesh{nullptr}; - cc::optional _subMeshIdx; + ccstd::optional _subMeshIdx; ccstd::vector _flatBuffers; @@ -197,9 +197,9 @@ private: ccstd::vector _jointMappedBufferIndices; - cc::optional _vertexIdChannel; + ccstd::optional _vertexIdChannel; - cc::optional _geometricInfo; + ccstd::optional _geometricInfo; // As gfx::InputAssemblerInfo needs the data structure, so not use IntrusivePtr. RefVector _vertexBuffers; @@ -214,7 +214,7 @@ private: gfx::InputAssemblerInfo _iaInfo; - cc::optional _drawInfo; + ccstd::optional _drawInfo; CC_DISALLOW_COPY_MOVE_ASSIGN(RenderingSubMesh); }; diff --git a/native/cocos/core/assets/SceneAsset.cpp b/native/cocos/core/assets/SceneAsset.cpp index 3c7cb096d7..2ac304816e 100644 --- a/native/cocos/core/assets/SceneAsset.cpp +++ b/native/cocos/core/assets/SceneAsset.cpp @@ -37,7 +37,7 @@ bool SceneAsset::validate() const { void SceneAsset::setScene(Scene *scene) { _scene = scene; }; -void SceneAsset::initDefault(const cc::optional &uuid) { +void SceneAsset::initDefault(const ccstd::optional &uuid) { Super::initDefault(uuid); _scene = ccnew Scene("New Scene"); } diff --git a/native/cocos/core/assets/SceneAsset.h b/native/cocos/core/assets/SceneAsset.h index c295bf0b2c..e7d5c52f6d 100644 --- a/native/cocos/core/assets/SceneAsset.h +++ b/native/cocos/core/assets/SceneAsset.h @@ -38,7 +38,7 @@ public: SceneAsset(); ~SceneAsset() override; - void initDefault(const cc::optional &uuid) override; + void initDefault(const ccstd::optional &uuid) override; bool validate() const override; diff --git a/native/cocos/core/assets/Texture2D.cpp b/native/cocos/core/assets/Texture2D.cpp index f4f7b2497b..7285fd6b57 100644 --- a/native/cocos/core/assets/Texture2D.cpp +++ b/native/cocos/core/assets/Texture2D.cpp @@ -142,7 +142,7 @@ void Texture2D::releaseTexture() { destroy(); } -cc::any Texture2D::serialize(const cc::any & /*ctxForExporting*/) { +ccstd::any Texture2D::serialize(const ccstd::any & /*ctxForExporting*/) { // if (EDITOR || TEST) { // return { // base: super._serialize(ctxForExporting), @@ -161,8 +161,8 @@ cc::any Texture2D::serialize(const cc::any & /*ctxForExporting*/) { return nullptr; } -void Texture2D::deserialize(const cc::any &serializedData, const cc::any &handle) { - const auto *data = cc::any_cast(&serializedData); +void Texture2D::deserialize(const ccstd::any &serializedData, const ccstd::any &handle) { + const auto *data = ccstd::any_cast(&serializedData); if (data == nullptr) { CC_LOG_WARNING("serializedData is not ITexture2DSerializeData"); return; @@ -203,10 +203,10 @@ gfx::TextureViewInfo Texture2D::getGfxTextureViewCreateInfo(gfx::Texture *textur return texViewInfo; } -void Texture2D::initDefault(const cc::optional &uuid) { +void Texture2D::initDefault(const ccstd::optional &uuid) { Super::initDefault(uuid); auto *imageAsset = ccnew ImageAsset(); - imageAsset->initDefault(cc::nullopt); + imageAsset->initDefault(ccstd::nullopt); setImage(imageAsset); } diff --git a/native/cocos/core/assets/Texture2D.h b/native/cocos/core/assets/Texture2D.h index 9f0d621ef3..754281791c 100644 --- a/native/cocos/core/assets/Texture2D.h +++ b/native/cocos/core/assets/Texture2D.h @@ -26,7 +26,7 @@ #pragma once #include "base/Ptr.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "core/assets/Asset.h" #include "core/assets/AssetEnum.h" #include "core/assets/SimpleTexture.h" @@ -60,28 +60,28 @@ struct ITexture2DCreateInfo { * @zh 像素格式。 * @default PixelFormat.RGBA8888 */ - cc::optional format; + ccstd::optional format; /** * @en The mipmap level count * @zh mipmap 层级。 * @default 1 */ - cc::optional mipmapLevel; + ccstd::optional mipmapLevel; /** * @en The selected base mipmap level * @zh 选择使用的最小 mipmap 层级。 * @default 1 */ - cc::optional baseLevel; + ccstd::optional baseLevel; /** * @en The selected maximum mipmap level * @zh 选择使用的最大 mipmap 层级。 * @default 1 */ - cc::optional maxLevel; + ccstd::optional maxLevel; }; /** @@ -186,18 +186,18 @@ public: /** * @return */ - cc::any serialize(const cc::any &ctxForExporting) override; + ccstd::any serialize(const ccstd::any &ctxForExporting) override; /** * * @param data */ - void deserialize(const cc::any &serializedData, const cc::any &handle) override; + void deserialize(const ccstd::any &serializedData, const ccstd::any &handle) override; gfx::TextureInfo getGfxTextureCreateInfo(gfx::TextureUsageBit usage, gfx::Format format, uint32_t levelCount, gfx::TextureFlagBit flags) override; gfx::TextureViewInfo getGfxTextureViewCreateInfo(gfx::Texture *texture, gfx::Format format, uint32_t baseLevel, uint32_t levelCount) override; - void initDefault(const cc::optional &uuid) override; + void initDefault(const ccstd::optional &uuid) override; bool validate() const override; diff --git a/native/cocos/core/assets/TextureBase.cpp b/native/cocos/core/assets/TextureBase.cpp index 792f6889d0..33aebc4467 100644 --- a/native/cocos/core/assets/TextureBase.cpp +++ b/native/cocos/core/assets/TextureBase.cpp @@ -126,7 +126,7 @@ gfx::Sampler *TextureBase::getGFXSampler() const { return _gfxSampler; } -cc::any TextureBase::serialize(const cc::any & /*ctxForExporting*/) { +ccstd::any TextureBase::serialize(const ccstd::any & /*ctxForExporting*/) { //cjh TODO: if (EDITOR || TEST) { // return `${this._minFilter},${this._magFilter},${ // this._wrapS},${this._wrapT},${ @@ -135,8 +135,8 @@ cc::any TextureBase::serialize(const cc::any & /*ctxForExporting*/) { return ccstd::string(""); } -void TextureBase::deserialize(const cc::any &serializedData, const cc::any & /*handle*/) { - const auto *pData = cc::any_cast(&serializedData); +void TextureBase::deserialize(const ccstd::any &serializedData, const ccstd::any & /*handle*/) { + const auto *pData = ccstd::any_cast(&serializedData); if (pData == nullptr) { return; } @@ -165,7 +165,7 @@ gfx::Format TextureBase::getGFXFormat() const { return getGFXPixelFormat(_format); } -void TextureBase::setGFXFormat(const cc::optional &format) { +void TextureBase::setGFXFormat(const ccstd::optional &format) { _format = format.has_value() ? format.value() : PixelFormat::RGBA8888; } diff --git a/native/cocos/core/assets/TextureBase.h b/native/cocos/core/assets/TextureBase.h index c454ba2909..88504ad77b 100644 --- a/native/cocos/core/assets/TextureBase.h +++ b/native/cocos/core/assets/TextureBase.h @@ -31,7 +31,7 @@ #include "core/assets/AssetEnum.h" #include "renderer/gfx-base/GFXDef.h" -#include "cocos/base/Any.h" +#include "base/std/any.h" namespace cc { @@ -200,13 +200,13 @@ public: /** * @return */ - cc::any serialize(const cc::any &ctxForExporting) override; + ccstd::any serialize(const ccstd::any &ctxForExporting) override; /** * * @param data */ - void deserialize(const cc::any &serializedData, const cc::any &handle) override; + void deserialize(const ccstd::any &serializedData, const ccstd::any &handle) override; protected: static gfx::Device *getGFXDevice(); @@ -214,7 +214,7 @@ protected: gfx::Format getGFXFormat() const; - void setGFXFormat(const cc::optional &format); + void setGFXFormat(const ccstd::optional &format); private: void notifySamplerUpdated(); diff --git a/native/cocos/core/assets/TextureCube.cpp b/native/cocos/core/assets/TextureCube.cpp index e577bc4fd6..9b5fb0babf 100644 --- a/native/cocos/core/assets/TextureCube.cpp +++ b/native/cocos/core/assets/TextureCube.cpp @@ -96,7 +96,7 @@ void TextureCube::setMipmaps(const ccstd::vector &value) { } else { reset({0, 0, - cc::nullopt, + ccstd::nullopt, static_cast(_mipmaps.size()), _baseLevel, _maxLevel}); @@ -160,7 +160,7 @@ bool TextureCube::destroy() { return Super::destroy(); } -cc::any TextureCube::serialize(const cc::any & /*ctxForExporting*/) { +ccstd::any TextureCube::serialize(const ccstd::any & /*ctxForExporting*/) { //cjh TODO: if (EDITOR || TEST) { // return { // base: super._serialize(ctxForExporting), @@ -185,8 +185,8 @@ cc::any TextureCube::serialize(const cc::any & /*ctxForExporting*/) { return nullptr; } -void TextureCube::deserialize(const cc::any &serializedData, const cc::any &handle) { - const auto *data = cc::any_cast(&serializedData); +void TextureCube::deserialize(const ccstd::any &serializedData, const ccstd::any &handle) { + const auto *data = ccstd::any_cast(&serializedData); if (data == nullptr) { return; } @@ -242,11 +242,11 @@ gfx::TextureViewInfo TextureCube::getGfxTextureViewCreateInfo(gfx::Texture *text return texViewInfo; } -void TextureCube::initDefault(const cc::optional &uuid) { +void TextureCube::initDefault(const ccstd::optional &uuid) { Super::initDefault(uuid); auto *imageAsset = ccnew ImageAsset(); - imageAsset->initDefault(cc::nullopt); + imageAsset->initDefault(ccstd::nullopt); ITextureCubeMipmap mipmap; diff --git a/native/cocos/core/assets/TextureCube.h b/native/cocos/core/assets/TextureCube.h index f4fa376085..7f8dbcea7d 100644 --- a/native/cocos/core/assets/TextureCube.h +++ b/native/cocos/core/assets/TextureCube.h @@ -165,13 +165,13 @@ public: */ bool destroy() override; - cc::any serialize(const cc::any &ctxForExporting) override; - void deserialize(const cc::any &serializedData, const cc::any &handle) override; + ccstd::any serialize(const ccstd::any &ctxForExporting) override; + void deserialize(const ccstd::any &serializedData, const ccstd::any &handle) override; gfx::TextureInfo getGfxTextureCreateInfo(gfx::TextureUsageBit usage, gfx::Format format, uint32_t levelCount, gfx::TextureFlagBit flags) override; gfx::TextureViewInfo getGfxTextureViewCreateInfo(gfx::Texture *texture, gfx::Format format, uint32_t baseLevel, uint32_t levelCount) override; - void initDefault(const cc::optional &uuid) override; + void initDefault(const ccstd::optional &uuid) override; bool validate() const override; // diff --git a/native/cocos/core/data/deserializer/EffectAssetDeserializer.cpp b/native/cocos/core/data/deserializer/EffectAssetDeserializer.cpp index a3b0943be8..e0d322d864 100644 --- a/native/cocos/core/data/deserializer/EffectAssetDeserializer.cpp +++ b/native/cocos/core/data/deserializer/EffectAssetDeserializer.cpp @@ -74,7 +74,7 @@ static MacroRecord jsonToMacroRecord(const rapidjson::Value &embeddedMacrosVal) const auto *name = macro.name.GetString(); const auto &value = macro.value; - // using MacroValue = cc::variant; + // using MacroValue = ccstd::variant; // MacroValue only support one of int32_t, float, bool, ccstd::string if (value.IsInt()) { cEmbeddedMacros.emplace(name, value.GetInt()); @@ -358,7 +358,7 @@ static void jsonToBlendTarget(const rapidjson::Value &val, BlendTargetInfo *outB } } -static void deserializeGfxColor(const rapidjson::Value &color, cc::optional &gfxColor) { +static void deserializeGfxColor(const rapidjson::Value &color, ccstd::optional &gfxColor) { if (gfxColor.has_value()) { if (color.HasMember("x")) { gfxColor->x = color["x"].GetFloat(); diff --git a/native/cocos/core/geometry/Intersect.cpp b/native/cocos/core/geometry/Intersect.cpp index 2153349d32..9b80aed191 100644 --- a/native/cocos/core/geometry/Intersect.cpp +++ b/native/cocos/core/geometry/Intersect.cpp @@ -211,7 +211,7 @@ float rayCapsule(const Ray &ray, const Capsule &capsule) { } namespace { -void fillResult(float *minDis, ERaycastMode m, float d, float i0, float i1, float i2, cc::optional> &r) { +void fillResult(float *minDis, ERaycastMode m, float d, float i0, float i1, float i2, ccstd::optional> &r) { if (m == ERaycastMode::CLOSEST) { if (*minDis > d || *minDis == 0.0F) { *minDis = d; @@ -234,8 +234,8 @@ void fillResult(float *minDis, ERaycastMode m, float d, float i0, float i1, floa float narrowphase(float *minDis, const Float32Array &vb, const IBArray &ib, gfx::PrimitiveMode pm, const Ray &ray, IRaySubMeshOptions *opt) { Triangle tri; - auto ibSize = cc::visit([](auto &arr) { return arr.length(); }, ib); - return cc::visit([&](auto &ib) { + auto ibSize = ccstd::visit([](auto &arr) { return arr.length(); }, ib); + return ccstd::visit([&](auto &ib) { if (pm == gfx::PrimitiveMode::TRIANGLE_LIST) { auto cnt = ibSize; for (auto j = 0; j < cnt; j += 3) { @@ -283,7 +283,7 @@ float narrowphase(float *minDis, const Float32Array &vb, const IBArray &ib, gfx: } return *minDis; }, - ib); + ib); } } // namespace diff --git a/native/cocos/core/geometry/Spec.h b/native/cocos/core/geometry/Spec.h index ec0c674f76..d50120ba50 100644 --- a/native/cocos/core/geometry/Spec.h +++ b/native/cocos/core/geometry/Spec.h @@ -2,7 +2,9 @@ #include #include -#include "base/Optional.h" + +#include "base/std/container/vector.h" +#include "base/std/optional.h" namespace cc { namespace geometry { @@ -109,7 +111,7 @@ struct IRaySubMeshOptions { * @zh * 用于存储射线检测结果的数组。 */ - cc::optional> result{}; + ccstd::optional> result{}; /** * @en @@ -133,7 +135,7 @@ struct IRayMeshOptions : public IRaySubMeshOptions { * @zh * 子网格的索引。 */ - cc::optional> subIndices{}; + ccstd::optional> subIndices{}; }; /** @@ -145,4 +147,4 @@ struct IRayMeshOptions : public IRaySubMeshOptions { using IRayModelOptions = IRayMeshOptions; } // namespace geometry -} // namespace cc \ No newline at end of file +} // namespace cc diff --git a/native/cocos/core/platform/Debug.cpp b/native/cocos/core/platform/Debug.cpp index 8691cf0ea2..ded12ea317 100644 --- a/native/cocos/core/platform/Debug.cpp +++ b/native/cocos/core/platform/Debug.cpp @@ -76,7 +76,7 @@ ccstd::string getTypedFormatter(DebugMode mode, uint32_t id) { return msg; } -void printLog(DebugMode mode, const ccstd::string &fmt, cc::any *arr, int paramsLength) { +void printLog(DebugMode mode, const ccstd::string &fmt, ccstd::any *arr, int paramsLength) { ccstd::string msg = fmt; const ccstd::string &prefix = getPrefixTag(mode); LogLevel logLevel = getLogLevel(mode); @@ -90,35 +90,35 @@ void printLog(DebugMode mode, const ccstd::string &fmt, cc::any *arr, int params } if (arr[i].type() == typeid(const ccstd::string)) { - const ccstd::string s = cc::any_cast(arr[i]); + const ccstd::string s = ccstd::any_cast(arr[i]); if (needToReplace) { msg.replace(pos, 2, s); } else { msg += " " + s; } } else if (arr[i].type() == typeid(ccstd::string)) { - ccstd::string s = cc::any_cast(arr[i]); + ccstd::string s = ccstd::any_cast(arr[i]); if (needToReplace) { msg.replace(pos, 2, s); } else { msg += " " + s; } } else if (arr[i].type() == typeid(int)) { - int value = cc::any_cast(arr[i]); + int value = ccstd::any_cast(arr[i]); if (needToReplace) { msg.replace(pos, 2, std::to_string(value)); } else { msg += " " + std::to_string(value); } } else if (arr[i].type() == typeid(float)) { - auto value = cc::any_cast(arr[i]); + auto value = ccstd::any_cast(arr[i]); if (needToReplace) { msg.replace(pos, 2, std::to_string(value)); } else { msg += " " + std::to_string(value); } } else if (arr[i].type() == typeid(const char *)) { - ccstd::string s = cc::any_cast(arr[i]); + ccstd::string s = ccstd::any_cast(arr[i]); if (needToReplace) { msg.replace(pos, 2, s); } else { @@ -134,4 +134,4 @@ void printLog(DebugMode mode, const ccstd::string &fmt, cc::any *arr, int params } } // namespace debug -} //namespace cc \ No newline at end of file +} //namespace cc diff --git a/native/cocos/core/platform/Debug.h b/native/cocos/core/platform/Debug.h index a596264f79..dec9852dff 100644 --- a/native/cocos/core/platform/Debug.h +++ b/native/cocos/core/platform/Debug.h @@ -25,8 +25,8 @@ THE SOFTWARE. #pragma once -#include "base/Any.h" #include "base/Log.h" +#include "base/std/any.h" #include "base/std/container/string.h" #include "core/builtin/DebugInfos.h" @@ -95,7 +95,7 @@ enum class DebugMode { */ template -void log(cc::any message, Args... optionalParams); +void log(ccstd::any message, Args... optionalParams); /** * @en @@ -111,7 +111,7 @@ void log(cc::any message, Args... optionalParams); * This gives you additional control over the format of the output. */ template -void warn(cc::any message, Args... optionalParams); +void warn(ccstd::any message, Args... optionalParams); /** * @en @@ -127,7 +127,7 @@ void warn(cc::any message, Args... optionalParams); * This gives you additional control over the format of the output. */ template -void error(cc::any message, Args... optionalParams); +void error(ccstd::any message, Args... optionalParams); /** * @en @@ -141,7 +141,7 @@ void error(cc::any message, Args... optionalParams); */ template -void _assert(cc::any value, ccstd::string message, Args... optionalParams); // NOLINT //assert is a reserved word +void _assert(ccstd::any value, ccstd::string message, Args... optionalParams); // NOLINT //assert is a reserved word /** * @en Outputs a message at the "debug" log level. @@ -183,13 +183,13 @@ T unpackParams(T value) { return value; } -void printLog(DebugMode mode, const ccstd::string &fmt, cc::any *arr, int paramsLength); +void printLog(DebugMode mode, const ccstd::string &fmt, ccstd::any *arr, int paramsLength); template void logID(uint32_t id, Args... optionalParams) { ccstd::string msg = getTypedFormatter(DebugMode::VERBOSE, id); int size = sizeof...(optionalParams); - cc::any arr[] = {0, unpackParams(optionalParams)...}; + ccstd::any arr[] = {0, unpackParams(optionalParams)...}; printLog(DebugMode::VERBOSE, msg, arr, size); } @@ -197,7 +197,7 @@ template void warnID(uint32_t id, Args... optionalParams) { ccstd::string msg = getTypedFormatter(DebugMode::WARN, id); int size = sizeof...(optionalParams); - cc::any arr[] = {0, unpackParams(optionalParams)...}; + ccstd::any arr[] = {0, unpackParams(optionalParams)...}; printLog(DebugMode::WARN, msg, arr, size); } @@ -205,7 +205,7 @@ template void errorID(uint32_t id, Args... optionalParams) { ccstd::string msg = getTypedFormatter(DebugMode::ERROR_MODE, id); int size = sizeof...(optionalParams); - cc::any arr[] = {0, unpackParams(optionalParams)...}; + ccstd::any arr[] = {0, unpackParams(optionalParams)...}; printLog(DebugMode::ERROR_MODE, msg, arr, size); } @@ -216,7 +216,7 @@ void assertID(bool condition, uint32_t id, Args... optionalParams) { } ccstd::string msg = getTypedFormatter(DebugMode::INFO, id); int size = sizeof...(optionalParams); - cc::any arr[] = {0, unpackParams(optionalParams)...}; + ccstd::any arr[] = {0, unpackParams(optionalParams)...}; printLog(DebugMode::INFO, msg, arr, size); CC_ASSERT(false); } diff --git a/native/cocos/core/scene-graph/Node.h b/native/cocos/core/scene-graph/Node.h index c44fa04774..f90365cc31 100644 --- a/native/cocos/core/scene-graph/Node.h +++ b/native/cocos/core/scene-graph/Node.h @@ -27,7 +27,7 @@ #include "base/Ptr.h" #include "base/TypeDef.h" -#include "cocos/base/Any.h" +#include "base/std/any.h" //#include "core/components/Component.h" //#include "core/event/Event.h" #include "core/event/EventTypesToJS.h" diff --git a/native/cocos/core/scene-graph/NodeEventProcessor.h b/native/cocos/core/scene-graph/NodeEventProcessor.h index 507aecd107..a04e420433 100644 --- a/native/cocos/core/scene-graph/NodeEventProcessor.h +++ b/native/cocos/core/scene-graph/NodeEventProcessor.h @@ -27,8 +27,8 @@ #include #include "base/memory/Memory.h" +#include "base/std/any.h" #include "base/std/container/string.h" -#include "cocos/base/Any.h" #include "core/event/CallbacksInvoker.h" //#include "core/event/Event.h" #include "core/scene-graph/NodeEvent.h" @@ -130,7 +130,7 @@ public: * @param args - The arguments to be passed to the callback */ template - void emit(const CallbacksInvoker::KeyType &type, Args &&... args); + void emit(const CallbacksInvoker::KeyType &type, Args &&...args); void targetOff(const CallbacksInvoker::KeyType &target); @@ -190,7 +190,7 @@ private: }; template -void NodeEventProcessor::emit(const CallbacksInvoker::KeyType &type, Args &&... args) { +void NodeEventProcessor::emit(const CallbacksInvoker::KeyType &type, Args &&...args) { if (_bubblingTargets != nullptr) { _bubblingTargets->emit(type, std::forward(args)...); } diff --git a/native/cocos/engine/Engine.cpp b/native/cocos/engine/Engine.cpp index 9e5abde3b0..1412813ede 100644 --- a/native/cocos/engine/Engine.cpp +++ b/native/cocos/engine/Engine.cpp @@ -126,7 +126,7 @@ Engine::~Engine() { // Profiler depends on DebugRenderer, should delete it after deleting Profiler, // and delete DebugRenderer after RenderPipeline::destroy which destroy DebugRenderer. delete _debugRenderer; - + //TODO(): Delete some global objects. FreeTypeFontFace::destroyFreeType(); @@ -369,7 +369,7 @@ bool Engine::dispatchWindowEvent(const WindowEvent &ev) { } else if (ev.type == WindowEvent::Type::SIZE_CHANGED || ev.type == WindowEvent::Type::RESIZED) { cc::EventDispatcher::dispatchResizeEvent(ev.width, ev.height); - auto* w = CC_GET_PLATFORM_INTERFACE(ISystemWindow); + auto *w = CC_GET_PLATFORM_INTERFACE(ISystemWindow); w->setViewSize(ev.width, ev.height); isHandled = true; } else if (ev.type == WindowEvent::Type::HIDDEN || diff --git a/native/cocos/platform/java/jni/glue/JniNativeGlue.h b/native/cocos/platform/java/jni/glue/JniNativeGlue.h index 868fa7d820..eefa172c40 100644 --- a/native/cocos/platform/java/jni/glue/JniNativeGlue.h +++ b/native/cocos/platform/java/jni/glue/JniNativeGlue.h @@ -119,7 +119,7 @@ public: int32_t getWidth() const; int32_t getHeight() const; - bool isAnimating() const {return _animating;} + bool isAnimating() const { return _animating; } private: void preExecCmd(JniCommand cmd); diff --git a/native/cocos/platform/linux/modules/SystemWindow.h b/native/cocos/platform/linux/modules/SystemWindow.h index 47659c554e..c92cfc8c23 100644 --- a/native/cocos/platform/linux/modules/SystemWindow.h +++ b/native/cocos/platform/linux/modules/SystemWindow.h @@ -48,7 +48,10 @@ public: uintptr_t getWindowHandler() const override; uintptr_t getDisplay() const; Size getViewSize() const override; - void setViewSize(uint32_t w, uint32_t h) override { _width = w; _height = h; } + void setViewSize(uint32_t w, uint32_t h) override { + _width = w; + _height = h; + } /* @brief enable/disable(lock) the cursor, default is enabled */ diff --git a/native/cocos/platform/mac/modules/SystemWindow.h b/native/cocos/platform/mac/modules/SystemWindow.h index dd173080f9..6879347397 100644 --- a/native/cocos/platform/mac/modules/SystemWindow.h +++ b/native/cocos/platform/mac/modules/SystemWindow.h @@ -45,7 +45,10 @@ public: uintptr_t getWindowHandler() const override; Size getViewSize() const override; - void setViewSize(uint32_t w, uint32_t h) override { _width = w; _height = h; } + void setViewSize(uint32_t w, uint32_t h) override { + _width = w; + _height = h; + } /* @brief enable/disable(lock) the cursor, default is enabled */ diff --git a/native/cocos/platform/win32/modules/SystemWindow.cpp b/native/cocos/platform/win32/modules/SystemWindow.cpp index 12aaa7833d..b045cb1be3 100644 --- a/native/cocos/platform/win32/modules/SystemWindow.cpp +++ b/native/cocos/platform/win32/modules/SystemWindow.cpp @@ -26,11 +26,11 @@ #include "platform/win32/modules/SystemWindow.h" #include #include "base/Log.h" -#include "sdl2/SDL_clipboard.h" #include "bindings/event/EventDispatcher.h" #include "platform/IEventDispatch.h" -#include "platform/win32/WindowsPlatform.h" #include "platform/SDLHelper.h" +#include "platform/win32/WindowsPlatform.h" +#include "sdl2/SDL_clipboard.h" namespace cc { SystemWindow::SystemWindow(IEventDispatch *delegate) diff --git a/native/cocos/platform/win32/modules/SystemWindow.h b/native/cocos/platform/win32/modules/SystemWindow.h index 5beb18c330..4399e9eee8 100644 --- a/native/cocos/platform/win32/modules/SystemWindow.h +++ b/native/cocos/platform/win32/modules/SystemWindow.h @@ -47,7 +47,10 @@ public: int h, int flags) override; uintptr_t getWindowHandler() const override; Size getViewSize() const override; - void setViewSize(uint32_t width, uint32_t height) override { _width = width; _height = height; } + void setViewSize(uint32_t width, uint32_t height) override { + _width = width; + _height = height; + } /* @brief enable/disable(lock) the cursor, default is enabled */ diff --git a/native/cocos/primitive/Box.cpp b/native/cocos/primitive/Box.cpp index 90d5e06ead..25651f7a3a 100644 --- a/native/cocos/primitive/Box.cpp +++ b/native/cocos/primitive/Box.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "primitive/Box.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" namespace cc { namespace { @@ -56,7 +56,7 @@ const ccstd::vector> FACE_TANGENTS{ }; } // namespace -IGeometry box(const cc::optional &options) { +IGeometry box(const ccstd::optional &options) { const uint32_t ws = options->widthSegments.has_value() ? options->widthSegments.value() : 1; const uint32_t hs = options->heightSegments.has_value() ? options->heightSegments.value() : 1; const uint32_t ls = options->lengthSegments.has_value() ? options->lengthSegments.value() : 1; diff --git a/native/cocos/primitive/Box.h b/native/cocos/primitive/Box.h index 057d930d9c..a5d65b3fa2 100644 --- a/native/cocos/primitive/Box.h +++ b/native/cocos/primitive/Box.h @@ -41,7 +41,7 @@ struct IBoxOptions : public IGeometryOptions { * @zh * 立方体宽度。 */ - cc::optional width; + ccstd::optional width; /** * @en @@ -49,7 +49,7 @@ struct IBoxOptions : public IGeometryOptions { * @zh * 立方体高度。 */ - cc::optional height; + ccstd::optional height; /** * @en @@ -57,7 +57,7 @@ struct IBoxOptions : public IGeometryOptions { * @zh * 立方体长度。 */ - cc::optional length; + ccstd::optional length; /** * @en @@ -65,7 +65,7 @@ struct IBoxOptions : public IGeometryOptions { * @zh * 宽度线段数。 */ - cc::optional widthSegments; + ccstd::optional widthSegments; /** * @en @@ -73,7 +73,7 @@ struct IBoxOptions : public IGeometryOptions { * @zh * 高度线段数。 */ - cc::optional heightSegments; + ccstd::optional heightSegments; /** * @en @@ -81,7 +81,7 @@ struct IBoxOptions : public IGeometryOptions { * @zh * 长度线段数。 */ - cc::optional lengthSegments; + ccstd::optional lengthSegments; }; /** @@ -92,5 +92,5 @@ struct IBoxOptions : public IGeometryOptions { * 生成一个立方体,其大小是定义的范围且中心在原点。 * @param options 参数选项。 */ -IGeometry box(const cc::optional &options = cc::nullopt); +IGeometry box(const ccstd::optional &options = ccstd::nullopt); } // namespace cc diff --git a/native/cocos/primitive/Capsule.cpp b/native/cocos/primitive/Capsule.cpp index 29fc8dc174..7beabbc008 100644 --- a/native/cocos/primitive/Capsule.cpp +++ b/native/cocos/primitive/Capsule.cpp @@ -27,7 +27,7 @@ namespace cc { -IGeometry capsule(float radiusTop, float radiusBottom, float height, const cc::optional &opts) { +IGeometry capsule(float radiusTop, float radiusBottom, float height, const ccstd::optional &opts) { const float torsoHeight = height - radiusTop - radiusBottom; const uint32_t sides = opts.has_value() ? opts->sides : 32; const uint32_t heightSegments = opts.has_value() ? opts->heightSegments : 32; @@ -236,4 +236,4 @@ IGeometry capsule(float radiusTop, float radiusBottom, float height, const cc::o return info; } -} // namespace cc \ No newline at end of file +} // namespace cc diff --git a/native/cocos/primitive/Capsule.h b/native/cocos/primitive/Capsule.h index 8389705d75..872090b809 100644 --- a/native/cocos/primitive/Capsule.h +++ b/native/cocos/primitive/Capsule.h @@ -49,6 +49,6 @@ struct ICapsuleOptions { * @param radiusBottom 底部半径。 * @param opts 胶囊体参数选项。 */ -IGeometry capsule(float radiusTop = 0.5, float radiusBottom = 0.5, float height = 2, const cc::optional &opts = cc::nullopt); +IGeometry capsule(float radiusTop = 0.5, float radiusBottom = 0.5, float height = 2, const ccstd::optional &opts = ccstd::nullopt); } // namespace cc diff --git a/native/cocos/primitive/Circle.cpp b/native/cocos/primitive/Circle.cpp index f98a08ba88..88baad5599 100644 --- a/native/cocos/primitive/Circle.cpp +++ b/native/cocos/primitive/Circle.cpp @@ -27,7 +27,7 @@ #include "gfx-base/GFXDef-common.h" namespace cc { -IGeometry circle(cc::optional &options) { +IGeometry circle(ccstd::optional &options) { if (!options.has_value()) options = ICircleOptions(); const uint32_t segments = options->segments; ccstd::vector positions(3 * (segments + 1)); @@ -62,4 +62,4 @@ IGeometry circle(cc::optional &options) { info.primitiveMode = gfx::PrimitiveMode::TRIANGLE_FAN; return info; } -} // namespace cc \ No newline at end of file +} // namespace cc diff --git a/native/cocos/primitive/Circle.h b/native/cocos/primitive/Circle.h index 9b77f78806..b264f0d2e9 100644 --- a/native/cocos/primitive/Circle.h +++ b/native/cocos/primitive/Circle.h @@ -47,6 +47,6 @@ struct ICircleOptions : public IGeometryOptions { * 生成一个圆,其半径是单位1,中心点在原点。 * @param options 参数选项。 */ -IGeometry circle(cc::optional &options); +IGeometry circle(ccstd::optional &options); } // namespace cc diff --git a/native/cocos/primitive/Cone.cpp b/native/cocos/primitive/Cone.cpp index 45eeba124f..50951d8fd4 100644 --- a/native/cocos/primitive/Cone.cpp +++ b/native/cocos/primitive/Cone.cpp @@ -27,7 +27,7 @@ namespace cc { -IGeometry cone(float radius, float height, const cc::optional &opts) { +IGeometry cone(float radius, float height, const ccstd::optional &opts) { return cylinder(0, radius, height, opts); } diff --git a/native/cocos/primitive/Cone.h b/native/cocos/primitive/Cone.h index 48a2a15908..a0bc659d6e 100644 --- a/native/cocos/primitive/Cone.h +++ b/native/cocos/primitive/Cone.h @@ -37,6 +37,6 @@ namespace cc { */ using IConeOptions = ICylinderOptions; -IGeometry cone(float radius = 0.5F, float height = 1.0F, const cc::optional &opts = cc::nullopt); +IGeometry cone(float radius = 0.5F, float height = 1.0F, const ccstd::optional &opts = ccstd::nullopt); } // namespace cc diff --git a/native/cocos/primitive/Cylinder.cpp b/native/cocos/primitive/Cylinder.cpp index d7bb363567..7664e7c62e 100644 --- a/native/cocos/primitive/Cylinder.cpp +++ b/native/cocos/primitive/Cylinder.cpp @@ -31,7 +31,7 @@ float sign(float v) { return (v < 0 ? -1.0F : (v > 0 ? 1.0F : 0.0F)); } -IGeometry cylinder(float radiusTop, float radiusBottom, float height, const cc::optional &opts) { +IGeometry cylinder(float radiusTop, float radiusBottom, float height, const ccstd::optional &opts) { const float halfHeight = height * 0.5F; const uint32_t radialSegments = opts.has_value() ? opts->radialSegments : 32; const uint32_t heightSegments = opts.has_value() ? opts->heightSegments : 1; @@ -263,4 +263,4 @@ IGeometry cylinder(float radiusTop, float radiusBottom, float height, const cc:: return info; } -} // namespace cc \ No newline at end of file +} // namespace cc diff --git a/native/cocos/primitive/Cylinder.h b/native/cocos/primitive/Cylinder.h index 7a6e5acf9e..4e163a37d4 100644 --- a/native/cocos/primitive/Cylinder.h +++ b/native/cocos/primitive/Cylinder.h @@ -51,6 +51,6 @@ struct ICylinderOptions : public IGeometryOptions { * @param options 参数选项。 */ -IGeometry cylinder(float radiusTop = 0.5, float radiusBottom = 0.5, float height = 2, const cc::optional &opts = cc::nullopt); +IGeometry cylinder(float radiusTop = 0.5, float radiusBottom = 0.5, float height = 2, const ccstd::optional &opts = ccstd::nullopt); } // namespace cc diff --git a/native/cocos/primitive/Plane.cpp b/native/cocos/primitive/Plane.cpp index d1e3bad0be..0dc3f36d71 100644 --- a/native/cocos/primitive/Plane.cpp +++ b/native/cocos/primitive/Plane.cpp @@ -27,7 +27,7 @@ #include "primitive/Plane.h" namespace cc { -IGeometry plane(cc::optional options) { +IGeometry plane(ccstd::optional options) { if (!options.has_value()) { options = IPlaneOptions(); } diff --git a/native/cocos/primitive/Plane.h b/native/cocos/primitive/Plane.h index cdce6e1113..f54ffa63ea 100644 --- a/native/cocos/primitive/Plane.h +++ b/native/cocos/primitive/Plane.h @@ -64,6 +64,6 @@ struct IPlaneOptions : public IGeometryOptions { * @param options 平面参数选项。 */ -IGeometry plane(cc::optional options = cc::nullopt); +IGeometry plane(ccstd::optional options = ccstd::nullopt); } // namespace cc diff --git a/native/cocos/primitive/Primitive.cpp b/native/cocos/primitive/Primitive.cpp index cfa4358dd5..4cd54c4f38 100644 --- a/native/cocos/primitive/Primitive.cpp +++ b/native/cocos/primitive/Primitive.cpp @@ -37,38 +37,38 @@ void Primitive::onLoaded() { reset(MeshUtils::createMeshInfo(createGeometry(type))); } -IGeometry createGeometry(PrimitiveType type, const cc::optional &options) { +IGeometry createGeometry(PrimitiveType type, const ccstd::optional &options) { switch (type) { case PrimitiveType::BOX: { - return options.has_value() ? box(cc::get(options.value())) : box(); + return options.has_value() ? box(ccstd::get(options.value())) : box(); break; } case PrimitiveType::SPHERE: { - return options.has_value() ? sphere(0.5F, cc::get(options.value())) : sphere(); + return options.has_value() ? sphere(0.5F, ccstd::get(options.value())) : sphere(); break; } case PrimitiveType::CYLINDER: { - return options.has_value() ? cylinder(0.5F, 0.5F, 2, cc::get<4>(options.value())) : cylinder(); + return options.has_value() ? cylinder(0.5F, 0.5F, 2, ccstd::get<4>(options.value())) : cylinder(); break; } case PrimitiveType::CONE: { - return options.has_value() ? cone(0.5F, 1.0F, cc::get<5>(options.value())) : cone(); + return options.has_value() ? cone(0.5F, 1.0F, ccstd::get<5>(options.value())) : cone(); break; } case PrimitiveType::CAPSULE: { - return options.has_value() ? capsule(0.5F, 0.5F, 2, cc::get(options.value())) : capsule(); + return options.has_value() ? capsule(0.5F, 0.5F, 2, ccstd::get(options.value())) : capsule(); break; } case PrimitiveType::TORUS: { - return options.has_value() ? torus(0.4F, 0.1F, cc::get(options.value())) : torus(); + return options.has_value() ? torus(0.4F, 0.1F, ccstd::get(options.value())) : torus(); break; } case PrimitiveType::PLANE: { - return options.has_value() ? quad(cc::get(options.value())) : plane(); + return options.has_value() ? quad(ccstd::get(options.value())) : plane(); break; } case PrimitiveType::QUAD: { - return options.has_value() ? quad(cc::get(options.value())) : quad(); + return options.has_value() ? quad(ccstd::get(options.value())) : quad(); break; } default: diff --git a/native/cocos/primitive/Primitive.h b/native/cocos/primitive/Primitive.h index 02140ec104..cb464cc767 100644 --- a/native/cocos/primitive/Primitive.h +++ b/native/cocos/primitive/Primitive.h @@ -24,10 +24,10 @@ ****************************************************************************/ #pragma once -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "3d/assets/Mesh.h" -#include "cocos/base/Variant.h" +#include "base/std/variant.h" #include "primitive/Box.h" #include "primitive/Capsule.h" #include "primitive/Circle.h" @@ -41,7 +41,7 @@ #include "primitive/PrimitiveDefine.h" namespace cc { -using PrimitiveOptions = cc::variant; +using PrimitiveOptions = ccstd::variant; enum class PrimitiveType { BOX = 0, SPHERE = 1, @@ -94,6 +94,6 @@ private: CC_DISALLOW_COPY_MOVE_ASSIGN(Primitive); }; -IGeometry createGeometry(PrimitiveType type, const cc::optional &options = cc::nullopt); +IGeometry createGeometry(PrimitiveType type, const ccstd::optional &options = ccstd::nullopt); } // namespace cc diff --git a/native/cocos/primitive/PrimitiveDefine.h b/native/cocos/primitive/PrimitiveDefine.h index 3e089910fd..fb5664708e 100644 --- a/native/cocos/primitive/PrimitiveDefine.h +++ b/native/cocos/primitive/PrimitiveDefine.h @@ -24,7 +24,7 @@ ****************************************************************************/ #pragma once -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "core/TypedArray.h" #include "math/Vec3.h" #include "math/Vec4.h" @@ -82,7 +82,7 @@ struct IGeometry { * @zh * 顶点法线。 */ - cc::optional> normals; + ccstd::optional> normals; /** * @en @@ -90,7 +90,7 @@ struct IGeometry { * @zh * 纹理坐标。 */ - cc::optional> uvs; + ccstd::optional> uvs; /** * @en @@ -98,7 +98,7 @@ struct IGeometry { * @zh * 顶点切线。 */ - cc::optional> tangents; + ccstd::optional> tangents; /** * @en @@ -106,7 +106,7 @@ struct IGeometry { * @zh * 顶点颜色。 */ - cc::optional> colors; + ccstd::optional> colors; /** * @en @@ -114,7 +114,7 @@ struct IGeometry { * @zh * 顶点属性。 */ - cc::optional attributes; + ccstd::optional attributes; /** * @en @@ -122,7 +122,7 @@ struct IGeometry { * @zh * 定制属性列表。 */ - cc::optional> customAttributes; + ccstd::optional> customAttributes; /** * @en @@ -130,7 +130,7 @@ struct IGeometry { * @zh * 包围球半径。 */ - cc::optional boundingRadius; + ccstd::optional boundingRadius; /** * @en @@ -138,7 +138,7 @@ struct IGeometry { * @zh * 最小位置。 */ - cc::optional minPos; + ccstd::optional minPos; /** * @en @@ -146,7 +146,7 @@ struct IGeometry { * @zh * 最大位置。 */ - cc::optional maxPos; + ccstd::optional maxPos; /** * @en @@ -154,7 +154,7 @@ struct IGeometry { * @zh * 几何索引,当使用索引绘制时。 */ - cc::optional> indices; //cjh uint16_t ? + ccstd::optional> indices; //cjh uint16_t ? /** * @en @@ -162,7 +162,7 @@ struct IGeometry { * @zh * 几何顶点的拓扑图元。默认值是TRIANGLE_LIST。 */ - cc::optional primitiveMode; + ccstd::optional primitiveMode; /** * @en @@ -170,7 +170,7 @@ struct IGeometry { * @zh * 是否是双面,用于判断来自于几何体背面的射线检测。 */ - cc::optional doubleSided; + ccstd::optional doubleSided; }; struct DynamicCustomAttribute { @@ -199,7 +199,7 @@ struct IDynamicGeometry { * @zh * 顶点法线:3个float分量。 */ - cc::optional normals; + ccstd::optional normals; /** * @en @@ -207,7 +207,7 @@ struct IDynamicGeometry { * @zh * 纹理坐标:2个float分量。 */ - cc::optional uvs; + ccstd::optional uvs; /** * @en @@ -215,7 +215,7 @@ struct IDynamicGeometry { * @zh * 顶点切线:4个float分量。 */ - cc::optional tangents; + ccstd::optional tangents; /** * @en @@ -223,7 +223,7 @@ struct IDynamicGeometry { * @zh * 顶点颜色:4个float分量。 */ - cc::optional colors; + ccstd::optional colors; /** * @en @@ -231,7 +231,7 @@ struct IDynamicGeometry { * @zh * 定制属性列表。 */ - cc::optional> customAttributes; + ccstd::optional> customAttributes; /** * @en @@ -239,7 +239,7 @@ struct IDynamicGeometry { * @zh * 最小位置。包围盒大小由用户提供,更高效。 */ - cc::optional minPos; + ccstd::optional minPos; /** * @en @@ -247,7 +247,7 @@ struct IDynamicGeometry { * @zh * 最大位置。包围盒大小由用户提供,更高效。 */ - cc::optional maxPos; + ccstd::optional maxPos; /** * @en @@ -255,7 +255,7 @@ struct IDynamicGeometry { * @zh * 16位几何索引,当使用索引绘制时。 */ - cc::optional indices16; + ccstd::optional indices16; /** * @en @@ -263,7 +263,7 @@ struct IDynamicGeometry { * @zh * 32位几何索引,当使用索引绘制时。 */ - cc::optional indices32; + ccstd::optional indices32; /** * @en @@ -271,7 +271,7 @@ struct IDynamicGeometry { * @zh * 几何顶点的拓扑图元。默认值是TRIANGLE_LIST。 */ - cc::optional primitiveMode; + ccstd::optional primitiveMode; /** * @en @@ -279,7 +279,7 @@ struct IDynamicGeometry { * @zh * 是否是双面,用于判断来自于几何体背面的射线检测。 */ - cc::optional doubleSided; + ccstd::optional doubleSided; }; } // namespace cc diff --git a/native/cocos/primitive/Quad.cpp b/native/cocos/primitive/Quad.cpp index e87a1a2ddf..915f14eb4d 100644 --- a/native/cocos/primitive/Quad.cpp +++ b/native/cocos/primitive/Quad.cpp @@ -25,7 +25,7 @@ #include "primitive/Quad.h" namespace cc { -IGeometry quad(cc::optional options) { +IGeometry quad(ccstd::optional options) { if (!options.has_value()) { options = IGeometryOptions(); } diff --git a/native/cocos/primitive/Quad.h b/native/cocos/primitive/Quad.h index 304efc8bf2..d3b4694b5e 100644 --- a/native/cocos/primitive/Quad.h +++ b/native/cocos/primitive/Quad.h @@ -35,5 +35,5 @@ namespace cc { * @param options 参数选项。 */ -IGeometry quad(cc::optional options = cc::nullopt); +IGeometry quad(ccstd::optional options = ccstd::nullopt); } // namespace cc diff --git a/native/cocos/primitive/Sphere.cpp b/native/cocos/primitive/Sphere.cpp index 7bb30fb85d..fefcbd3534 100644 --- a/native/cocos/primitive/Sphere.cpp +++ b/native/cocos/primitive/Sphere.cpp @@ -26,7 +26,7 @@ #include "primitive/Sphere.h" namespace cc { -IGeometry sphere(float radius, const cc::optional &opts) { +IGeometry sphere(float radius, const ccstd::optional &opts) { const uint32_t segments = opts.has_value() ? opts->segments : 32; // lat === latitude diff --git a/native/cocos/primitive/Sphere.h b/native/cocos/primitive/Sphere.h index 680f4b1ff4..e1e97ef57b 100644 --- a/native/cocos/primitive/Sphere.h +++ b/native/cocos/primitive/Sphere.h @@ -48,6 +48,6 @@ struct ISphereOptions : public IGeometryOptions { * @param options 参数选项。 */ -IGeometry sphere(float radius = 0.5, const cc::optional &opts = cc::nullopt); +IGeometry sphere(float radius = 0.5, const ccstd::optional &opts = ccstd::nullopt); } // namespace cc diff --git a/native/cocos/primitive/Torus.cpp b/native/cocos/primitive/Torus.cpp index bafe8e8d23..e8668a3844 100644 --- a/native/cocos/primitive/Torus.cpp +++ b/native/cocos/primitive/Torus.cpp @@ -26,7 +26,7 @@ #include "primitive/Torus.h" namespace cc { -IGeometry torus(float radius, float tube, const cc::optional &opts) { +IGeometry torus(float radius, float tube, const ccstd::optional &opts) { const uint32_t radialSegments = opts.has_value() ? opts->radialSegments : 32; const uint32_t tubularSegments = opts.has_value() ? opts->tubularSegments : 32; const float arc = opts.has_value() ? opts->arc : math::PI_2; diff --git a/native/cocos/primitive/Torus.h b/native/cocos/primitive/Torus.h index f6c2722812..48d0ccdbec 100644 --- a/native/cocos/primitive/Torus.h +++ b/native/cocos/primitive/Torus.h @@ -46,6 +46,6 @@ struct ITorusOptions { * @param tube 管形大小。 * @param opts 参数选项。 */ -IGeometry torus(float radius = 0.4, float tube = 0.1, const cc::optional &opts = cc::nullopt); +IGeometry torus(float radius = 0.4, float tube = 0.1, const ccstd::optional &opts = ccstd::nullopt); } // namespace cc diff --git a/native/cocos/primitive/Transform.cpp b/native/cocos/primitive/Transform.cpp index b6cda26338..060cca7a74 100644 --- a/native/cocos/primitive/Transform.cpp +++ b/native/cocos/primitive/Transform.cpp @@ -26,7 +26,7 @@ #include "primitive/Transform.h" namespace cc { -IGeometry translate(IGeometry &geometry, const cc::optional &offset) { +IGeometry translate(IGeometry &geometry, const ccstd::optional &offset) { const float x = offset.has_value() ? offset->x : 0; const float y = offset.has_value() ? offset->y : 0; const float z = offset.has_value() ? offset->z : 0; @@ -57,7 +57,7 @@ IGeometry translate(IGeometry &geometry, const cc::optional &offset) { return geometry; } -IGeometry scale(IGeometry &geometry, const cc::optional &value) { +IGeometry scale(IGeometry &geometry, const ccstd::optional &value) { const float x = value.has_value() ? value->x : 0; const float y = value.has_value() ? value->y : 0; const float z = value.has_value() ? value->z : 0; diff --git a/native/cocos/primitive/Transform.h b/native/cocos/primitive/Transform.h index 9cfedc2639..bd3c87ec44 100644 --- a/native/cocos/primitive/Transform.h +++ b/native/cocos/primitive/Transform.h @@ -37,7 +37,7 @@ namespace cc { * @param geometry 几何体信息。 * @param offset 偏移量。 */ -IGeometry translate(IGeometry &geometry, const cc::optional &offset); +IGeometry translate(IGeometry &geometry, const ccstd::optional &offset); /** * @en @@ -47,7 +47,7 @@ IGeometry translate(IGeometry &geometry, const cc::optional &offset); * @param geometry 几何体信息。 * @param value 缩放量。 */ -IGeometry scale(IGeometry &geometry, const cc::optional &value); +IGeometry scale(IGeometry &geometry, const ccstd::optional &value); /** * @en diff --git a/native/cocos/renderer/core/MaterialInstance.h b/native/cocos/renderer/core/MaterialInstance.h index df0d6fce3c..2e7a3bbeb6 100644 --- a/native/cocos/renderer/core/MaterialInstance.h +++ b/native/cocos/renderer/core/MaterialInstance.h @@ -26,7 +26,7 @@ #pragma once #include "base/TypeDef.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "core/assets/Material.h" diff --git a/native/cocos/renderer/core/PassInstance.cpp b/native/cocos/renderer/core/PassInstance.cpp index 77cadd3a16..7f2cfe2b47 100644 --- a/native/cocos/renderer/core/PassInstance.cpp +++ b/native/cocos/renderer/core/PassInstance.cpp @@ -70,7 +70,7 @@ void PassInstance::overridePipelineStates(const IPassInfo &original, const PassO onStateChange(); } -bool PassInstance::tryCompile(const cc::optional &defineOverrides) { +bool PassInstance::tryCompile(const ccstd::optional &defineOverrides) { if (defineOverrides.has_value()) { if (!overrideMacros(_defines, defineOverrides.value())) return false; } diff --git a/native/cocos/renderer/core/PassInstance.h b/native/cocos/renderer/core/PassInstance.h index dddcdc8d4f..ba4ba495a2 100644 --- a/native/cocos/renderer/core/PassInstance.h +++ b/native/cocos/renderer/core/PassInstance.h @@ -25,7 +25,7 @@ #pragma once -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "scene/Pass.h" namespace cc { @@ -55,7 +55,7 @@ public: */ void overridePipelineStates(const IPassInfo &original, const PassOverrides &override) override; - bool tryCompile(const cc::optional &defineOverrides) override; + bool tryCompile(const ccstd::optional &defineOverrides) override; /** * @en Prepare to change states of the pass and do not notify the material to rebuild the pipeline state object diff --git a/native/cocos/renderer/core/PassUtils.cpp b/native/cocos/renderer/core/PassUtils.cpp index b426603eda..9a833ddeeb 100644 --- a/native/cocos/renderer/core/PassUtils.cpp +++ b/native/cocos/renderer/core/PassUtils.cpp @@ -36,25 +36,25 @@ const ccstd::unordered_map type2reader = { CC_LOG_ERROR("type2reader unknown type"); }}, {gfx::Type::INT, [](const float *a, MaterialProperty &v, index_t idx) { - auto *p = cc::get_if(&v); + auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); p[0] = static_cast(a[idx]); }}, {gfx::Type::INT2, [](const float *a, MaterialProperty &v, index_t idx) { - auto *p = cc::get_if(&v); + auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); p->x = a[idx]; p->y = a[idx + 1]; }}, {gfx::Type::INT3, [](const float *a, MaterialProperty &v, index_t idx) { - auto *p = cc::get_if(&v); + auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); p->x = a[idx]; p->y = a[idx + 1]; p->z = a[idx + 2]; }}, {gfx::Type::INT4, [](const float *a, MaterialProperty &v, index_t idx) { - auto *p = cc::get_if(&v); + auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); p->x = a[idx]; p->y = a[idx + 1]; @@ -62,25 +62,25 @@ const ccstd::unordered_map type2reader = { p->w = a[idx + 3]; }}, {gfx::Type::FLOAT, [](const float *a, MaterialProperty &v, index_t idx) { - auto *p = cc::get_if(&v); + auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); p[0] = a[idx]; }}, {gfx::Type::FLOAT2, [](const float *a, MaterialProperty &v, index_t idx) { - auto *p = cc::get_if(&v); + auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); p->x = a[idx]; p->y = a[idx + 1]; }}, {gfx::Type::FLOAT3, [](const float *a, MaterialProperty &v, index_t idx) { - auto *p = cc::get_if(&v); + auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); p->x = a[idx]; p->y = a[idx + 1]; p->z = a[idx + 2]; }}, {gfx::Type::FLOAT4, [](const float *a, MaterialProperty &v, index_t idx) { - auto *p = cc::get_if(&v); + auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); p->x = a[idx]; p->y = a[idx + 1]; @@ -88,12 +88,12 @@ const ccstd::unordered_map type2reader = { p->w = a[idx + 3]; }}, {gfx::Type::MAT3, [](const float *a, MaterialProperty &v, index_t idx) { - auto *p = cc::get_if(&v); + auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); memcpy(&p->m[0], &a[idx], sizeof(Mat3)); }}, {gfx::Type::MAT4, [](const float *a, MaterialProperty &v, index_t idx) { - auto *p = cc::get_if(&v); + auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); memcpy(&p->m[0], &a[idx], sizeof(Mat4)); }}, @@ -104,12 +104,12 @@ const ccstd::unordered_map type2writer = { CC_LOG_ERROR("type2writer unknown type"); }}, {gfx::Type::INT, [](float *a, const MaterialProperty &v, index_t idx) { - const int32_t *p = cc::get_if(&v); + const int32_t *p = ccstd::get_if(&v); const float *pFloat = nullptr; if (p != nullptr) { a[idx] = static_cast(*p); } else { - pFloat = cc::get_if(&v); + pFloat = ccstd::get_if(&v); if (pFloat != nullptr) { a[idx] = static_cast(*p); } @@ -117,20 +117,20 @@ const ccstd::unordered_map type2writer = { CC_ASSERT(p != nullptr || pFloat != nullptr); }}, {gfx::Type::INT2, [](float *a, const MaterialProperty &v, index_t idx) { - const auto *p = cc::get_if(&v); + const auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); a[idx] = p->x; a[idx + 1] = p->y; }}, {gfx::Type::INT3, [](float *a, const MaterialProperty &v, index_t idx) { - const auto *p = cc::get_if(&v); + const auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); a[idx] = p->x; a[idx + 1] = p->y; a[idx + 2] = p->z; }}, {gfx::Type::INT4, [](float *a, const MaterialProperty &v, index_t idx) { - const auto *p = cc::get_if(&v); + const auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); a[idx] = p->x; a[idx + 1] = p->y; @@ -138,12 +138,12 @@ const ccstd::unordered_map type2writer = { a[idx + 3] = p->w; }}, {gfx::Type::FLOAT, [](float *a, const MaterialProperty &v, index_t idx) { - const float *p = cc::get_if(&v); + const float *p = ccstd::get_if(&v); const int32_t *pInt = nullptr; if (p != nullptr) { a[idx] = *p; } else { - pInt = cc::get_if(&v); + pInt = ccstd::get_if(&v); if (pInt != nullptr) { a[idx] = static_cast(*pInt); } @@ -151,19 +151,19 @@ const ccstd::unordered_map type2writer = { CC_ASSERT(p != nullptr || pInt != nullptr); }}, {gfx::Type::FLOAT2, [](float *a, const MaterialProperty &v, index_t idx) { - const auto *p = cc::get_if(&v); + const auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); a[idx] = p->x; a[idx + 1] = p->y; }}, {gfx::Type::FLOAT3, [](float *a, const MaterialProperty &v, index_t idx) { - if (cc::holds_alternative(v)) { - const auto &vec3 = cc::get(v); + if (ccstd::holds_alternative(v)) { + const auto &vec3 = ccstd::get(v); a[idx] = vec3.x; a[idx + 1] = vec3.y; a[idx + 2] = vec3.z; - } else if (cc::holds_alternative(v)) { - const auto &vec4 = cc::get(v); + } else if (ccstd::holds_alternative(v)) { + const auto &vec4 = ccstd::get(v); a[idx] = vec4.x; a[idx + 1] = vec4.y; a[idx + 2] = vec4.z; @@ -172,21 +172,21 @@ const ccstd::unordered_map type2writer = { } }}, {gfx::Type::FLOAT4, [](float *a, const MaterialProperty &v, index_t idx) { - if (cc::holds_alternative(v)) { - const auto &vec4 = cc::get(v); + if (ccstd::holds_alternative(v)) { + const auto &vec4 = ccstd::get(v); a[idx] = vec4.x; a[idx + 1] = vec4.y; a[idx + 2] = vec4.z; a[idx + 3] = vec4.w; - } else if (cc::holds_alternative(v)) { - const auto &color = cc::get(v); + } else if (ccstd::holds_alternative(v)) { + const auto &color = ccstd::get(v); Vec4 colorFloat{color.toVec4()}; a[idx] = colorFloat.x; a[idx + 1] = colorFloat.y; a[idx + 2] = colorFloat.z; a[idx + 3] = colorFloat.w; - } else if (cc::holds_alternative(v)) { - const auto &quat = cc::get(v); + } else if (ccstd::holds_alternative(v)) { + const auto &quat = ccstd::get(v); a[idx] = quat.x; a[idx + 1] = quat.y; a[idx + 2] = quat.z; @@ -196,12 +196,12 @@ const ccstd::unordered_map type2writer = { } }}, {gfx::Type::MAT3, [](float *a, const MaterialProperty &v, index_t idx) { - const auto *p = cc::get_if(&v); + const auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); memcpy(&a[idx], &p->m[0], sizeof(Mat3)); }}, {gfx::Type::MAT4, [](float *a, const MaterialProperty &v, index_t idx) { - const auto *p = cc::get_if(&v); + const auto *p = ccstd::get_if(&v); CC_ASSERT(p != nullptr); memcpy(&a[idx], &p->m[0], sizeof(Mat4)); }}, diff --git a/native/cocos/renderer/core/PassUtils.h b/native/cocos/renderer/core/PassUtils.h index fb9c2cb27d..c654c235f0 100644 --- a/native/cocos/renderer/core/PassUtils.h +++ b/native/cocos/renderer/core/PassUtils.h @@ -27,9 +27,9 @@ #include "base/Ptr.h" #include "base/TypeDef.h" -#include "base/Variant.h" #include "base/std/container/string.h" #include "base/std/container/vector.h" +#include "base/std/variant.h" #include "math/Color.h" #include "math/Mat3.h" @@ -66,7 +66,7 @@ constexpr uint32_t customizeType(uint32_t handle, gfx::Type type) { return (handle & ~TYPE_MASK) | ((static_cast(type) << 26) & TYPE_MASK); } -using MacroValue = cc::variant; +using MacroValue = ccstd::variant; /** * @en Combination of preprocess macros @@ -74,11 +74,11 @@ using MacroValue = cc::variant; */ using MacroRecord = Record; -using MaterialProperty = cc::variant /*10*/, IntrusivePtr /*11*/>; +using MaterialProperty = ccstd::variant /*10*/, IntrusivePtr /*11*/>; using MaterialPropertyList = ccstd::vector; -using MaterialPropertyVariant = cc::variant; +using MaterialPropertyVariant = ccstd::variant; #define MATERIAL_PROPERTY_INDEX_SINGLE 1 #define MATERIAL_PROPERTY_INDEX_LIST 2 diff --git a/native/cocos/renderer/core/ProgramLib.cpp b/native/cocos/renderer/core/ProgramLib.cpp index 58b8b9eca8..a5bc0e051b 100644 --- a/native/cocos/renderer/core/ProgramLib.cpp +++ b/native/cocos/renderer/core/ProgramLib.cpp @@ -44,32 +44,32 @@ int32_t getBitCount(int32_t cnt) { } bool recordAsBool(const MacroRecord::mapped_type &v) { - if (cc::holds_alternative(v)) { - return cc::get(v); + if (ccstd::holds_alternative(v)) { + return ccstd::get(v); } - if (cc::holds_alternative(v)) { - return cc::get(v) == "true"; + if (ccstd::holds_alternative(v)) { + return ccstd::get(v) == "true"; } - if (cc::holds_alternative(v)) { - return cc::get(v); + if (ccstd::holds_alternative(v)) { + return ccstd::get(v); } return false; } ccstd::string recordAsString(const MacroRecord::mapped_type &v) { - if (cc::holds_alternative(v)) { - return cc::get(v) ? "1" : "0"; + if (ccstd::holds_alternative(v)) { + return ccstd::get(v) ? "1" : "0"; } - if (cc::holds_alternative(v)) { - return cc::get(v); + if (ccstd::holds_alternative(v)) { + return ccstd::get(v); } - if (cc::holds_alternative(v)) { - return std::to_string(cc::get(v)); + if (ccstd::holds_alternative(v)) { + return std::to_string(ccstd::get(v)); } return ""; } -ccstd::string mapDefine(const IDefineInfo &info, const cc::optional &def) { +ccstd::string mapDefine(const IDefineInfo &info, const ccstd::optional &def) { if (info.type == "boolean") { return def.has_value() ? (recordAsBool(def.value()) ? "1" : "0") : "0"; } @@ -88,8 +88,8 @@ ccstd::vector prepareDefines(const MacroRecord &records, const ccstd for (const auto &tmp : defList) { const auto &name = tmp.name; auto it = records.find(name); - auto value = mapDefine(tmp, it == records.end() ? cc::nullopt : cc::optional(it->second)); - bool isDefault = it == records.end() || (cc::holds_alternative(it->second) && cc::get(it->second) == "0"); + auto value = mapDefine(tmp, it == records.end() ? ccstd::nullopt : ccstd::optional(it->second)); + bool isDefault = it == records.end() || (ccstd::holds_alternative(it->second) && ccstd::get(it->second) == "0"); macros.emplace_back(); auto &info = macros.back(); info.name = name; @@ -278,10 +278,10 @@ ProgramLib::ProgramLib() { ProgramLib::~ProgramLib() { ProgramLib::instance = nullptr; #if CC_DEBUG - for (const auto& cache : _cache) { + for (const auto &cache : _cache) { if (cache.second->getRefCount() > 1) { - CC_LOG_WARNING("ProgramLib cache: %s ref_count is %d and may leak", cache.second->getName().c_str(), cache.second->getRefCount() ); - } + CC_LOG_WARNING("ProgramLib cache: %s ref_count is %d and may leak", cache.second->getName().c_str(), cache.second->getRefCount()); + } } #endif } @@ -328,11 +328,11 @@ IProgramInfo *ProgramLib::define(IShaderInfo &shader) { auto &range = def.range.value(); cnt = getBitCount(range[1] - range[0] + 1); // inclusive on both ends def.map = [=](const MacroValue &value) -> int32_t { - if (cc::holds_alternative(value)) { - return cc::get(value) - range[0]; + if (ccstd::holds_alternative(value)) { + return ccstd::get(value) - range[0]; } - if (cc::holds_alternative(value)) { - return (cc::get(value) ? 1 : 0) - range[0]; + if (ccstd::holds_alternative(value)) { + return (ccstd::get(value) ? 1 : 0) - range[0]; } CC_ASSERT(false); // We only support macro with int32_t type now. return 0; @@ -340,7 +340,7 @@ IProgramInfo *ProgramLib::define(IShaderInfo &shader) { } else if (def.type == "string") { cnt = getBitCount(static_cast(def.options.value().size())); def.map = [=](const MacroValue &value) -> int32_t { - const auto *pValue = cc::get_if(&value); + const auto *pValue = ccstd::get_if(&value); if (pValue != nullptr) { auto idx = static_cast(std::find(def.options.value().begin(), def.options.value().end(), *pValue) - def.options.value().begin()); return std::max(0, idx); @@ -349,15 +349,15 @@ IProgramInfo *ProgramLib::define(IShaderInfo &shader) { }; } else if (def.type == "boolean") { def.map = [](const MacroValue &value) -> int32_t { - const auto *pBool = cc::get_if(&value); + const auto *pBool = ccstd::get_if(&value); if (pBool != nullptr) { return *pBool ? 1 : 0; } - const auto *pInt = cc::get_if(&value); + const auto *pInt = ccstd::get_if(&value); if (pInt != nullptr) { return *pInt ? 1 : 0; } - const auto *pString = cc::get_if(&value); + const auto *pString = ccstd::get_if(&value); if (pString != nullptr) { return *pString != "0" || !(*pString).empty() ? 1 : 0; } diff --git a/native/cocos/renderer/core/ProgramLib.h b/native/cocos/renderer/core/ProgramLib.h index 4f3431ae85..c33ae06791 100644 --- a/native/cocos/renderer/core/ProgramLib.h +++ b/native/cocos/renderer/core/ProgramLib.h @@ -31,7 +31,7 @@ #include "base/RefVector.h" #include "base/std/container/string.h" #include "base/std/container/unordered_map.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "core/Types.h" #include "core/assets/EffectAsset.h" #include "renderer/gfx-base/GFXDef-common.h" @@ -84,7 +84,7 @@ const char *getDeviceShaderVersion(const gfx::Device *device); class ProgramLib final { public: static ProgramLib *getInstance(); - + ProgramLib(); ~ProgramLib(); diff --git a/native/cocos/renderer/core/TextureBufferPool.h b/native/cocos/renderer/core/TextureBufferPool.h index ba8dd585a5..87390c3c17 100644 --- a/native/cocos/renderer/core/TextureBufferPool.h +++ b/native/cocos/renderer/core/TextureBufferPool.h @@ -26,7 +26,7 @@ #include #include "audio/android/PcmBufferProvider.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "core/ArrayBuffer.h" #include "renderer/gfx-base/GFXDef.h" @@ -53,9 +53,9 @@ struct ITextureBufferHandle { struct ITextureBufferPoolInfo { gfx::Format format{gfx::Format::UNKNOWN}; // target texture format - cc::optional inOrderFree; // will the handles be freed exactly in the order of their allocation? - cc::optional alignment; // the data alignment for each handle allocated, in bytes - cc::optional roundUpFn; // given a target size, how will the actual texture size round up? + ccstd::optional inOrderFree; // will the handles be freed exactly in the order of their allocation? + ccstd::optional alignment; // the data alignment for each handle allocated, in bytes + ccstd::optional roundUpFn; // given a target size, how will the actual texture size round up? }; class TextureBufferPool : public RefCounted { diff --git a/native/cocos/renderer/gfx-gles3/GLES3Device.h b/native/cocos/renderer/gfx-gles3/GLES3Device.h index a3fb1bf5c1..a93199ce13 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Device.h +++ b/native/cocos/renderer/gfx-gles3/GLES3Device.h @@ -26,7 +26,7 @@ #pragma once #include "GLES3Std.h" -#include "base/Any.h" +#include "base/std/any.h" #include "gfx-base/GFXDevice.h" #include "gfx-gles-common/GLESCommandPool.h" diff --git a/native/cocos/renderer/pipeline/RenderBatchedQueue.cpp b/native/cocos/renderer/pipeline/RenderBatchedQueue.cpp index 97ecbabe04..d2866a3ce6 100644 --- a/native/cocos/renderer/pipeline/RenderBatchedQueue.cpp +++ b/native/cocos/renderer/pipeline/RenderBatchedQueue.cpp @@ -26,10 +26,10 @@ #include "RenderBatchedQueue.h" #include "BatchedBuffer.h" #include "PipelineStateManager.h" -#include "scene/Pass.h" #include "gfx-base/GFXCommandBuffer.h" #include "gfx-base/GFXDevice.h" #include "gfx-base/GFXRenderPass.h" +#include "scene/Pass.h" namespace cc { namespace pipeline { diff --git a/native/cocos/renderer/pipeline/RenderInstancedQueue.cpp b/native/cocos/renderer/pipeline/RenderInstancedQueue.cpp index b5274d09c2..83cb0881d9 100644 --- a/native/cocos/renderer/pipeline/RenderInstancedQueue.cpp +++ b/native/cocos/renderer/pipeline/RenderInstancedQueue.cpp @@ -26,10 +26,10 @@ #include "RenderInstancedQueue.h" #include "InstancedBuffer.h" #include "PipelineStateManager.h" -#include "gfx-base/GFXDevice.h" -#include "gfx-base/GFXRenderPass.h" #include "gfx-base/GFXCommandBuffer.h" #include "gfx-base/GFXDescriptorSet.h" +#include "gfx-base/GFXDevice.h" +#include "gfx-base/GFXRenderPass.h" namespace cc { namespace pipeline { diff --git a/native/cocos/renderer/pipeline/custom/GraphTypes.h b/native/cocos/renderer/pipeline/custom/GraphTypes.h index ebece8e294..5c18218019 100644 --- a/native/cocos/renderer/pipeline/custom/GraphTypes.h +++ b/native/cocos/renderer/pipeline/custom/GraphTypes.h @@ -30,10 +30,10 @@ #include #include #include -#include "base/Variant.h" #include "base/memory/Memory.h" #include "base/std/container/list.h" #include "base/std/container/string.h" +#include "base/std/variant.h" #include "renderer/pipeline/custom/Overload.h" namespace boost { @@ -67,7 +67,7 @@ struct VertexOverloaded : Overloaded { template auto visitObject(typename GraphT::vertex_descriptor v, GraphT &g, Ts... args) { - return cc::visit(VertexOverloaded{std::move(args)...}, value(v, g)); + return ccstd::visit(VertexOverloaded{std::move(args)...}, value(v, g)); } namespace impl { @@ -483,7 +483,7 @@ struct ListEdge { : source(s), target(t), property(p) {} template - ListEdge(VertexDescriptor s, VertexDescriptor t, T &&... args) // NOLINT + ListEdge(VertexDescriptor s, VertexDescriptor t, T &&...args) // NOLINT : source(s), target(t), property(std::forward(args)...) {} EdgeProperty &get_property() noexcept { return property; } // NOLINT @@ -512,7 +512,7 @@ struct PmrListEdge { : source(s), target(t), property(p, alloc) {} template - PmrListEdge(VertexDescriptor s, VertexDescriptor t, T &&... args) // NOLINT + PmrListEdge(VertexDescriptor s, VertexDescriptor t, T &&...args) // NOLINT : source(s), target(t), property(std::forward(args)...) {} // move/copy cntrs @@ -553,7 +553,7 @@ struct ValueHandle : Tag { ValueHandle(Handle &&handle) noexcept // NOLINT(google-explicit-constructor) : value(std::move(handle)) {} template - ValueHandle(Args &&... args) noexcept // NOLINT(google-explicit-constructor) + ValueHandle(Args &&...args) noexcept // NOLINT(google-explicit-constructor) : value(std::forward(args)...) {} Handle value{}; diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h b/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h index f68cd87256..8da5a6db3f 100644 --- a/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h @@ -822,7 +822,7 @@ get(T DescriptorDB::*memberPointer, LayoutGraph& g) noexcept { inline LayoutGraph::vertices_size_type id(LayoutGraph::vertex_descriptor u, const LayoutGraph& g) noexcept { using vertex_descriptor = LayoutGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [](const impl::ValueHandle& h) { return h.value; @@ -836,7 +836,7 @@ id(LayoutGraph::vertex_descriptor u, const LayoutGraph& g) noexcept { inline LayoutGraph::VertexTag tag(LayoutGraph::vertex_descriptor u, const LayoutGraph& g) noexcept { using vertex_descriptor = LayoutGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [](const impl::ValueHandle&) { return LayoutGraph::VertexTag{RenderStageTag{}}; @@ -850,7 +850,7 @@ tag(LayoutGraph::vertex_descriptor u, const LayoutGraph& g) noexcept { inline LayoutGraph::VertexValue value(LayoutGraph::vertex_descriptor u, LayoutGraph& g) noexcept { using vertex_descriptor = LayoutGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [&](const impl::ValueHandle& h) { return LayoutGraph::VertexValue{&g.stages[h.value]}; @@ -864,7 +864,7 @@ value(LayoutGraph::vertex_descriptor u, LayoutGraph& g) noexcept { inline LayoutGraph::VertexConstValue value(LayoutGraph::vertex_descriptor u, const LayoutGraph& g) noexcept { using vertex_descriptor = LayoutGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [&](const impl::ValueHandle& h) { return LayoutGraph::VertexConstValue{&g.stages[h.value]}; @@ -1306,7 +1306,7 @@ inline void clear_vertex(LayoutGraph::vertex_descriptor u, LayoutGraph& g) noexc inline void remove_vertex_value_impl(const LayoutGraph::VertexHandle& h, LayoutGraph& g) noexcept { // NOLINT using vertex_descriptor = LayoutGraph::vertex_descriptor; - cc::visit( + ccstd::visit( overload( [&](const impl::ValueHandle& h) { g.stages.erase(g.stages.begin() + std::ptrdiff_t(h.value)); @@ -1522,7 +1522,7 @@ get(T PipelineLayoutData::*memberPointer, LayoutGraphData& g) noexcept { inline LayoutGraphData::vertices_size_type id(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { using vertex_descriptor = LayoutGraphData::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [](const impl::ValueHandle& h) { return h.value; @@ -1536,7 +1536,7 @@ id(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { inline LayoutGraphData::VertexTag tag(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { using vertex_descriptor = LayoutGraphData::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [](const impl::ValueHandle&) { return LayoutGraphData::VertexTag{RenderStageTag{}}; @@ -1550,7 +1550,7 @@ tag(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { inline LayoutGraphData::VertexValue value(LayoutGraphData::vertex_descriptor u, LayoutGraphData& g) noexcept { using vertex_descriptor = LayoutGraphData::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [&](const impl::ValueHandle& h) { return LayoutGraphData::VertexValue{&g.stages[h.value]}; @@ -1564,7 +1564,7 @@ value(LayoutGraphData::vertex_descriptor u, LayoutGraphData& g) noexcept { inline LayoutGraphData::VertexConstValue value(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { using vertex_descriptor = LayoutGraphData::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [&](const impl::ValueHandle& h) { return LayoutGraphData::VertexConstValue{&g.stages[h.value]}; @@ -2006,7 +2006,7 @@ inline void clear_vertex(LayoutGraphData::vertex_descriptor u, LayoutGraphData& inline void remove_vertex_value_impl(const LayoutGraphData::VertexHandle& h, LayoutGraphData& g) noexcept { // NOLINT using vertex_descriptor = LayoutGraphData::vertex_descriptor; - cc::visit( + ccstd::visit( overload( [&](const impl::ValueHandle& h) { g.stages.erase(g.stages.begin() + std::ptrdiff_t(h.value)); diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h b/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h index e83c35e38b..8db4faed5a 100644 --- a/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h +++ b/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h @@ -260,7 +260,7 @@ inline void clear_vertex(ResourceGraph::vertex_descriptor u, ResourceGraph& g) n inline void remove_vertex_value_impl(const ResourceGraph::VertexHandle& h, ResourceGraph& g) noexcept { // NOLINT using vertex_descriptor = ResourceGraph::vertex_descriptor; - cc::visit( + ccstd::visit( overload( [&](const impl::ValueHandle& h) { g.resources.erase(g.resources.begin() + std::ptrdiff_t(h.value)); @@ -1483,7 +1483,7 @@ get(T ResourceStates::*memberPointer, ResourceGraph& g) noexcept { inline ResourceGraph::vertices_size_type id(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { using vertex_descriptor = ResourceGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [](const impl::ValueHandle& h) { return h.value; @@ -1506,7 +1506,7 @@ id(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { inline ResourceGraph::VertexTag tag(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { using vertex_descriptor = ResourceGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [](const impl::ValueHandle&) { return ResourceGraph::VertexTag{ManagedTag{}}; @@ -1529,7 +1529,7 @@ tag(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { inline ResourceGraph::VertexValue value(ResourceGraph::vertex_descriptor u, ResourceGraph& g) noexcept { using vertex_descriptor = ResourceGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [&](const impl::ValueHandle& h) { return ResourceGraph::VertexValue{&g.resources[h.value]}; @@ -1552,7 +1552,7 @@ value(ResourceGraph::vertex_descriptor u, ResourceGraph& g) noexcept { inline ResourceGraph::VertexConstValue value(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { using vertex_descriptor = ResourceGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [&](const impl::ValueHandle& h) { return ResourceGraph::VertexConstValue{&g.resources[h.value]}; @@ -2289,7 +2289,7 @@ get(RenderGraph::ValidTag /*tag*/, RenderGraph& g) noexcept { inline RenderGraph::vertices_size_type id(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { using vertex_descriptor = RenderGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [](const impl::ValueHandle& h) { return h.value; @@ -2327,7 +2327,7 @@ id(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { inline RenderGraph::VertexTag tag(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { using vertex_descriptor = RenderGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [](const impl::ValueHandle&) { return RenderGraph::VertexTag{RasterTag{}}; @@ -2365,7 +2365,7 @@ tag(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { inline RenderGraph::VertexValue value(RenderGraph::vertex_descriptor u, RenderGraph& g) noexcept { using vertex_descriptor = RenderGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [&](const impl::ValueHandle& h) { return RenderGraph::VertexValue{&g.rasterPasses[h.value]}; @@ -2403,7 +2403,7 @@ value(RenderGraph::vertex_descriptor u, RenderGraph& g) noexcept { inline RenderGraph::VertexConstValue value(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { using vertex_descriptor = RenderGraph::vertex_descriptor; - return cc::visit( + return ccstd::visit( overload( [&](const impl::ValueHandle& h) { return RenderGraph::VertexConstValue{&g.rasterPasses[h.value]}; diff --git a/native/cocos/scene/Camera.h b/native/cocos/scene/Camera.h index 9f32448033..0f0840b4c5 100644 --- a/native/cocos/scene/Camera.h +++ b/native/cocos/scene/Camera.h @@ -30,7 +30,7 @@ #include "base/Ptr.h" #include "base/RefCounted.h" #include "base/std/container/string.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "cocos/math/Utils.h" #include "core/geometry/Frustum.h" #include "core/geometry/Ray.h" @@ -118,10 +118,10 @@ struct ICameraInfo { ccstd::string name; Node *node{nullptr}; CameraProjection projection; - cc::optional targetDisplay; + ccstd::optional targetDisplay; RenderWindow *window{nullptr}; uint32_t priority{0}; - cc::optional pipeline; + ccstd::optional pipeline; }; class Camera : public RefCounted { diff --git a/native/cocos/scene/Fog.cpp b/native/cocos/scene/Fog.cpp index 48f0beb532..a04158c36c 100644 --- a/native/cocos/scene/Fog.cpp +++ b/native/cocos/scene/Fog.cpp @@ -25,8 +25,8 @@ #include "scene/Fog.h" #include "core/Root.h" -#include "renderer/pipeline/helper/Utils.h" #include "renderer/pipeline/custom/RenderInterfaceTypes.h" +#include "renderer/pipeline/helper/Utils.h" namespace cc { namespace scene { @@ -130,8 +130,8 @@ void Fog::updatePipeline() { if (iterMacroFog != pipeline->getMacros().end() && iterMacroAccurateFog != pipeline->getMacros().end()) { const MacroValue ¯oFog = iterMacroFog->second; const MacroValue ¯oAccurateFog = iterMacroAccurateFog->second; - const int32_t *macroFogPtr = cc::get_if(¯oFog); - const int32_t *macroAccurateFogPtr = cc::get_if(¯oAccurateFog); + const int32_t *macroFogPtr = ccstd::get_if(¯oFog); + const int32_t *macroAccurateFogPtr = ccstd::get_if(¯oAccurateFog); if (macroFogPtr != nullptr && *macroFogPtr == static_cast(value) && macroAccurateFogPtr != nullptr && *macroAccurateFogPtr == accurateValue) return; } diff --git a/native/cocos/scene/Model.cpp b/native/cocos/scene/Model.cpp index 66498ce6c2..0e8422a199 100644 --- a/native/cocos/scene/Model.cpp +++ b/native/cocos/scene/Model.cpp @@ -237,7 +237,7 @@ void Model::updateUBOs(uint32_t stamp) { int idx = _instMatWorldIdx; if (idx >= 0) { ccstd::vector &attrs = getInstancedAttributeBlock()->views; - uploadMat4AsVec4x3(worldMatrix, cc::get(attrs[idx]), cc::get(attrs[idx + 1]), cc::get(attrs[idx + 2])); + uploadMat4AsVec4x3(worldMatrix, ccstd::get(attrs[idx]), ccstd::get(attrs[idx + 1]), ccstd::get(attrs[idx + 2])); } else if (_localBuffer) { mat4ToFloat32Array(worldMatrix, _localData, pipeline::UBOLocal::MAT_WORLD_OFFSET); Mat4::inverseTranspose(worldMatrix, &mat4); @@ -271,7 +271,7 @@ void Model::updateWorldBoundUBOs() { } } -void Model::createBoundingShape(const cc::optional &minPos, const cc::optional &maxPos) { +void Model::createBoundingShape(const ccstd::optional &minPos, const ccstd::optional &maxPos) { if (!minPos.has_value() || !maxPos.has_value()) { return; } @@ -500,7 +500,7 @@ void Model::updateWorldBoundDescriptors(index_t subModelIndex, gfx::DescriptorSe } } void Model::setInstancedAttributesViewData(index_t viewIdx, index_t arrIdx, float value) { - cc::get(_instanceAttributeBlock.views[viewIdx])[arrIdx] = value; + ccstd::get(_instanceAttributeBlock.views[viewIdx])[arrIdx] = value; } void Model::updateLocalShadowBias() { diff --git a/native/cocos/scene/Model.h b/native/cocos/scene/Model.h index 820228107d..86c4ab0a27 100644 --- a/native/cocos/scene/Model.h +++ b/native/cocos/scene/Model.h @@ -82,7 +82,7 @@ public: void updateWorldBound(); void updateWorldBoundsForJSSkinningModel(const Vec3 &min, const Vec3 &max); void updateWorldBoundsForJSBakedSkinningModel(geometry::AABB *aabb); - void createBoundingShape(const cc::optional &minPos, const cc::optional &maxPos); + void createBoundingShape(const ccstd::optional &minPos, const ccstd::optional &maxPos); virtual void initSubModel(index_t idx, RenderingSubMesh *subMeshData, Material *mat); void setSubModelMesh(index_t idx, RenderingSubMesh *subMesh) const; virtual void setSubModelMaterial(index_t idx, Material *mat); diff --git a/native/cocos/scene/Pass.cpp b/native/cocos/scene/Pass.cpp index 69b6676605..06779d28a7 100644 --- a/native/cocos/scene/Pass.cpp +++ b/native/cocos/scene/Pass.cpp @@ -303,8 +303,8 @@ void Pass::resetUniform(const ccstd::string &name) { if (givenDefaultOpt.has_value()) { const auto &value = givenDefaultOpt.value(); - if (cc::holds_alternative>(value)) { - const auto &floatArr = cc::get>(value); + if (ccstd::holds_alternative>(value)) { + const auto &floatArr = ccstd::get>(value); auto iter = type2writer.find(type); if (iter != type2writer.end()) { CC_ASSERT(floatArr.size() == 2); @@ -329,7 +329,7 @@ void Pass::resetTexture(const ccstd::string &name, index_t index /* = CC_INVALID if (iter != _properties.end()) { if (iter->second.value.has_value()) { info = &iter->second; - ccstd::string *pStrVal = cc::get_if(&iter->second.value.value()); + ccstd::string *pStrVal = ccstd::get_if(&iter->second.value.value()); if (pStrVal != nullptr) { texName = (*pStrVal) + "-texture"; } @@ -342,7 +342,7 @@ void Pass::resetTexture(const ccstd::string &name, index_t index /* = CC_INVALID auto *textureBase = BuiltinResMgr::getInstance()->get(texName); gfx::Texture *texture = textureBase != nullptr ? textureBase->getGFXTexture() : nullptr; - cc::optional samplerInfo; + ccstd::optional samplerInfo; if (info != nullptr && info->samplerHash.has_value()) { samplerInfo = gfx::Sampler::unpackFromHash(static_cast(info->samplerHash.value())); } else if (textureBase != nullptr) { @@ -365,7 +365,7 @@ void Pass::resetUBOs() { const auto &block = _blocks[u.binding]; const auto &info = _properties[cur.name]; const auto &givenDefault = info.value; - const auto &value = (givenDefault.has_value() ? cc::get>(givenDefault.value()) : getDefaultFloatArrayFromType(cur.type)); + const auto &value = (givenDefault.has_value() ? ccstd::get>(givenDefault.value()) : getDefaultFloatArrayFromType(cur.type)); const uint32_t size = (gfx::getTypeSize(cur.type) >> 2) * cur.count; for (size_t k = 0; (k + value.size()) <= size; k += value.size()) { std::copy(value.begin(), value.end(), block.data + ofs + k); diff --git a/native/cocos/scene/Pass.h b/native/cocos/scene/Pass.h index 5fecefd6dc..1a3467c294 100644 --- a/native/cocos/scene/Pass.h +++ b/native/cocos/scene/Pass.h @@ -248,7 +248,7 @@ public: * @zh 尝试编译 shader 并获取相关资源引用。 */ virtual bool tryCompile(); - virtual bool tryCompile(const cc::optional & /*defineOverrides*/) { return Pass::tryCompile(); } + virtual bool tryCompile(const ccstd::optional & /*defineOverrides*/) { return Pass::tryCompile(); } /** * @en Gets the shader variant of the current pass and given macro patches diff --git a/native/cocos/scene/RenderWindow.h b/native/cocos/scene/RenderWindow.h index 5a6a27b1ca..85f6a39618 100644 --- a/native/cocos/scene/RenderWindow.h +++ b/native/cocos/scene/RenderWindow.h @@ -27,7 +27,7 @@ #include "base/Macros.h" #include "base/RefVector.h" -#include "cocos/base/Optional.h" +#include "base/std/optional.h" #include "renderer/gfx-base/GFXDef-common.h" namespace cc { @@ -35,7 +35,7 @@ namespace scene { class Camera; struct IRenderWindowInfo { - cc::optional title; + ccstd::optional title; uint32_t width{0}; uint32_t height{0}; gfx::RenderPassInfo renderPassInfo; diff --git a/native/cocos/scene/Skybox.cpp b/native/cocos/scene/Skybox.cpp index 11fefc4ae4..06d92df614 100644 --- a/native/cocos/scene/Skybox.cpp +++ b/native/cocos/scene/Skybox.cpp @@ -324,7 +324,7 @@ void Skybox::updatePipeline() const { auto iter = pipeline->getMacros().find("CC_USE_IBL"); if (iter != pipeline->getMacros().end()) { const MacroValue ¯oIBL = iter->second; - const int32_t *macroIBLPtr = cc::get_if(¯oIBL); + const int32_t *macroIBLPtr = ccstd::get_if(¯oIBL); if (macroIBLPtr != nullptr && (*macroIBLPtr != useIBLValue)) { pipeline->setValue("CC_USE_IBL", useIBLValue); valueChanged = true; @@ -334,7 +334,7 @@ void Skybox::updatePipeline() const { auto iterDiffuseMap = pipeline->getMacros().find("CC_USE_DIFFUSEMAP"); if (iterDiffuseMap != pipeline->getMacros().end()) { const MacroValue ¯oDIFFUSEMAP = iterDiffuseMap->second; - const int32_t *macroDIFFUSEMAPPtr = cc::get_if(¯oDIFFUSEMAP); + const int32_t *macroDIFFUSEMAPPtr = ccstd::get_if(¯oDIFFUSEMAP); if (macroDIFFUSEMAPPtr != nullptr && ((*macroDIFFUSEMAPPtr != 0) != useDiffuseMapValue)) { pipeline->setValue("CC_USE_DIFFUSEMAP", useDiffuseMapValue); valueChanged = true; @@ -344,7 +344,7 @@ void Skybox::updatePipeline() const { auto iterUseHDR = pipeline->getMacros().find("CC_USE_HDR"); if (iterUseHDR != pipeline->getMacros().end()) { const MacroValue ¯oHDR = iterUseHDR->second; - const int32_t *macroHDRPtr = cc::get_if(¯oHDR); + const int32_t *macroHDRPtr = ccstd::get_if(¯oHDR); if (macroHDRPtr != nullptr && ((*macroHDRPtr != 0) != useHDRValue)) { pipeline->setValue("CC_USE_HDR", useHDRValue); valueChanged = true;