Skip to content

Commit

Permalink
Merge pull request #1906 from KLayout/issue-1899
Browse files Browse the repository at this point in the history
Issue 1899
  • Loading branch information
klayoutmatthias authored Oct 20, 2024
2 parents 05c13e6 + 761388f commit 2d1658c
Show file tree
Hide file tree
Showing 100 changed files with 1,389 additions and 228 deletions.
8 changes: 4 additions & 4 deletions scripts/mkqtdecl_common/c++.treetop
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ grammar CPP
( ":" s block_wo_curly_braces s )?
( trailing_return_type )?
a
(
blk:(
"{" s block s "}" /
";"?
) <PDeclaration>
Expand All @@ -200,7 +200,7 @@ grammar CPP
( ":" s block_wo_curly_braces s )?
( trailing_return_type )?
a
(
blk:(
"{" s block s "}" /
";"
) <PDeclaration>
Expand Down Expand Up @@ -436,7 +436,7 @@ grammar CPP
s ( ":" s block_wo_curly_braces s )?
( trailing_return_type )?
a
(
blk:(
"{" s block s "}" /
";"
) <PDeclaration>
Expand All @@ -452,7 +452,7 @@ grammar CPP
s ( ":" s block_wo_curly_braces s )?
( trailing_return_type )?
a
(
blk:(
"{" s block s "}" /
";"?
) <PDeclaration>
Expand Down
6 changes: 3 additions & 3 deletions scripts/mkqtdecl_common/cpp_classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize_copy(other)
# TODO: is there a better way to check whether dup can be used?
# Implement Hash?
#{args.map { |arg| "a = other.#{arg}\n"+
"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"+
"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"+
" @#{arg} = a\n"+
"elsif a.is_a?(Array)\n"+
" @#{arg} = a.collect { |aa| aa.dup }\n"+
Expand Down Expand Up @@ -550,8 +550,8 @@ def dump(i)
# @attribute inline Is true for inline declarations
class CPPDeclaration < CPPObject

attr_accessor :type, :template_decl, :visibility, :storage_class, :virtual, :inline
def_initializer :type, :template_decl, :visibility, :storage_class, :virtual, :inline
attr_accessor :type, :template_decl, :visibility, :storage_class, :virtual, :inline, :is_definition
def_initializer :type, :template_decl, :visibility, :storage_class, :virtual, :inline, :is_definition

def dump(i)
l = i
Expand Down
5 changes: 4 additions & 1 deletion scripts/mkqtdecl_common/cpp_parser_classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ def cpp
end

module PDeclaration
def is_definition
blk.text_value =~ /^\{/
end
def cpp
td = nil
if template.nonterminal?
Expand Down Expand Up @@ -438,7 +441,7 @@ def cpp
elsif d.is_a?(CPPEnum)
CPPEnumDeclaration::new(d, :default)
else
CPPDeclaration::new(d, td, :default, storage_class, virtual, inline)
CPPDeclaration::new(d, td, :default, storage_class, virtual, inline, self.is_definition)
end
end
end
Expand Down
31 changes: 26 additions & 5 deletions scripts/mkqtdecl_common/produce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,24 @@ def get_dtor

end

def collect_friend_definitions

friend_decl = []

(self.body_decl || []).each do |bd|
if bd.is_a?(CPPFriendDecl)
bd.decl.each do |decl|
if ! decl.template_decl && decl.respond_to?(:is_definition) && decl.is_definition
friend_decl << decl
end
end
end
end

friend_decl

end

def collect_ctors

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

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

# the drop test includes the static attribute so we can distinguish between
Expand Down Expand Up @@ -1977,7 +1995,7 @@ def produce_class(conf, decl_obj, ofile, index)
if ctors.empty? && conf.has_default_ctor?(cls)
func = CPPFunc::new(CPPQualifiedId::new(false, [ CPPId::new(decl_obj.myself, nil) ]), [], nil, nil)
type = CPPType::new(nil, func, nil)
def_ctor = CPPDeclaration::new(type, nil, :public, nil, false, false)
def_ctor = CPPDeclaration::new(type, nil, :public, nil, false, false, false)
def_ctor.parent = decl_obj
ctors << def_ctor
end
Expand All @@ -1989,7 +2007,9 @@ def produce_class(conf, decl_obj, ofile, index)
global_operators = []

# collect global operators with the given class as the first argument
@root.decls.each do |bd|
# Note that operators can also implicitly be declared as friends
(@root.decls + struct.collect_friend_definitions).each do |bd|

if bd.is_a?(CPPDeclaration) && bd.type.func && bd.type.name =~ /^operator/
op_func = bd.type.func
if op_func.args.size >= 1
Expand All @@ -1999,6 +2019,7 @@ def produce_class(conf, decl_obj, ofile, index)
end
end
end

end

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

if !rt.is_void?
ofile.puts(" return " + rt.access_gsi_return(decl_obj, "::#{mid}(*#{qt_alist.join(', ')});"))
ofile.puts(" return " + rt.access_gsi_return(decl_obj, "#{mid}(*#{qt_alist.join(', ')});"))
else
ofile.puts(" ::#{mid}(*#{qt_alist.join(', ')});")
ofile.puts(" #{mid}(*#{qt_alist.join(', ')});")
end

ofile.puts("}")
Expand Down
2 changes: 1 addition & 1 deletion src/gsiqt/qt5/QtCore/gsiDeclQCollatorSortKey.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static void _call_f_swap_2252 (const qt_gsi::GenericMethod * /*decl*/, void *cls

// bool ::operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
static bool op_QCollatorSortKey_operator_lt__5786(const QCollatorSortKey *_self, const QCollatorSortKey &rhs) {
return ::operator<(*_self, rhs);
return operator<(*_self, rhs);
}


Expand Down
48 changes: 48 additions & 0 deletions src/gsiqt/qt5/QtCore/gsiDeclQDeadlineTimer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,46 @@ static void _call_f_current_1680 (const qt_gsi::GenericStaticMethod * /*decl*/,
}


// bool ::operator==(QDeadlineTimer d1, QDeadlineTimer d2)
static bool op_QDeadlineTimer_operator_eq__eq__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
return operator==(*_self, d2);
}

// bool ::operator!=(QDeadlineTimer d1, QDeadlineTimer d2)
static bool op_QDeadlineTimer_operator_excl__eq__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
return operator!=(*_self, d2);
}

// bool ::operator<(QDeadlineTimer d1, QDeadlineTimer d2)
static bool op_QDeadlineTimer_operator_lt__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
return operator<(*_self, d2);
}

// bool ::operator<=(QDeadlineTimer d1, QDeadlineTimer d2)
static bool op_QDeadlineTimer_operator_lt__eq__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
return operator<=(*_self, d2);
}

// bool ::operator>(QDeadlineTimer d1, QDeadlineTimer d2)
static bool op_QDeadlineTimer_operator_gt__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
return operator>(*_self, d2);
}

// bool ::operator>=(QDeadlineTimer d1, QDeadlineTimer d2)
static bool op_QDeadlineTimer_operator_gt__eq__3532(QDeadlineTimer *_self, QDeadlineTimer d2) {
return operator>=(*_self, d2);
}

// QDeadlineTimer ::operator-(QDeadlineTimer dt, qint64 msecs)
static QDeadlineTimer op_QDeadlineTimer_operator_minus__2698(QDeadlineTimer *_self, qint64 msecs) {
return operator-(*_self, msecs);
}

// qint64 ::operator-(QDeadlineTimer dt1, QDeadlineTimer dt2)
static qint64 op_QDeadlineTimer_operator_minus__3532(QDeadlineTimer *_self, QDeadlineTimer dt2) {
return operator-(*_self, dt2);
}


namespace gsi
{
Expand All @@ -446,6 +486,14 @@ static gsi::Methods methods_QDeadlineTimer () {
methods += new qt_gsi::GenericMethod (":timerType", "@brief Method Qt::TimerType QDeadlineTimer::timerType()\n", true, &_init_f_timerType_c0, &_call_f_timerType_c0);
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);
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);
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.");
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.");
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.");
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.");
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.");
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.");
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.");
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.");
return methods;
}

