summaryrefslogtreecommitdiff
path: root/source/core/slang-rtti-util.h
blob: cf513ecad7a14be84ae9f4f91f2cd0ef10c0bb52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef SLANG_CORE_RTTI_UTIL_H
#define SLANG_CORE_RTTI_UTIL_H

#include "slang-rtti-info.h"

namespace Slang {


struct RttiUtil
{
    static SlangResult setInt(int64_t value, const RttiInfo* rttiInfo, void* dst);
    static int64_t getInt64(const RttiInfo* rttiInfo, const void* src);

    static double asDouble(const RttiInfo* rttiInfo, const void* src);

    static SlangResult setFromDouble(double v, const RttiInfo* rttiInfo, void* dst);

    static bool asBool(const RttiInfo* rttiInfo, const void* src);

    static bool isDefault(RttiDefaultValue defaultValue, const RttiInfo* rttiInfo, const void* src);

        /// Gets funcs for default scenarios
    static RttiTypeFuncs getDefaultTypeFuncs(const RttiInfo* rttiInfo);

        /// Set a list count
    static SlangResult setListCount(RttiTypeFuncsMap* typeMap, const RttiInfo* elementType, void* dst, Index count);

        /// Returns if the type can be zero initialized
    static bool canZeroInit(const RttiInfo* type);
        /// Returns true if the type needs dtor
    static bool hasDtor(const RttiInfo* type);
        /// Returns true if we can memcpy to copy 
    static bool canMemCpy(const RttiInfo* type);

    static void ctorArray(RttiTypeFuncsMap* typeMap, const RttiInfo* rttiInfo, void* inDst, ptrdiff_t stride, Index count);
    static void copyArray(RttiTypeFuncsMap* typeMap, const RttiInfo* rttiInfo, void* inDst, const void* inSrc, ptrdiff_t stride, Index count);
    static void dtorArray(RttiTypeFuncsMap* typeMap, const RttiInfo* rttiInfo, void* inDst, ptrdiff_t stride, Index count);
};

} // namespace Slang

#endif // SLANG_CORE_RTTI_UTIL_H