Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmllocale.cpp File Reference
#include "qqmllocale_p.h"
#include <private/qqmlcontext_p.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qtimezone.h>
#include <private/qlocale_p.h>
#include <private/qlocale_data_p.h>
#include <private/qv4dateobject_p.h>
#include <private/qv4numberobject_p.h>
#include <private/qv4stringobject_p.h>
#include "moc_qqmllocale_p.cpp"
+ Include dependency graph for qqmllocale.cpp:

Go to the source code of this file.

Classes

class  QV4LocaleDataDeletable
 

Macros

#define THROW_ERROR(string)
 
#define GET_LOCALE_DATA_RESOURCE(OBJECT)
 
#define LOCALE_FORMAT(FUNC)
 
#define LOCALE_FORMATTED_MONTHNAME(VARIABLE)
 
#define LOCALE_FORMATTED_DAYNAME(VARIABLE)
 
#define LOCALE_STRING_PROPERTY(VARIABLE)
 

Functions

 DEFINE_OBJECT_VTABLE (QQmlLocaleData)
 
static bool isLocaleObject (const QV4::Value &val)
 
 V4_DEFINE_EXTENSION (QV4LocaleDataDeletable, localeV4Data)
 

Macro Definition Documentation

◆ GET_LOCALE_DATA_RESOURCE

#define GET_LOCALE_DATA_RESOURCE (   OBJECT)
Value:
if (!r) \
THROW_ERROR("Not a valid Locale object")
GLboolean r
[2]

Definition at line 29 of file qqmllocale.cpp.

◆ LOCALE_FORMAT

#define LOCALE_FORMAT (   FUNC)
Value:
ReturnedValue QQmlLocaleData::method_ ##FUNC (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { \
QV4::Scope scope(b); \
const QLocale *locale = getThisLocale(scope, thisObject); \
if (!locale) \
return Encode::undefined(); \
if (argc > 1) \
THROW_ERROR("Locale: " #FUNC "(): Invalid arguments"); \
if (argc == 1) { \
quint32 intFormat = argv[0].toUInt32(); \
format = QLocale::FormatType(intFormat); \
} \
RETURN_RESULT(scope.engine->newString(locale-> FUNC (format))); \
}
@ LongFormat
Definition qlocale.h:865
quint64 ReturnedValue
GLboolean GLboolean GLboolean b
GLint GLsizei GLsizei GLenum format
unsigned int quint32
Definition qtypes.h:45
static constexpr ReturnedValue undefined()
unsigned int toUInt32() const
Definition qv4value_p.h:361

Definition at line 576 of file qqmllocale.cpp.

◆ LOCALE_FORMATTED_DAYNAME

#define LOCALE_FORMATTED_DAYNAME (   VARIABLE)
Value:
ReturnedValue QQmlLocaleData::method_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) {\
Scope scope(b); \
const QLocale *locale = getThisLocale(scope, thisObject); \
if (!locale) \
return Encode::undefined(); \
if (argc < 1 || argc > 2) \
THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
int idx = argv[0].toInt32(); \
if (idx < 0 || idx > 7) \
THROW_ERROR("Locale: Invalid day"); \
if (idx == 0) idx = 7; \
if (argc == 2) { \
if (argv[1].isNumber()) { \
quint32 intFormat = argv[1].toUInt32(); \
name = locale-> VARIABLE(idx, format); \
} else { \
THROW_ERROR("Locale: Invalid datetime format"); \
} \
} else { \
name = locale-> VARIABLE(idx, enumFormat); \
} \
RETURN_RESULT(scope.engine->newString(name)); \
}
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
Q_QML_PRIVATE_EXPORT QV4::ReturnedValue locale(QV4::ExecutionEngine *engine, const QString &localeName)
Provides locale specific properties and formatted data.
static bool isNumber(char s)
GLuint name
if(qFloatDistance(a, b)<(1<< 7))
[0]
int toInt32() const
Definition qv4value_p.h:350

Definition at line 625 of file qqmllocale.cpp.

◆ LOCALE_FORMATTED_MONTHNAME

#define LOCALE_FORMATTED_MONTHNAME (   VARIABLE)
Value:
ReturnedValue QQmlLocaleData::method_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) {\
Scope scope(b); \
const QLocale *locale = getThisLocale(scope, thisObject); \
if (!locale) \
return Encode::undefined(); \
if (argc < 1 || argc > 2) \
THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
int idx = argv[0].toInt32() + 1; \
if (idx < 1 || idx > 12) \
THROW_ERROR("Locale: Invalid month"); \
if (argc == 2) { \
if (argv[1].isNumber()) { \
quint32 intFormat = argv[1].toUInt32(); \
name = locale-> VARIABLE(idx, format); \
} else { \
THROW_ERROR("Locale: Invalid datetime format"); \
} \
} else { \
name = locale-> VARIABLE(idx, enumFormat); \
} \
RETURN_RESULT(scope.engine->newString(name)); \
}

Definition at line 597 of file qqmllocale.cpp.

◆ LOCALE_STRING_PROPERTY

#define LOCALE_STRING_PROPERTY (   VARIABLE)
Value:
ReturnedValue QQmlLocaleData::method_get_ ## VARIABLE (const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) \
{ \
Scope scope(b); \
const QLocale *locale = getThisLocale(scope, thisObject); \
if (!locale) \
return Encode::undefined(); \
RETURN_RESULT(scope.engine->newString(locale-> VARIABLE()));\
}

Definition at line 732 of file qqmllocale.cpp.

◆ THROW_ERROR

#define THROW_ERROR (   string)
Value:
do { \
return scope.engine->throwError(QString::fromUtf8(string)); \
} while (false)
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857

Definition at line 23 of file qqmllocale.cpp.

Function Documentation

◆ DEFINE_OBJECT_VTABLE()

DEFINE_OBJECT_VTABLE ( QQmlLocaleData  )

◆ isLocaleObject()

static bool isLocaleObject ( const QV4::Value val)
static

Definition at line 34 of file qqmllocale.cpp.

◆ V4_DEFINE_EXTENSION()

V4_DEFINE_EXTENSION ( QV4LocaleDataDeletable  ,
localeV4Data   
)