Expand Down
26 changes: 13 additions & 13 deletions src/gsiqt/qt5/QtCore/gsiDeclQMargins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,67 +387,67 @@ static void _call_f_top_c0 (const qt_gsi::GenericMethod * /*decl*/, void *cls, g

// bool ::operator==(const QMargins &m1, const QMargins &m2)
static bool op_QMargins_operator_eq__eq__4122(const QMargins *_self, const QMargins &m2) {
return ::operator==(*_self, m2);
return operator==(*_self, m2);
}

// bool ::operator!=(const QMargins &m1, const QMargins &m2)
static bool op_QMargins_operator_excl__eq__4122(const QMargins *_self, const QMargins &m2) {
return ::operator!=(*_self, m2);
return operator!=(*_self, m2);
}

// QMargins ::operator+(const QMargins &m1, const QMargins &m2)
static QMargins op_QMargins_operator_plus__4122(const QMargins *_self, const QMargins &m2) {
return ::operator+(*_self, m2);
return operator+(*_self, m2);
}

// QMargins ::operator-(const QMargins &m1, const QMargins &m2)
static QMargins op_QMargins_operator_minus__4122(const QMargins *_self, const QMargins &m2) {
return ::operator-(*_self, m2);
return operator-(*_self, m2);
}

// QMargins ::operator+(const QMargins &lhs, int rhs)
static QMargins op_QMargins_operator_plus__2774(const QMargins *_self, int rhs) {
return ::operator+(*_self, rhs);
return operator+(*_self, rhs);
}

// QMargins ::operator-(const QMargins &lhs, int rhs)
static QMargins op_QMargins_operator_minus__2774(const QMargins *_self, int rhs) {
return ::operator-(*_self, rhs);
return operator-(*_self, rhs);
}

// QMargins ::operator*(const QMargins &margins, int factor)
static QMargins op_QMargins_operator_star__2774(const QMargins *_self, int factor) {
return ::operator*(*_self, factor);
return operator*(*_self, factor);
}

// QMargins ::operator*(const QMargins &margins, qreal factor)
static QMargins op_QMargins_operator_star__2976(const QMargins *_self, qreal factor) {
return ::operator*(*_self, factor);
return operator*(*_self, factor);
}

// QMargins ::operator/(const QMargins &margins, int divisor)
static QMargins op_QMargins_operator_slash__2774(const QMargins *_self, int divisor) {
return ::operator/(*_self, divisor);
return operator/(*_self, divisor);
}

// QMargins ::operator/(const QMargins &margins, qreal divisor)
static QMargins op_QMargins_operator_slash__2976(const QMargins *_self, qreal divisor) {
return ::operator/(*_self, divisor);
return operator/(*_self, divisor);
}

// QMargins ::operator+(const QMargins &margins)
static QMargins op_QMargins_operator_plus__2115(const QMargins *_self) {
return ::operator+(*_self);
return operator+(*_self);
}

// QMargins ::operator-(const QMargins &margins)
static QMargins op_QMargins_operator_minus__2115(const QMargins *_self) {
return ::operator-(*_self);
return operator-(*_self);
}

// QRect ::operator+(const QMargins &margins, const QRect &rectangle)
static QRect op_QMargins_operator_plus__3799(const QMargins *_self, const QRect &rectangle) {
return ::operator+(*_self, rectangle);
return operator+(*_self, rectangle);
}


Expand Down
22 changes: 11 additions & 11 deletions src/gsiqt/qt5/QtCore/gsiDeclQMarginsF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,57 +384,57 @@ static void _call_f_top_c0 (const qt_gsi::GenericMethod * /*decl*/, void *cls, g

// bool ::operator==(const QMarginsF &lhs, const QMarginsF &rhs)
static bool op_QMarginsF_operator_eq__eq__4262(const QMarginsF *_self, const QMarginsF &rhs) {
return ::operator==(*_self, rhs);
return operator==(*_self, rhs);
}

// bool ::operator!=(const QMarginsF &lhs, const QMarginsF &rhs)
static bool op_QMarginsF_operator_excl__eq__4262(const QMarginsF *_self, const QMarginsF &rhs) {
return ::operator!=(*_self, rhs);
return operator!=(*_self, rhs);
}

// QMarginsF ::operator+(const QMarginsF &lhs, const QMarginsF &rhs)
static QMarginsF op_QMarginsF_operator_plus__4262(const QMarginsF *_self, const QMarginsF &rhs) {
return ::operator+(*_self, rhs);
return operator+(*_self, rhs);
}

// QMarginsF ::operator-(const QMarginsF &lhs, const QMarginsF &rhs)
static QMarginsF op_QMarginsF_operator_minus__4262(const QMarginsF *_self, const QMarginsF &rhs) {
return ::operator-(*_self, rhs);
return operator-(*_self, rhs);
}

// QMarginsF ::operator+(const QMarginsF &lhs, qreal rhs)
static QMarginsF op_QMarginsF_operator_plus__3046(const QMarginsF *_self, qreal rhs) {
return ::operator+(*_self, rhs);
return operator+(*_self, rhs);
}

// QMarginsF ::operator-(const QMarginsF &lhs, qreal rhs)
static QMarginsF op_QMarginsF_operator_minus__3046(const QMarginsF *_self, qreal rhs) {
return ::operator-(*_self, rhs);
return operator-(*_self, rhs);
}

// QMarginsF ::operator*(const QMarginsF &lhs, qreal rhs)
static QMarginsF op_QMarginsF_operator_star__3046(const QMarginsF *_self, qreal rhs) {
return ::operator*(*_self, rhs);
return operator*(*_self, rhs);
}

// QMarginsF ::operator/(const QMarginsF &lhs, qreal divisor)
static QMarginsF op_QMarginsF_operator_slash__3046(const QMarginsF *_self, qreal divisor) {
return ::operator/(*_self, divisor);
return operator/(*_self, divisor);
}

// QMarginsF ::operator+(const QMarginsF &margins)
static QMarginsF op_QMarginsF_operator_plus__2185(const QMarginsF *_self) {
return ::operator+(*_self);
return operator+(*_self);
}

// QMarginsF ::operator-(const QMarginsF &margins)
static QMarginsF op_QMarginsF_operator_minus__2185(const QMarginsF *_self) {
return ::operator-(*_self);
return operator-(*_self);
}

// QRectF ::operator+(const QMarginsF &lhs, const QRectF &rhs)
static QRectF op_QMarginsF_operator_plus__3939(const QMarginsF *_self, const QRectF &rhs) {
return ::operator+(*_self, rhs);
return operator+(*_self, rhs);
}


Expand Down
4 changes: 2 additions & 2 deletions src/gsiqt/qt5/QtCore/gsiDeclQMetaMethod.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ static void _call_f_typeName_c0 (const qt_gsi::GenericMethod * /*decl*/, void *c

// bool ::operator==(const QMetaMethod &m1, const QMetaMethod &m2)
static bool op_QMetaMethod_operator_eq__eq__4680(const QMetaMethod *_self, const QMetaMethod &m2) {
return ::operator==(*_self, m2);
return operator==(*_self, m2);
}

// bool ::operator!=(const QMetaMethod &m1, const QMetaMethod &m2)
static bool op_QMetaMethod_operator_excl__eq__4680(const QMetaMethod *_self, const QMetaMethod &m2) {
return ::operator!=(*_self, m2);
return operator!=(*_self, m2);
}


Expand Down
Loading

0 comments on commit 2d1658c

Please sign in to comment.