aboutsummaryrefslogtreecommitdiffstats
path: root/qtbindings/qtscript_gui/include/__package_shared.h
blob: f31928dd0d5fb95e7aaee49bd6cf34dcc46df895 (plain) (blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once

#include <qfont.h>
#include <qfontinfo.h>
#include <qfontmetrics.h>

#include <QtScript/qscriptvalue.h>
#include <QtScript/QScriptEngine>

Q_DECLARE_METATYPE(QFontInfo)
Q_DECLARE_METATYPE(QFontMetrics)
Q_DECLARE_METATYPE(QFontMetricsF)


namespace QtMetaTypePrivate {

template <>
inline void *QMetaTypeFunctionHelper<QFontInfo, true>::Construct(void *where, const void *t)
{
    if (t)
        return new (where) QFontInfo(*static_cast<const QFontInfo*>(t));
    return new (where) QFontInfo(QFont());
}





template <>
inline void *QMetaTypeFunctionHelper<QFontMetrics, true>::Construct(void *where, const void *t)
{
    if (t)
        return new (where) QFontMetrics(*static_cast<const QFontMetrics*>(t));
    return new (where) QFontMetrics(QFont());
}




template <>
inline void *QMetaTypeFunctionHelper<QFontMetricsF, true>::Construct(void *where, const void *t)
{
    if (t)
        return new (where) QFontMetricsF(*static_cast<const QFontMetricsF*>(t));
    return new (where) QFontMetricsF(QFont());
}

}

template <>
inline QFontInfo qscriptvalue_cast<QFontInfo>(const QScriptValue &value)
{
    QFont f;
    QFontInfo t(f);
    const int id = qMetaTypeId<QFontInfo>();

    if (qscriptvalue_cast_helper(value, id, (void*)&t))
        return t;

    return QFontInfo(QFont());
}

template <>
inline QFontMetrics qscriptvalue_cast<QFontMetrics>(const QScriptValue &value)
{
    QFont f;
    QFontMetrics t(f);
    const int id = qMetaTypeId<QFontMetrics>();

    if (qscriptvalue_cast_helper(value, id, (void*)&t))
        return t;

    return QFontMetrics(QFont());
}

template <>
inline QFontMetricsF qscriptvalue_cast<QFontMetricsF>(const QScriptValue &value)
{
    QFont f;
    QFontMetricsF t(f);
    const int id = qMetaTypeId<QFontMetricsF>();

    if (qscriptvalue_cast_helper(value, id, (void*)&t))
        return t;

    return QFontMetricsF(QFont());
}