18bf80f4bSopenharmony_ci/*
28bf80f4bSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
38bf80f4bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
48bf80f4bSopenharmony_ci * you may not use this file except in compliance with the License.
58bf80f4bSopenharmony_ci * You may obtain a copy of the License at
68bf80f4bSopenharmony_ci *
78bf80f4bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
88bf80f4bSopenharmony_ci *
98bf80f4bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
108bf80f4bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
118bf80f4bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128bf80f4bSopenharmony_ci * See the License for the specific language governing permissions and
138bf80f4bSopenharmony_ci * limitations under the License.
148bf80f4bSopenharmony_ci */
158bf80f4bSopenharmony_ci#include <PropertyTools/core_metadata.inl>
168bf80f4bSopenharmony_ci
178bf80f4bSopenharmony_ci#include <core/property/scoped_handle.h>
188bf80f4bSopenharmony_ci
198bf80f4bSopenharmony_ci#include <meta/ext/engine/internal_access.h>
208bf80f4bSopenharmony_ci#include <meta/interface/engine/intf_engine_data.h>
218bf80f4bSopenharmony_ci#include <meta/interface/engine/intf_engine_value.h>
228bf80f4bSopenharmony_ci#include <meta/interface/intf_object_registry.h>
238bf80f4bSopenharmony_ci
248bf80f4bSopenharmony_ciMETA_BEGIN_NAMESPACE()
258bf80f4bSopenharmony_ci
268bf80f4bSopenharmony_ci// clang-format off
278bf80f4bSopenharmony_ciusing SingleAndArrayTypes = TypeList<
288bf80f4bSopenharmony_ci    bool,
298bf80f4bSopenharmony_ci    int8_t,
308bf80f4bSopenharmony_ci    int16_t,
318bf80f4bSopenharmony_ci    int32_t,
328bf80f4bSopenharmony_ci    int64_t,
338bf80f4bSopenharmony_ci    uint8_t,
348bf80f4bSopenharmony_ci    uint16_t,
358bf80f4bSopenharmony_ci    uint32_t,
368bf80f4bSopenharmony_ci    uint64_t,
378bf80f4bSopenharmony_ci    float,
388bf80f4bSopenharmony_ci    double,
398bf80f4bSopenharmony_ci#ifdef __APPLE__
408bf80f4bSopenharmony_ci    size_t,
418bf80f4bSopenharmony_ci#endif
428bf80f4bSopenharmony_ci    BASE_NS::Math::Vec2,
438bf80f4bSopenharmony_ci    BASE_NS::Math::Vec3,
448bf80f4bSopenharmony_ci    BASE_NS::Math::Vec4,
458bf80f4bSopenharmony_ci    BASE_NS::Math::UVec2,
468bf80f4bSopenharmony_ci    BASE_NS::Math::UVec3,
478bf80f4bSopenharmony_ci    BASE_NS::Math::UVec4,
488bf80f4bSopenharmony_ci    BASE_NS::Math::IVec2,
498bf80f4bSopenharmony_ci    BASE_NS::Math::IVec3,
508bf80f4bSopenharmony_ci    BASE_NS::Math::IVec4,
518bf80f4bSopenharmony_ci    BASE_NS::Math::Quat,
528bf80f4bSopenharmony_ci    BASE_NS::Math::Mat3X3,
538bf80f4bSopenharmony_ci    BASE_NS::Math::Mat4X4,
548bf80f4bSopenharmony_ci    BASE_NS::Uid,
558bf80f4bSopenharmony_ci    CORE_NS::Entity,
568bf80f4bSopenharmony_ci    CORE_NS::EntityReference,
578bf80f4bSopenharmony_ci    BASE_NS::string,
588bf80f4bSopenharmony_ci    CORE_NS::IPropertyHandle*
598bf80f4bSopenharmony_ci    >;
608bf80f4bSopenharmony_ciusing VectorTypes = TypeList<
618bf80f4bSopenharmony_ci    BASE_NS::vector<float>,
628bf80f4bSopenharmony_ci    BASE_NS::vector<BASE_NS::Math::Mat4X4>,
638bf80f4bSopenharmony_ci    BASE_NS::vector<CORE_NS::EntityReference>
648bf80f4bSopenharmony_ci    >;
658bf80f4bSopenharmony_ci// clang-format on
668bf80f4bSopenharmony_ci
678bf80f4bSopenharmony_cinamespace Internal {
688bf80f4bSopenharmony_cinamespace {
698bf80f4bSopenharmony_ci
708bf80f4bSopenharmony_citemplate<bool ArrayTypes, typename... List>
718bf80f4bSopenharmony_civoid RegisterBasicEngineTypes(IEngineData& d, TypeList<List...>)
728bf80f4bSopenharmony_ci{
738bf80f4bSopenharmony_ci    (d.RegisterInternalValueAccess(MetaType<List>::coreType, CreateShared<EngineInternalValueAccess<List>>()), ...);
748bf80f4bSopenharmony_ci    if constexpr (ArrayTypes) {
758bf80f4bSopenharmony_ci        (d.RegisterInternalValueAccess(
768bf80f4bSopenharmony_ci             MetaType<List[]>::coreType, CreateShared<EngineInternalArrayValueAccess<List>>()),
778bf80f4bSopenharmony_ci            ...);
788bf80f4bSopenharmony_ci    }
798bf80f4bSopenharmony_ci}
808bf80f4bSopenharmony_ci
818bf80f4bSopenharmony_citemplate<bool ArrayTypes, typename... List>
828bf80f4bSopenharmony_civoid UnRegisterBasicEngineTypes(IEngineData& d, TypeList<List...>)
838bf80f4bSopenharmony_ci{
848bf80f4bSopenharmony_ci    (d.UnregisterInternalValueAccess(MetaType<List>::coreType), ...);
858bf80f4bSopenharmony_ci    if constexpr (ArrayTypes) {
868bf80f4bSopenharmony_ci        (d.UnregisterInternalValueAccess(MetaType<List[]>::coreType), ...);
878bf80f4bSopenharmony_ci    }
888bf80f4bSopenharmony_ci}
898bf80f4bSopenharmony_ci} // namespace
908bf80f4bSopenharmony_ci
918bf80f4bSopenharmony_civoid RegisterEngineTypes(IObjectRegistry& registry)
928bf80f4bSopenharmony_ci{
938bf80f4bSopenharmony_ci    auto& pr = registry.GetEngineData();
948bf80f4bSopenharmony_ci    RegisterBasicEngineTypes<true>(pr, SingleAndArrayTypes {});
958bf80f4bSopenharmony_ci    RegisterBasicEngineTypes<false>(pr, VectorTypes {});
968bf80f4bSopenharmony_ci}
978bf80f4bSopenharmony_ci
988bf80f4bSopenharmony_civoid UnRegisterEngineTypes(IObjectRegistry& registry)
998bf80f4bSopenharmony_ci{
1008bf80f4bSopenharmony_ci    auto& pr = registry.GetEngineData();
1018bf80f4bSopenharmony_ci    UnRegisterBasicEngineTypes<false>(pr, VectorTypes {});
1028bf80f4bSopenharmony_ci    UnRegisterBasicEngineTypes<true>(pr, SingleAndArrayTypes {});
1038bf80f4bSopenharmony_ci}
1048bf80f4bSopenharmony_ci
1058bf80f4bSopenharmony_ci} // namespace Internal
1068bf80f4bSopenharmony_ciMETA_END_NAMESPACE()
107