Skip to content

Commit 2d1658c

Browse files
Merge pull request KLayout#1906 from KLayout/issue-1899
Issue 1899
2 parents 05c13e6 + 761388f commit 2d1658c

File tree

100 files changed

+1389
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1389
-228
lines changed

scripts/mkqtdecl_common/c++.treetop

+4-4
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ grammar CPP
183183
( ":" s block_wo_curly_braces s )?
184184
( trailing_return_type )?
185185
a
186-
(
186+
blk:(
187187
"{" s block s "}" /
188188
";"?
189189
) <PDeclaration>
@@ -200,7 +200,7 @@ grammar CPP
200200
( ":" s block_wo_curly_braces s )?
201201
( trailing_return_type )?
202202
a
203-
(
203+
blk:(
204204
"{" s block s "}" /
205205
";"
206206
) <PDeclaration>
@@ -436,7 +436,7 @@ grammar CPP
436436
s ( ":" s block_wo_curly_braces s )?
437437
( trailing_return_type )?
438438
a
439-
(
439+
blk:(
440440
"{" s block s "}" /
441441
";"
442442
) <PDeclaration>
@@ -452,7 +452,7 @@ grammar CPP
452452
s ( ":" s block_wo_curly_braces s )?
453453
( trailing_return_type )?
454454
a
455-
(
455+
blk:(
456456
"{" s block s "}" /
457457
";"?
458458
) <PDeclaration>

scripts/mkqtdecl_common/cpp_classes.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def initialize_copy(other)
2626
# TODO: is there a better way to check whether dup can be used?
2727
# Implement Hash?
2828
#{args.map { |arg| "a = other.#{arg}\n"+
29-
"if a.is_a?(TrueClass) || a.is_a?(FalseClass) || a.is_a?(NilClass) || a.is_a?(Fixnum) || a.is_a?(Float) || a.is_a?(Symbol)\n"+
29+
"if a.is_a?(TrueClass) || a.is_a?(FalseClass) || a.is_a?(NilClass) || a.is_a?(1.class) || a.is_a?(1.0.class) || a.is_a?(Symbol)\n"+
3030
" @#{arg} = a\n"+
3131
"elsif a.is_a?(Array)\n"+
3232
" @#{arg} = a.collect { |aa| aa.dup }\n"+
@@ -550,8 +550,8 @@ def dump(i)
550550
# @attribute inline Is true for inline declarations
551551
class CPPDeclaration < CPPObject
552552

553-
attr_accessor :type, :template_decl, :visibility, :storage_class, :virtual, :inline
554-
def_initializer :type, :template_decl, :visibility, :storage_class, :virtual, :inline
553+
attr_accessor :type, :template_decl, :visibility, :storage_class, :virtual, :inline, :is_definition
554+
def_initializer :type, :template_decl, :visibility, :storage_class, :virtual, :inline, :is_definition
555555

556556
def dump(i)
557557
l = i

scripts/mkqtdecl_common/cpp_parser_classes.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ def cpp
409409
end
410410

411411
module PDeclaration
412+
def is_definition
413+
blk.text_value =~ /^\{/
414+
end
412415
def cpp
413416
td = nil
414417
if template.nonterminal?
@@ -438,7 +441,7 @@ def cpp
438441
elsif d.is_a?(CPPEnum)
439442
CPPEnumDeclaration::new(d, :default)
440443
else
441-
CPPDeclaration::new(d, td, :default, storage_class, virtual, inline)
444+
CPPDeclaration::new(d, td, :default, storage_class, virtual, inline, self.is_definition)
442445
end
443446
end
444447
end

scripts/mkqtdecl_common/produce.rb

+26-5
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,24 @@ def get_dtor
424424

425425
end
426426

427+
def collect_friend_definitions
428+
429+
friend_decl = []
430+
431+
(self.body_decl || []).each do |bd|
432+
if bd.is_a?(CPPFriendDecl)
433+
bd.decl.each do |decl|
434+
if ! decl.template_decl && decl.respond_to?(:is_definition) && decl.is_definition
435+
friend_decl << decl
436+
end
437+
end
438+
end
439+
end
440+
441+
friend_decl
442+
443+
end
444+
427445
def collect_ctors
428446

429447
ctors = []
@@ -1202,7 +1220,7 @@ def target_name(cls, bd, mid, mm = nil, decl = nil)
12021220

12031221
# we also test for the parent of bd which may be different from cls if
12041222
# the method is imported from a base class or through "using"
1205-
cls2 = bd.parent.myself || ""
1223+
cls2 = (bd.parent && bd.parent.myself) || ""
12061224
sig2 = bd.sig(cls2)
12071225

12081226
# the drop test includes the static attribute so we can distinguish between
@@ -1977,7 +1995,7 @@ def produce_class(conf, decl_obj, ofile, index)
19771995
if ctors.empty? && conf.has_default_ctor?(cls)
19781996
func = CPPFunc::new(CPPQualifiedId::new(false, [ CPPId::new(decl_obj.myself, nil) ]), [], nil, nil)
19791997
type = CPPType::new(nil, func, nil)
1980-
def_ctor = CPPDeclaration::new(type, nil, :public, nil, false, false)
1998+
def_ctor = CPPDeclaration::new(type, nil, :public, nil, false, false, false)
19811999
def_ctor.parent = decl_obj
19822000
ctors << def_ctor
19832001
end
@@ -1989,7 +2007,9 @@ def produce_class(conf, decl_obj, ofile, index)
19892007
global_operators = []
19902008

19912009
# collect global operators with the given class as the first argument
1992-
@root.decls.each do |bd|
2010+
# Note that operators can also implicitly be declared as friends
2011+
(@root.decls + struct.collect_friend_definitions).each do |bd|
2012+
19932013
if bd.is_a?(CPPDeclaration) && bd.type.func && bd.type.name =~ /^operator/
19942014
op_func = bd.type.func
19952015
if op_func.args.size >= 1
@@ -1999,6 +2019,7 @@ def produce_class(conf, decl_obj, ofile, index)
19992019
end
20002020
end
20012021
end
2022+
20022023
end
20032024

20042025
native_impl = conf.native_impl(cls)
@@ -2359,9 +2380,9 @@ def produce_class(conf, decl_obj, ofile, index)
23592380
ofile.puts("static #{rt.gsi_decl_return(decl_obj)} op_#{clsn}_#{mn}_#{hk}(#{args}) {")
23602381

23612382
if !rt.is_void?
2362-
ofile.puts(" return " + rt.access_gsi_return(decl_obj, "::#{mid}(*#{qt_alist.join(', ')});"))
2383+
ofile.puts(" return " + rt.access_gsi_return(decl_obj, "#{mid}(*#{qt_alist.join(', ')});"))
23632384
else
2364-
ofile.puts(" ::#{mid}(*#{qt_alist.join(', ')});")
2385+
ofile.puts(" #{mid}(*#{qt_alist.join(', ')});")
23652386
end
23662387

23672388
ofile.puts("}")

src/gsiqt/qt5/QtCore/gsiDeclQCollatorSortKey.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static void _call_f_swap_2252 (const qt_gsi::GenericMethod * /*decl*/, void *cls
114114

115115
// bool ::operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
116116
static bool op_QCollatorSortKey_operator_lt__5786(const QCollatorSortKey *_self, const QCollatorSortKey &rhs) {
117-
return ::operator<(*_self, rhs);
117+
return operator<(*_self, rhs);
118118
}
119119

120120

src/gsiqt/qt5/QtCore/gsiDeclQDeadlineTimer.cc

+48
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,46 @@ static void _call_f_current_1680 (const qt_gsi::GenericStaticMethod * /*decl*/,
420420
}
421421

422422

423+
// bool ::operator==(QDeadlineTimer d1, QDeadlineTimer d2)
424+
static bool op_QDeadlineTimer_operator_eq__eq__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
425+
return operator==(*_self, d2);
426+
}
427+
428+
// bool ::operator!=(QDeadlineTimer d1, QDeadlineTimer d2)
429+
static bool op_QDeadlineTimer_operator_excl__eq__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
430+
return operator!=(*_self, d2);
431+
}
432+
433+
// bool ::operator<(QDeadlineTimer d1, QDeadlineTimer d2)
434+
static bool op_QDeadlineTimer_operator_lt__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
435+
return operator<(*_self, d2);
436+
}
437+
438+
// bool ::operator<=(QDeadlineTimer d1, QDeadlineTimer d2)
439+
static bool op_QDeadlineTimer_operator_lt__eq__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
440+
return operator<=(*_self, d2);
441+
}
442+
443+
// bool ::operator>(QDeadlineTimer d1, QDeadlineTimer d2)
444+
static bool op_QDeadlineTimer_operator_gt__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
445+
return operator>(*_self, d2);
446+
}
447+
448+
// bool ::operator>=(QDeadlineTimer d1, QDeadlineTimer d2)
449+
static bool op_QDeadlineTimer_operator_gt__eq__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
450+
return operator>=(*_self, d2);
451+
}
452+
453+
// QDeadlineTimer ::operator-(QDeadlineTimer dt, qint64 msecs)
454+
static QDeadlineTimer op_QDeadlineTimer_operator_minus__2698(QDeadlineTimer *_self, qint64 msecs) {
455+
return operator-(*_self, msecs);
456+
}
457+
458+
// qint64 ::operator-(QDeadlineTimer dt1, QDeadlineTimer dt2)
459+
static qint64 op_QDeadlineTimer_operator_minus__3532(QDeadlineTimer *_self, QDeadlineTimer dt2) {
460+
return operator-(*_self, dt2);
461+
}
462+
423463

