[Kde-bindings] KDE/kdebindings/qtruby
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Mon Jun 5 22:52:39 UTC 2006
SVN commit 548584 by rdale:
* Added support for q_classinfo() attributes, equivalent to the c++
Q_CLASSINFO() macro. If the key of the q_classinfo is 'D-Bus Interface'
the slots in the class are marked as Q_SCRIPTABLE in the QMetaObject.
For example:
class LCDRange < Qt::Widget
q_classinfo('D-Bus Interface', 'MyInterface')
signals 'valueChanged(int)'
slots 'setValue(int)'
...
CCMAIL: kde-bindings at kde.org
M +11 -0 ChangeLog
M +35 -6 rubylib/qtruby/lib/Qt/qtruby.rb
--- trunk/KDE/kdebindings/qtruby/ChangeLog #548583:548584
@@ -1,5 +1,16 @@
2006-06-05 Richard Dale <rdale at foton.es>
+ * Added support for q_classinfo() attributes, equivalent to the c++
+ Q_CLASSINFO() macro. If the key of the q_classinfo is 'D-Bus Interface'
+ the slots in the class are marked as Q_SCRIPTABLE in the QMetaObject.
+ For example:
+
+ class LCDRange < Qt::Widget
+ q_classinfo('D-Bus Interface', 'MyInterface')
+ signals 'valueChanged(int)'
+ slots 'setValue(int)'
+ ...
+
* The metaObject methods for slots and signals are no longer added when
a Qt::Object is constructed, but when slots or signals are added to
a class. This means that signals as well as slots can be added to an
--- trunk/KDE/kdebindings/qtruby/rubylib/qtruby/lib/Qt/qtruby.rb #548583:548584
@@ -68,6 +68,12 @@
meta.changed = true
end
+ def self.q_classinfo(key, value)
+ meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
+ meta.add_classinfo(key, value)
+ meta.changed = true
+ end
+
def **(a)
return Qt::**(self, a)
end
@@ -1889,7 +1895,7 @@
end
end
- def Internal.makeMetaData(classname, signals, slots)
+ def Internal.makeMetaData(classname, classinfos, dbus, signals, slots)
# Each entry in 'stringdata' corresponds to a string in the
# qt_meta_stringdata_<classname> structure.
# 'pack_string' is used to convert 'stringdata' into the
@@ -1902,11 +1908,17 @@
# qt_meta_data_<classname> structure in the metaObject
data = [1, # revision
string_table.call(classname), # classname
- 0, 0, # classinfo
- signals.length + slots.length, 10, # methods
+ classinfos.length, classinfos.length > 0 ? 10 : 0, # classinfo
+ signals.length + slots.length,
+ 10 + (2*classinfos.length), # methods
0, 0, # properties
0, 0] # enums/sets
+ classinfos.each do |entry|
+ data.push string_table.call(entry[0]) # key
+ data.push string_table.call(entry[1]) # value
+ end
+
signals.each do |entry|
data.push string_table.call(entry.full_name) # signature
data.push string_table.call(entry.full_name.delete("^,")) # parameters
@@ -1920,7 +1932,11 @@
data.push string_table.call(entry.full_name.delete("^,")) # parameters
data.push string_table.call("") # type, "" means void
data.push string_table.call("") # tag
- data.push MethodSlot | AccessPublic # flags, always public for now
+ if dbus
+ data.push MethodScriptable | MethodSlot | AccessPublic # flags, always public for now
+ else
+ data.push MethodSlot | AccessPublic # flags, always public for now
+ end
end
data.push 0 # eod
@@ -1935,7 +1951,11 @@
if meta.metaobject.nil? or meta.changed
signals = meta.get_signals
slots = meta.get_slots
- stringdata, data = makeMetaData(qobject.class.name, signals, slots)
+ stringdata, data = makeMetaData( qobject.class.name,
+ meta.classinfos,
+ meta.dbus,
+ signals,
+ slots)
meta.metaobject = make_metaObject(qobject, stringdata, data)
meta.changed = false
addSignalMethods(qobject.class, getSignalNames(qobject.class))
@@ -1956,13 +1976,15 @@
QObjectMember = Struct.new :name, :full_name, :arg_types
class MetaInfo
- attr_accessor :signals, :slots, :metaobject, :mocargs, :changed
+ attr_accessor :classinfos, :dbus, :signals, :slots, :metaobject, :mocargs, :changed
def initialize(klass)
Meta[klass.name] = self
@klass = klass
@metaobject = nil
@signals = []
@slots = []
+ @classinfos = []
+ @dbus = false
@changed = false
Internal.addMetaObjectMethods(klass)
end
@@ -2022,6 +2044,13 @@
end
return all_slots
end
+
+ def add_classinfo(key, value)
+ @classinfos.push [key, value]
+ if key == 'D-Bus Interface'
+ @dbus = true
+ end
+ end
end # Qt::MetaInfo
# These values are from the enum WindowType in qnamespace.h.
More information about the Kde-bindings
mailing list