forked from zeromq/zproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zproject_qt.gsl
787 lines (718 loc) · 25.6 KB
/
zproject_qt.gsl
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
# Generate minimal Qt language bindings.
#
# This is a code generator built using the iMatix GSL code generation
# language. See https://github.com/imatix/gsl for details.
#
# Copyright (c) the Contributors as noted in the AUTHORS file.
# This file is part of zproject.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
register_target ("qt", "Qt binding")
# Target provides name space isolation for its functions
function target_qt
# This function will map c types to Qt types and also define how Qt types are
# transformed from and to c types when the c api is called.
#
function resolve_container (container)
my.container.qtName = "$(my.container.name:camel)"
my.container.qtArgType = my.container.c_type
my.container.qtArgPass = my.container.qtName
my.container.qtReturnType = my.container.c_type
my.container.qtCallPre = my.container.qtReturnType + " rv = "
my.container.qtCallPost = ""
my.container.qtReturn = "return rv;"
# Use native Qt types instead of the c ones.
if my.container.c_type = "void"
my.container.qtCallPre = ""
my.container.qtReturn = ""
elsif regexp.match ("uint(\\d+)_t", my.container.c_type, my.size)
my.container.qtArgType = "quint$(my.size)"
my.container.qtArgPass = "(" + my.container.c_type + ") " + my.container.qtName
my.container.qtReturnType = "quint$(my.size)"
elsif my.container.type = "string" & !my.container.by_reference & !my.container.fresh
my.container.qtArgType = "const QString &"
my.container.qtArgPass = my.container.qtName + ".toUtf8().data()"
my.container.qtReturnType = "const QString"
my.container.qtCallPre = my.container.qtReturnType + " rv = QString ("
my.container.qtCallPost = ")"
elsif my.container.type = "string"
my.container.qtArgType = "QString"
my.container.qtArgPass = my.container.qtName + ".toUtf8().data()"
my.container.qtReturnType = "QString"
my.container.qtCallPre = "char *retStr_ = "
my.container.qtCallPost = ";\n" + \
" QString rv = QString (retStr_);\n" + \
" zstr_free (&retStr_)"
elsif my.container.type = "format"
my.container.qtName = "param" # Rename as 'format' is confusing, due to not being format in Qt
my.container.qtArgType = "const QString &"
# Pass as string format argument, to avoid escaping problems.
my.container.qtArgPass = "\"%s\", " + my.container.qtName + ".toUtf8().data()"
my.container.qtReturnType = "const QString"
my.container.qtCallPre = my.container.qtReturnType + " rv = QString ("
my.container.qtCallPost = ")"
elsif count (project.class, defined (class.QtName) & (my.container.type = class.c_name)) \
| count (dependencies.class, defined (class.QtName) & (my.container.type = class.c_name))
# Resolve c classes
for project.class where (defined (class.QtName) & (my.container.type = class.c_name))
my.container.qtArgType = "$(class.QtName) *"
my.container.qtArgPass = my.container.qtName + "->self"
my.container.qtReturnType = "$(class.QtName) *"
my.container.qtCallPre = my.container.qtReturnType + "rv = new $(class.QtName) ("
my.container.qtCallPost = ")"
if my.container.by_reference
my.container.qtArgPass = "&" + my.container.qtArgPass
my.container.qtCallPre = my.container.qtCallPre + "*"
endif
endfor
for dependencies.class where (defined (class.QtName) & (my.container.type = class.c_name))
my.container.qtArgType = "$(class.QtName) *"
my.container.qtArgPass = my.container.qtName + "->self"
my.container.qtReturnType = "$(class.QtName) *"
my.container.qtCallPre = my.container.qtReturnType + "rv = new $(class.QtName) ("
my.container.qtCallPost = ")"
if my.container.by_reference
my.container.qtArgPass = "&" + my.container.qtArgPass
my.container.qtCallPre = my.container.qtCallPre + "*"
endif
endfor
endif
if my.container.variadic
my.container.qtArgType = ""
my.container.qtName = "..."
my.container.qtArgPass = "args"
my.container.qtArgPassPre = "va_list args;\n va_start (args, " + my.container.va_start + ");"
my.container.qtArgPassPost = "va_end (args);"
endif
endfunction
function method_has_self_pointer (method)
for my.method.argument
if argument_is_self_pointer (argument)
return 1
endif
endfor
return 0
endfunction
function argument_is_self_pointer (argument)
if argument.name = "self_p"
return 1
else
return 0
endif
endfunction
#
# A function for constructing a string of arguments for a method declaration
# in source/header files. Returns the argument string or 'ERROR'.
#
function method_arguments (method)
my.problematic = 0
my.out = ""
# Skip arguments that are,
# * self pointer to wrapped struct
# * variadic argument, if start argument is of type format
for my.method.argument where !argument_is_self_pointer (argument) & \
!(argument.variadic & count (my.method.argument, argument.type = "format"))
resolve_container (argument)
if !(my.method.is_destructor & first ())
my.out += argument.qtArgType
if !regexp.match ("[\\*&]$", argument.qtArgType?"")
my.out += " "
endif
my.out += argument.qtName
endif
if !last ()
my.out += ", "
endif
endfor
if my.problematic
my.out = "ERROR"
endif
return my.out
endfunction
#
# A function for constructing the string for a return type in a QML C header
#
function method_return_type (method)
resolve_container (my.method->return)
my.out = "$(my.method->return.qtReturnType) "
return my.out
endfunction
#
# A function for constructing the string for a method signature in Qt C++ file
#
function method_signature (method, in_header)
# Resolve conflicts with defines
for class.method
if method.name = "streq" \
| method.name = "strneq" \
| method.name = "export" \
| method.name = "delete" \
| method.name = "foreach"
method.QtName = method.name + " no conflict"
else
method.QtName = method.name
endif
endfor
for class.constructor as method
if method.name = "streq" \
| method.name = "strneq" \
| method.name = "export" \
| method.name = "delete" \
| method.name = "foreach"
method.QtName = method.name + " no conflict"
else
method.QtName = method.name
endif
endfor
my.problematic = 0
my.out = ""
if !my.method.is_destructor & !(my.method.is_constructor & my.method.name = "new")
if my.in_header & my.method.singleton & !method_has_self_pointer (my.method)
my.out += "static "
endif
if !my.method.is_constructor
my.out += method_return_type (my.method)
elsif my.method.name <> "new"
my.out += "$(class.QtName)* "
endif
else
method_return_type (my.method)
endif
if my.in_header
if my.method.is_constructor
if my.method.name = "new"
my.out += "explicit $(class.QtName)"
else
my.out += "$(my.method.QtName:camel)"
endif
elsif my.method.is_destructor
my.out += "~$(class.QtName)"
endif
else
my.out += "$(class.QtName:)::"
if my.method.is_constructor
if my.method.name = "new"
my.out += "$(class.QtName)"
else
my.out += "$(my.method.QtName:camel)"
endif
elsif my.method.is_destructor
my.out += "~$(class.QtName)"
endif
endif
if !my.method.is_constructor & !my.method.is_destructor
my.out += "$(my.method.QtName:camel)"
endif
my.out += " ("
my.args = method_arguments (my.method)
if my.args = "ERROR"
my.problematic = 1
else
my.out += my.args
endif
if my.method.is_constructor
if !(my.args = "")
my.out += ", "
endif
if my.in_header
my.out += "QObject *qObjParent = 0"
else
my.out += "QObject *qObjParent"
endif
endif
my.out += ")"
if my.method.is_constructor
if !my.in_header & my.method.name = "new"
my.out += " : QObject (qObjParent)"
endif
endif
# Variadic methods without a va_list sibling are not allowed, as the
# arguments cannot be forwared < C++11. This is to ensure backwards
# compatability.
# Exception is if the type is format!
if count (my.method.argument, argument.variadic) & \
!count (my.method.argument, argument.type = "format") & !my.method.has_va_list_sibling
my.problematic = 1
endif
# Exclude methods where strings are passed by reference as the might get
# deleted which does not play well with QString.
if count (my.method.argument, argument.type = "string" & argument.by_reference)
my.problematic = 1
endif
if my.problematic
my.out = # undefined
endif
return my.out
endfunction
function print_class_header (class)
>/*
>$(project.GENERATED_WARNING_HEADER:)
>*/
>#ifndef Q_$(CLASS.C_NAME)_H
>#define Q_$(CLASS.C_NAME)_H
>
>#include "$(project.QtName).h"
>
>class QT_$(PROJECT.PREFIX)_EXPORT $(class.QtName:) : public QObject
>{
> Q_OBJECT
>public:
>
> // Copy-construct to return the proper wrapped c types
> $(class.QtName:camel) ($(class.name:c)_t *self, QObject *qObjParent = 0);
for class.constructor as method where defined (method_signature (method, 1))
>
> // $(method.description:no,block)
> $(method_signature (method, 1));
endfor
for class.destructor as method where defined (method_signature (method, 1))
>
> // $(method.description:no,block)
> $(method_signature (method, 1));
endfor
for class.method where defined (method_signature (method, 1))
>
> // $(method.description:no,block)
> $(method_signature (method, 1));
endfor
>
> $(class.c_name:)_t *self;
>};
>#endif // Q_$(CLASS.C_NAME)_H
>/*
>$(project.GENERATED_WARNING_HEADER:)
>*/
endfunction
function print_class_body (class)
>/*
>$(project.GENERATED_WARNING_HEADER:)
>*/
>
>#include "$(project.QtName).h"
>
>///
>// Copy-construct to return the proper wrapped c types
>$(class.QtName:camel)::$(class.QtName:camel) ($(class.name:c)_t *self, QObject *qObjParent) : QObject (qObjParent)
>{
> this->self = self;
>}
>
for class.constructor as method where defined (method_signature (method, 0))
>
>///
>// $(method.description:no,block)
>$(method_signature (method, 0))
>{
if index () = 1
> this->self = $(class.c_name:)_$(method.c_name) (\
else
> return new $(class.QtName) ($(class.c_name:)_$(method.c_name) (\
endif
for method.argument where !argument.variadic
>$(argument.qtArgPass)\
if !last ()
>, \
endif
endfor
if index () = 1
>);
else
>), qObjParent);
endif
>}
endfor
for class.destructor as method where defined (method_signature (method, 0))
>
>///
>// $(method.description:no,block)
>$(method_signature (method, 0))
>{
> $(method->return.qtCallPre)$(class.c_name:)_$(method.c_name) (&self\
if count (method.argument) > 1
>, \
endif
for method.argument where !argument.variadic
if !first ()
>$(argument.qtArgPass)\
endif
if !last ()
>, \
endif
endfor
>)$(method->return.qtCallPost);
>}
endfor
for class.method where defined (method_signature (method, 0))
>
>///
>// $(method.description:no,block)
>$(method_signature (method, 0))
>{
for method.argument where defined (argument.qtArgPassPre)
> $(argument.qtArgPassPre)
endfor
if (method.has_va_list_sibling)
> $(method->return.qtCallPre)$(class.c_name:)_v$(method.c_name) (\
else
> $(method->return.qtCallPre)$(class.c_name:)_$(method.c_name) (\
endif
if method_has_self_pointer (method)
>&self\
if count (method.argument) > 1
>, \
endif
elsif !method.singleton
>self\
if count (method.argument)
>, \
endif
endif
for method.argument where !(!method.has_va_list_sibling & argument.variadic) \
& !argument_is_self_pointer (argument)
>$(argument.qtArgPass)\
if !last ()
>, \
endif
endfor
>)$(method->return.qtCallPost);
for method.argument where defined (argument.qtArgPassPost)
> $(argument.qtArgPassPost)
endfor
> $(method->return.qtReturn)
>}
endfor
>/*
>$(project.GENERATED_WARNING_HEADER:)
>*/
endfunction
.macro generate_binding ()
.directory.create ("bindings/qt/src")
.for class where defined (class.api) & class.private = "0"
. output "bindings/qt/src/$(class.qtname).h"
. print_class_header (class)
. close
.endfor
.#
.for dependencies.class
. output "bindings/qt/src/$(class.qtname).h"
. print_class_header (class)
. close
.endfor
.
.for class where defined (class.api) & class.private = "0"
. output "bindings/qt/src/$(class.qtname).cpp"
. print_class_body (class)
. close
.endfor
.#
.for dependencies.class
. output "bindings/qt/src/$(class.qtname).cpp"
. print_class_body (class)
. close
.endfor
.
.output "bindings/qt/src/$(project.QtName).h"
/*
$(project.GENERATED_WARNING_HEADER:)
*/
#ifndef Q_$(PROJECT.PREFIX)_H
#define Q_$(PROJECT.PREFIX)_H
#include <QObject>
#include <QString>
#include <$(project.header:)>
#if defined(Q_OS_WIN)
# if !defined(QT_$(PROJECT.PREFIX)_EXPORT) && !defined(QT_$(PROJECT.PREFIX)_IMPORT)
# define QT_$(PROJECT.PREFIX)_EXPORT
# elif defined(QT_$(PROJECT.PREFIX)_IMPORT)
# if defined(QT_$(PROJECT.PREFIX)_EXPORT)
# undef QT_$(PROJECT.PREFIX)_EXPORT
# endif
# define QT_$(PROJECT.PREFIX)_EXPORT __declspec(dllimport)
# elif defined(QT_$(PROJECT.PREFIX)_EXPORT)
# undef QT_$(PROJECT.PREFIX)_EXPORT
# define QT_$(PROJECT.PREFIX)_EXPORT __declspec(dllexport)
# endif
#else
# define QT_$(PROJECT.PREFIX)_EXPORT
#endif
// Opaque class structures to allow forward references
.for class where defined (class.api) & class.private = "0"
class $(class.QtName:);
.endfor
.for dependencies.class
class $(class.QtName:);
.endfor
// Public API classes
.for class where defined (class.api) & class.private = "0"
#include "$(class.qtname).h"
.endfor
.for dependencies.class
#include "$(class.qtname).h"
.endfor
#endif // Q_$(PROJECT.PREFIX)_H
/*
$(project.GENERATED_WARNING_HEADER:)
*/
.close
.###############################################################################
.# #
.# Generate config.pri, allows to switch between static or library build #
.# #
.###############################################################################
.if !file.exists ("bindings/qt/config.pri")
. output "bindings/qt/config.pri"
$(PROJECT.QTNAME)_LIBRARY = yes
. close
.endif
.###############################################################################
.# #
.# Generate common.pri, common flags and variables for both static and library #
.# #
.###############################################################################
.output "bindings/qt/common.pri"
$(project.GENERATED_WARNING_HEADER:)
exists(config.pri):infile(config.pri, $(PROJECT.QTNAME)_LIBRARY, yes): CONFIG += $(project.QtName)-uselib
TEMPLATE += fakelib
Q$(PROJECT.PREFIX)_LIBNAME = $(project.QtName)
CONFIG(debug, debug|release) {
mac:Q$(PROJECT.PREFIX)_LIBNAME = $$member(Q$(PROJECT.PREFIX)_LIBNAME, 0)_debug
else:win32:Q$(PROJECT.PREFIX)_LIBNAME = $$member(Q$(PROJECT.PREFIX)_LIBNAME, 0)d
}
TEMPLATE -= fakelib
CONFIG += link_pkgconfig
PKGCONFIG += lib$(project.name)
Q$(PROJECT.PREFIX)_LIBDIR = $$PWD/lib
unix:$(project.QtName)-uselib:!$(project.QtName)-buildlib:QMAKE_RPATHDIR += $$Q$(PROJECT.PREFIX)_LIBDIR
$(project.GENERATED_WARNING_HEADER:)
.close
.###############################################################################
.# #
.# Generate $(project.QtName).pri, adds sources/header or link library #
.# #
.###############################################################################
.output "bindings/qt/src/$(project.QtName).pri"
$(project.GENERATED_WARNING_HEADER:)
include(../common.pri)
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
$(project.QtName)-uselib:!$(project.QtName)-buildlib {
LIBS += -L$$Q$(PROJECT.PREFIX)_LIBDIR -l$$Q$(PROJECT.PREFIX)_LIBNAME
} else {
HEADERS += \\
$$PWD/$(project.QtName).h \\
.for class where defined (class.api) & class.private = "0"
. if !last() | count (dependencies.class) > 0
$$PWD/$(class.qtname).h \\
. else
$$PWD/$(class.qtname).h
. endif
.endfor
.for dependencies.class
. if !last ()
$$PWD/$(class.qtname).h \\
. else
$$PWD/$(class.qtname).h
. endif
.endfor
SOURCES += \\
.for class where defined (class.api) & class.private = "0"
. if !last() | count (dependencies.class) > 0
$$PWD/$(class.qtname).cpp \\
. else
$$PWD/$(class.qtname).cpp
. endif
.endfor
.for dependencies.class
. if !last ()
$$PWD/$(class.qtname).cpp \\
. else
$$PWD/$(class.qtname).cpp
. endif
.endfor
}
win32 {
$(project.QtName)-buildlib:shared:DEFINES += QT_$(PROJECT.PREFIX)_EXPORT
else:$(project.QtName)-uselib:DEFINES += QT_$(PROJECT.PREFIX)_IMPORT
}
$(project.GENERATED_WARNING_HEADER:)
.close
.###############################################################################
.# #
.# Generate buildlib/buildlib.pro, helper to build the library #
.# #
.###############################################################################
.if !file.exists ("bindings/qt/buildlib")
. directory.create("bindings/qt/buildlib")
.endif
.output "bindings/qt/buildlib/buildlib.pro"
$(project.GENERATED_WARNING_HEADER:)
TEMPLATE = lib
VERSION = $(project->version.major).$(project->version.minor).$(project->version.patch)
CONFIG += qt dll $(project.QtName)-buildlib
mac:CONFIG += absolute_library_soname
win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all
include(../src/$(project.QtName).pri)
TARGET = $$Q$(PROJECT.PREFIX)_LIBNAME
DESTDIR = $$Q$(PROJECT.PREFIX)_LIBDIR
.for use where use.optional = "0"
!packagesExist ($(use.libname)): error ("cannot link with -l$(use.linkname), install $(use.libname).")
.endfor
LIBS += \\
.for use where use.optional = "0"
-l$(use.linkname) \\
.endfor
-l$(project.name)
win32 {
DLLDESTDIR = $$[QT_INSTALL_BINS]
QMAKE_DISTCLEAN += $$[QT_INSTALL_BINS]\\$${Q$(PROJECT.PREFIX)_LIBNAME}.dll
}
unix {
isEmpty(PREFIX): PREFIX = /usr/local
header.files = $$PWD/../src/*.h
header.path = $$PREFIX/include
target.path = $$PREFIX/lib
INSTALLS += target header
}
$(project.GENERATED_WARNING_HEADER:)
.close
.###############################################################################
.# #
.# Generate master project file $(project.QtName) #
.# #
.###############################################################################
.output "bindings/qt/$(project.QtName).pro"
$(project.GENERATED_WARNING_HEADER:)
TEMPLATE=subdirs
CONFIG += ordered
include(common.pri)
$(project.QtName)-uselib:SUBDIRS=buildlib
SUBDIRS+=selftest
$(project.GENERATED_WARNING_HEADER:)
.close
.###############################################################################
.# #
.# Generate selftest project file selftest/selftest.pro #
.# #
.###############################################################################
.if !file.exists ("bindings/qt/selftest")
. directory.create("bindings/qt/selftest")
.endif
.output "bindings/qt/selftest/selftest.pro"
$(project.GENERATED_WARNING_HEADER:)
QT += core
QT -= gui
include(../src/$(project.QtName).pri)
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
$(project.GENERATED_WARNING_HEADER:)
.close
.###############################################################################
.# #
.# Generate selftest main.cpp #
.# #
.###############################################################################
.output "bindings/qt/selftest/main.cpp"
/*
$(project.GENERATED_WARNING_HEADER:)
*/
#include <QDebug>
#include "$(project.QtName).h"
int main(int argc, char **argv)
{
bool verbose;
if (argc == 2 && streq (argv [1], "-v"))
verbose = true;
else
verbose = false;
qDebug() << "Running $(project.QtName) selftests...\\n";
.for class where defined (class.api) & class.private = "0"
$(class.QtName)::test (verbose);
.endfor
.for dependencies.class
$(class.QtName)::test (verbose);
.endfor
qDebug() << "Tests passed OK\\n";
return 0;
}
/*
$(project.GENERATED_WARNING_HEADER:)
*/
.close
.###############################################################################
.# #
.# Generate selftest main.cpp #
.# #
.###############################################################################
.output "bindings/qt/README.md"
```
$(project.GENERATED_WARNING_HEADER:)
```
# $(project.QtName)
## Overview
$(project.QtName) is a Qt wrapper for $(project.name). It's possible to
statically or dynamically link against it as well as use it as internal or external
library.
## Internal library
You can use the Qt wrapper as internal library by including the
`$(project.QtName).pri` file. Here is a minimal example app:
```make
QT += core
QT -= gui
include(<path to pri file>/$(project.QtName).pri)
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
```
To link statically against the wrapper you need to change the
`$(PROJECT.QTNAME)_LIBRARY` variable in `config.pri` to `no`.
To link dynamically against the wrapper you need to change the
`$(PROJECT.QTNAME)_LIBRARY` variable in `config.pri` to `yes`.
## External library
To install $(project.QtName) as a shared library do the following:
```sh
qmake
make
sudo make install
```
The default installation directory prefix on unix is `/usr/local/`. If you like
to change the prefix define the PREFIX variable when calling qmake:
```sh
qmake PREFIX=/usr
```
## Notes
### Dependent classes
If the bindings are generated as part of a zproject that depends on another
zproject (e.g. zyre on czmq), the Qt bindings will automatically detect all
dependent classes and generate bindings for them too. Check the ./generate.sh
output the see which dependent classes couldn't be resolved.
### Format methods
Whenever a c method takes a format followed by variadic arguments, this is
replaced in the Qt bindings by one string instead.
### Excluded methods
If you're missing some methods in the bindings then because they have been
excluded. Currently methods are excluded if,
* they have variadic arguments and don't have a sibling method that
accepts a va_list. Most prominent example is probably printf and vprintf.
* they have char** arguments, as they might get freed which doesn't play
well with QString.
```
$(project.GENERATED_WARNING_HEADER:)
```
.close
.endmacro
if count (class, defined (class.api) & class.private = "0")
project.QtName = "q$(project.name)"
for class where defined (class.api) & class.private = "0"
class.QtName = "Q$(class.c_name:Pascal)"
endfor
for dependencies.class
class.QtName = "Q$(class.c_name:Pascal)"
endfor
generate_binding ()
endif
endfunction