ObjQt  Check-in [ed8ed56b3a]

Overview
Comment:Add OFString (QString)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ed8ed56b3a54eb9dd0cb2ee8618156f681fd7fcc2b7b724806016eb6148229dc
User & Date: js on 2017-04-09 12:19:53
Other Links: manifest | tags
Context
2017-04-09
12:20
Ownership fix for QtChildEvent check-in: 6de2243af6 user: js tags: trunk
12:19
Add OFString (QString) check-in: ed8ed56b3a user: js tags: trunk
2017-04-05
21:19
Add toOF() / toQt() for easy conversion check-in: e9fd43644a user: js tags: trunk
Changes

Modified ObjQt.pro from [2b8eeb5b52] to [209f0c7bf9].

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
TEMPLATE = lib
TARGET = ObjQt
DESTDIR = build
OBJECTS_DIR = build
QT += core gui widgets

INCLUDEPATH += common	\
	       QtCore	\
	       QtGui	\
	       QtWidgets

HEADERS += common/helpers.h		\

	   common/QtOwnershipManaging.h	\
	   QtCore/QtChildEvent.h	\
	   QtCore/QtCoreApplication.h	\
	   QtCore/QtEvent.h		\
	   QtCore/QtObject.h		\
	   QtCore/QtThread.h		\
	   QtGui/QtGuiApplication.h	\
	   QtGui/QtPaintDevice.h	\
	   QtWidgets/QtApplication.h	\
	   QtWidgets/QtWidget.h


SOURCES += QtCore/QtChildEvent.mm	\
           QtCore/QtCoreApplication.mm	\
	   QtCore/QtEvent.mm  		\
	   QtCore/QtObject.mm		\
	   QtCore/QtThread.mm		\
	   QtGui/QtGuiApplication.mm	\
	   QtGui/QtPaintDevice.mm	\
	   QtWidgets/QtApplication.mm	\












>











>
|







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
TEMPLATE = lib
TARGET = ObjQt
DESTDIR = build
OBJECTS_DIR = build
QT += core gui widgets

INCLUDEPATH += common	\
	       QtCore	\
	       QtGui	\
	       QtWidgets

HEADERS += common/helpers.h		\
	   common/OFString+QString.h	\
	   common/QtOwnershipManaging.h	\
	   QtCore/QtChildEvent.h	\
	   QtCore/QtCoreApplication.h	\
	   QtCore/QtEvent.h		\
	   QtCore/QtObject.h		\
	   QtCore/QtThread.h		\
	   QtGui/QtGuiApplication.h	\
	   QtGui/QtPaintDevice.h	\
	   QtWidgets/QtApplication.h	\
	   QtWidgets/QtWidget.h

SOURCES += common/OFString+QString.mm	\
	   QtCore/QtChildEvent.mm	\
           QtCore/QtCoreApplication.mm	\
	   QtCore/QtEvent.mm  		\
	   QtCore/QtObject.mm		\
	   QtCore/QtThread.mm		\
	   QtGui/QtGuiApplication.mm	\
	   QtGui/QtPaintDevice.mm	\
	   QtWidgets/QtApplication.mm	\

Added common/OFString+QString.h version [b10f5cc8a5].



















>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
#import <ObjFW/ObjFW.h>

#include <QString>

@interface OFString (QString)
+ (instancetype)stringWithQString: (const QString&)qString;
- initWithQString: (const QString&)qString;
- (QString)qString;
@end

Added common/OFString+QString.mm version [30948bf7cc].





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#import "OFString+QString.h"

@implementation OFString (QString)
+ stringWithQString: (const QString&)qString
{
	return [[[self alloc] initWithQString: qString] autorelease];
}

- initWithQString: (const QString&)qString
{
	static_assert(sizeof(QChar) == sizeof(of_char16_t),
	    "QChar and of_char16_t have a different size!");

	return [self initWithUTF16String: (of_char16_t*)qString.data()
				  length: qString.length()];
}

- (QString)qString
{
	static_assert(sizeof(of_char16_t) == sizeof(QChar),
	    "of_char16_t and QChar have a different size!");

	void *pool = objc_autoreleasePoolPush();
	QString ret = QString((QChar*)[self UTF16String]);

	objc_autoreleasePoolPop(pool);

	return ret;
}
@end

Modified common/helpers.h from [0f97c8adb0] to [600866af29].

1
2
3
4
5
6


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#import <ObjFW/ObjFW.h>

#include <QString>
#include <QSize>
#include <QRect>



static OF_INLINE OFString*
toOF(const QString &qString)
{
	return [OFString stringWithUTF8String: qString.toUtf8()];
}

static OF_INLINE QString
toQt(OFString *string)
{
	return QString::fromUtf8([string UTF8String]);
}

static OF_INLINE of_point_t
toOF(const QPoint &qPoint)
{
	return of_point(qPoint.x(), qPoint.y());
}






>
>



|





|







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
#import <ObjFW/ObjFW.h>

#include <QString>
#include <QSize>
#include <QRect>

#import "OFString+QString.h"

static OF_INLINE OFString*
toOF(const QString &qString)
{
	return [OFString stringWithQString: qString];
}

static OF_INLINE QString
toQt(OFString *string)
{
	return [string qString];
}

static OF_INLINE of_point_t
toOF(const QPoint &qPoint)
{
	return of_point(qPoint.x(), qPoint.y());
}