424464
namespace gsi
425465
{
@@ -446,6 +486,14 @@ static gsi::Methods methods_QDeadlineTimer () {
446486
methods += new qt_gsi::GenericMethod (":timerType", "@brief Method Qt::TimerType QDeadlineTimer::timerType()\n", true, &_init_f_timerType_c0, &_call_f_timerType_c0);
447487
methods += new qt_gsi::GenericStaticMethod ("addNSecs", "@brief Static method QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs)\nThis method is static and can be called without an instance.", &_init_f_addNSecs_2698, &_call_f_addNSecs_2698);
448488
methods += new qt_gsi::GenericStaticMethod ("current", "@brief Static method QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType)\nThis method is static and can be called without an instance.", &_init_f_current_1680, &_call_f_current_1680);
489+
methods += gsi::method_ext("==", &::op_QDeadlineTimer_operator_eq__eq__3532, gsi::arg ("d2"), "@brief Operator bool ::operator==(QDeadlineTimer d1, QDeadlineTimer d2)\nThis is the mapping of the global operator to the instance method.");
490+
methods += gsi::method_ext("!=", &::op_QDeadlineTimer_operator_excl__eq__3532, gsi::arg ("d2"), "@brief Operator bool ::operator!=(QDeadlineTimer d1, QDeadlineTimer d2)\nThis is the mapping of the global operator to the instance method.");
491+
methods += gsi::method_ext("<", &::op_QDeadlineTimer_operator_lt__3532, gsi::arg ("d2"), "@brief Operator bool ::operator<(QDeadlineTimer d1, QDeadlineTimer d2)\nThis is the mapping of the global operator to the instance method.");
492+
methods += gsi::method_ext("<=", &::op_QDeadlineTimer_operator_lt__eq__3532, gsi::arg ("d2"), "@brief Operator bool ::operator<=(QDeadlineTimer d1, QDeadlineTimer d2)\nThis is the mapping of the global operator to the instance method.");
493+
methods += gsi::method_ext(">", &::op_QDeadlineTimer_operator_gt__3532, gsi::arg ("d2"), "@brief Operator bool ::operator>(QDeadlineTimer d1, QDeadlineTimer d2)\nThis is the mapping of the global operator to the instance method.");
494+
methods += gsi::method_ext(">=", &::op_QDeadlineTimer_operator_gt__eq__3532, gsi::arg ("d2"), "@brief Operator bool ::operator>=(QDeadlineTimer d1, QDeadlineTimer d2)\nThis is the mapping of the global operator to the instance method.");
495+
methods += gsi::method_ext("-", &::op_QDeadlineTimer_operator_minus__2698, gsi::arg ("msecs"), "@brief Operator QDeadlineTimer ::operator-(QDeadlineTimer dt, qint64 msecs)\nThis is the mapping of the global operator to the instance method.");
496+
methods += gsi::method_ext("-", &::op_QDeadlineTimer_operator_minus__3532, gsi::arg ("dt2"), "@brief Operator qint64 ::operator-(QDeadlineTimer dt1, QDeadlineTimer dt2)\nThis is the mapping of the global operator to the instance method.");
449497
return methods;
450498
}
451499

src/gsiqt/qt5/QtCore/gsiDeclQMargins.cc

+13-13
Original file line numberDiff line numberDiff line change
@@ -387,67 +387,67 @@ static void _call_f_top_c0 (const qt_gsi::GenericMethod * /*decl*/, void *cls, g
387387

388388
// bool ::operator==(const QMargins &m1, const QMargins &m2)
389389
static bool op_QMargins_operator_eq__eq__4122(const QMargins *_self, const QMargins &m2) {
390-
return ::operator==(*_self, m2);
390+
return operator==(*_self, m2);
391391
}
392392

393393
// bool ::operator!=(const QMargins &m1, const QMargins &m2)
394394
static bool op_QMargins_operator_excl__eq__4122(const QMargins *_self, const QMargins &m2) {
395-
return ::operator!=(*_self, m2);
395+
return operator!=(*_self, m2);
396396
}
397397

398398
// QMargins ::operator+(const QMargins &m1, const QMargins &m2)
399399
static QMargins op_QMargins_operator_plus__4122(const QMargins *_self, const QMargins &m2) {
400-
return ::operator+(*_self, m2);
400+
return operator+(*_self, m2);
401401
}
402402

403403
// QMargins ::operator-(const QMargins &m1, const QMargins &m2)
404404
static QMargins op_QMargins_operator_minus__4122(const QMargins *_self, const QMargins &m2) {
405-
return ::operator-(*_self, m2);
405+
return operator-(*_self, m2);
406406
}
407407

408408
// QMargins ::operator+(const QMargins &lhs, int rhs)
409409
static QMargins op_QMargins_operator_plus__2774(const QMargins *_self, int rhs) {
410-
return ::operator+(*_self, rhs);
410+
return operator+(*_self, rhs);
411411
}
412412

413413
// QMargins ::operator-(const QMargins &lhs, int rhs)
414414
static QMargins op_QMargins_operator_minus__2774(const QMargins *_self, int rhs) {
415-
return ::operator-(*_self, rhs);
415+
return operator-(*_self, rhs);
416416
}
417417

418418
// QMargins ::operator*(const QMargins &margins, int factor)
419419
static QMargins op_QMargins_operator_star__2774(const QMargins *_self, int factor) {
420-
return ::operator*(*_self, factor);
420+
return operator*(*_self, factor);
421421
}
422422

423423
// QMargins ::operator*(const QMargins &margins, qreal factor)
424424
static QMargins op_QMargins_operator_star__2976(const QMargins *_self, qreal factor) {
425-
return ::operator*(*_self, factor);
425+
return operator*(*_self, factor);
426426
}
427427

428428
// QMargins ::operator/(const QMargins &margins, int divisor)
429429
static QMargins op_QMargins_operator_slash__2774(const QMargins *_self, int divisor) {
430-
return ::operator/(*_self, divisor);
430+
return operator/(*_self, divisor);
431431
}
432432

433433
// QMargins ::operator/(const QMargins &margins, qreal divisor)
434434
static QMargins op_QMargins_operator_slash__2976(const QMargins *_self, qreal divisor) {
435-
return ::operator/(*_self, divisor);
435+
return operator/(*_self, divisor);
436436
}
437437

438438
// QMargins ::operator+(const QMargins &margins)
439439
static QMargins op_QMargins_operator_plus__2115(const QMargins *_self) {
440-
return ::operator+(*_self);
440+
return operator+(*_self);
441441
}
442442

443443
// QMargins ::operator-(const QMargins &margins)
444444
static QMargins op_QMargins_operator_minus__2115(const QMargins *_self) {
445-
return ::operator-(*_self);
445+
return operator-(*_self);
446446
}
447447

448448
// QRect ::operator+(const QMargins &margins, const QRect &rectangle)
449449
static QRect op_QMargins_operator_plus__3799(const QMargins *_self, const QRect &rectangle) {
450-
return ::operator+(*_self, rectangle);
450+
return operator+(*_self, rectangle);
451451
}
452452

453453

src/gsiqt/qt5/QtCore/gsiDeclQMarginsF.cc

+11-11
Original file line numberDiff line numberDiff line change
@@ -384,57 +384,57 @@ static void _call_f_top_c0 (const qt_gsi::GenericMethod * /*decl*/, void *cls, g
384384

385385
// bool ::operator==(const QMarginsF &lhs, const QMarginsF &rhs)
386386
static bool op_QMarginsF_operator_eq__eq__4262(const QMarginsF *_self, const QMarginsF &rhs) {
387-
return ::operator==(*_self, rhs);
387+
return operator==(*_self, rhs);
388388
}
389389

390390
// bool ::operator!=(const QMarginsF &lhs, const QMarginsF &rhs)
391391
static bool op_QMarginsF_operator_excl__eq__4262(const QMarginsF *_self, const QMarginsF &rhs) {
392-
return ::operator!=(*_self, rhs);
392+
return operator!=(*_self, rhs);
393393
}
394394

395395
// QMarginsF ::operator+(const QMarginsF &lhs, const QMarginsF &rhs)
396396
static QMarginsF op_QMarginsF_operator_plus__4262(const QMarginsF *_self, const QMarginsF &rhs) {
397-
return ::operator+(*_self, rhs);
397+
return operator+(*_self, rhs);
398398
}
399399

400400
// QMarginsF ::operator-(const QMarginsF &lhs, const QMarginsF &rhs)
401401
static QMarginsF op_QMarginsF_operator_minus__4262(const QMarginsF *_self, const QMarginsF &rhs) {
402-
return ::operator-(*_self, rhs);
402+
return operator-(*_self, rhs);
403403
}
404404

405405
// QMarginsF ::operator+(const QMarginsF &lhs, qreal rhs)
406406
static QMarginsF op_QMarginsF_operator_plus__3046(const QMarginsF *_self, qreal rhs) {
407-
return ::operator+(*_self, rhs);
407+
return operator+(*_self, rhs);
408408
}
409409

410410
// QMarginsF ::operator-(const QMarginsF &lhs, qreal rhs)
411411
static QMarginsF op_QMarginsF_operator_minus__3046(const QMarginsF *_self, qreal rhs) {
412-
return ::operator-(*_self, rhs);
412+
return operator-(*_self, rhs);
413413
}
414414

415415
// QMarginsF ::operator*(const QMarginsF &lhs, qreal rhs)
416416
static QMarginsF op_QMarginsF_operator_star__3046(const QMarginsF *_self, qreal rhs) {
417-
return ::operator*(*_self, rhs);
417+
return operator*(*_self, rhs);
418418
}
419419

420420
// QMarginsF ::operator/(const QMarginsF &lhs, qreal divisor)
421421
static QMarginsF op_QMarginsF_operator_slash__3046(const QMarginsF *_self, qreal divisor) {
422-
return ::operator/(*_self, divisor);
422+
return operator/(*_self, divisor);
423423
}
424424

425425
// QMarginsF ::operator+(const QMarginsF &margins)
426426
static QMarginsF op_QMarginsF_operator_plus__2185(const QMarginsF *_self) {
427-
return ::operator+(*_self);
427+
return operator+(*_self);
428428
}
429429

430430
// QMarginsF ::operator-(const QMarginsF &margins)
431431
static QMarginsF op_QMarginsF_operator_minus__2185(const QMarginsF *_self) {
432-
return ::operator-(*_self);
432+
return operator-(*_self);
433433
}
434434

435435
// QRectF ::operator+(const QMarginsF &lhs, const QRectF &rhs)
436436
static QRectF op_QMarginsF_operator_plus__3939(const QMarginsF *_self, const QRectF &rhs) {
437-
return ::operator+(*_self, rhs);
437+
return operator+(*_self, rhs);
438438
}
439439

440440

src/gsiqt/qt5/QtCore/gsiDeclQMetaMethod.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,12 @@ static void _call_f_typeName_c0 (const qt_gsi::GenericMethod * /*decl*/, void *c
317317

318318
// bool ::operator==(const QMetaMethod &m1, const QMetaMethod &m2)
319319
static bool op_QMetaMethod_operator_eq__eq__4680(const QMetaMethod *_self, const QMetaMethod &m2) {
320-
return ::operator==(*_self, m2);
320+
return operator==(*_self, m2);
321321
}
322322

323323
// bool ::operator!=(const QMetaMethod &m1, const QMetaMethod &m2)
324324
static bool op_QMetaMethod_operator_excl__eq__4680(const QMetaMethod *_self, const QMetaMethod &m2) {
325-
return ::operator!=(*_self, m2);
325+
return operator!=(*_self, m2);
326326
}
327327

328328

0 commit comments

Comments
 (0)