Adeodato Simó
2005-Apr-09 21:50 UTC
[Pkg-kde-talk] qtruby.rb: backporting the ''Module includes Qt'' bug to 3.3
--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
Hello Richard,
I''m one of the KDE packagers in Debian. Our next release, Sarge, will
be shipping with KDE 3.3, and a user has requested [1] that we
backport the "include ''Qt'' in Module pollutes its
namespace" fix from
KDE_3_4_BRANCH.
[1] http://bugs.debian.org/303608
I''ve digged into it today and backported the CVS commit.
I''ve tested
the resulting package and seems to work, but I''d really appreciate if
you could have a quick look at the patch we''ll be applying
(attached).
I''m asking this because, although the patch came from CVS,
I''ve needed
to do a bit of tweaking to it, and I fear having left something out,
or having included something that will have some nasty effects that my
testing hasn''t discovered.
The changes are explained at the top of the diff, the involved CVS
revisions are listed in it too.
Thanks in advance,
--
Adeodato Simó
EM: asp16 [ykwim] alu.ua.es | PK: DA6AE621
Listening to: Eric Clapton - Old love
Kindness is a language which the deaf can hear and the blind can read.
-- Mark Twain
--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="050-qtruby-no-include-Qt-in-Module.diff"
Index: rubylib/qtruby/lib/Qt/qtruby.rb
==================================================================RCS file:
/home/kde/kdebindings/qtruby/rubylib/qtruby/lib/Qt/qtruby.rb,v
retrieving revision 1.61
retrieving revision 1.62
NOTE: This is not a pristine patch from CVS. A hunk had to be
removed (the one reverting the Time hack, since it was not in 3.3),
and a couple of them (try_initialize, do_method_missing) had to had
their context adjusted. Also, continue_new_instance wasn''t present
in the 3_4_BRANCH version, so I added a hunk to change it from a
method to a module function. Rediffed, too, to get offsets right.
diff -u -p -r1.61 -r1.62
--- kdebindings/qtruby/rubylib/qtruby/lib/Qt/qtruby.rb 24 Mar 2005 04:59:58
-0000 1.61
+++ kdebindings/qtruby/rubylib/qtruby/lib/Qt/qtruby.rb 30 Mar 2005 13:35:01
-0000 1.62
@@ -18,9 +18,9 @@
=end
module Qt
- module DebugLevel
- Off, Minimal, High, Extensive = 0, 1, 2, 3
- end
+ module DebugLevel
+ Off, Minimal, High, Extensive = 0, 1, 2, 3
+ end
module QtDebugChannel
QTDB_NONE = 0x00
@@ -30,17 +30,18 @@
QTDB_GC = 0x08
QTDB_VIRTUAL = 0x10
QTDB_VERBOSE = 0x20
- QTDB_ALL = QTDB_VERBOSE | QTDB_VIRTUAL | QTDB_GC | QTDB_CALLS |
QTDB_METHOD_MISSING | QTDB_AMBIGUOUS
+ QTDB_ALL = QTDB_VERBOSE | QTDB_VIRTUAL | QTDB_GC | QTDB_CALLS |
QTDB_METHOD_MISSING | QTDB_AMBIGUOUS
+ end
+
+ @@debug_level = DebugLevel::Off
+ def Qt.debug_level=(level)
+ @@debug_level = level
+ Internal::setDebug Qt::QtDebugChannel::QTDB_ALL if level >=
DebugLevel::Extensive
end
- @@debug_level = DebugLevel::Off
- def Qt.debug_level=(level)
- @@debug_level = level
- Internal::setDebug Qt::QtDebugChannel::QTDB_ALL if level >=
DebugLevel::Extensive
- end
- def Qt.debug_level
- @@debug_level
- end
+ def Qt.debug_level
+ @@debug_level
+ end
class Base
def **(a)
@@ -99,7 +100,7 @@
# def ==(a)
# return Qt::==(self, a)
# end
- end
+ end # Qt::Base
require ''delegate.rb''
@@ -241,12 +242,11 @@
end
module Internal
-
@@classes = {}
@@cpp_names = {}
@@idclass = []
- def normalize_classname(classname)
+ def Internal.normalize_classname(classname)
if classname =~ /^Q/
now = classname.sub(/^Q(?=[A-Z])/,''Qt::'')
elsif classname !~ /::/
@@ -258,9 +258,9 @@
now
end
- def init_class(c)
- classname = normalize_classname(c)
- classId = idClass(c)
+ def Internal.init_class(c)
+ classname = Qt::Internal::normalize_classname(c)
+ classId = Qt::Internal.idClass(c)
insert_pclassid(classname, classId)
@@idclass[classId] = classname
@@cpp_names[classname] = c
@@ -269,11 +269,11 @@
@@classes[classname] = klass unless klass.nil?
end
- def debug_level
- Qt.debug_level
- end
+ def Internal.debug_level
+ Qt.debug_level
+ end
- def checkarg(argtype, typename)
+ def Internal.checkarg(argtype, typename)
puts " #{typename} (#{argtype})" if debug_level >=
DebugLevel::High
if argtype == ''i''
if typename =~ /^int&?$|^signed$/
@@ -366,14 +366,14 @@
return -99
end
- def find_class(classname)
+ def Internal.find_class(classname)
# puts @@classes.keys.sort.join "\n"
@@classes[classname]
end
# Runs the initializer as far as allocating the Qt C++ instance.
# Then use the @@current_initializer continuation to jump back to here
- def try_initialize(instance, *args)
+ def Internal.try_initialize(instance, *args)
initializer = instance.method(:initialize)
return callcc {
|continuation|
@@ -383,7 +383,7 @@
end
# continues off here after first stage initialize is complete
- def continue_new_instance(instance)
+ def Internal.continue_new_instance(instance)
@@current_initializer.call(instance)
end
@@ -391,7 +391,7 @@
# run that now. Either run the context of the new instance
# if no args were passed to the block. Or otherwise,
# run the block in the context of the arg.
- def run_initializer_block(instance, block)
+ def Internal.run_initializer_block(instance, block)
if block.arity == -1
instance.instance_eval(&block)
elsif block.arity == 1
@@ -401,7 +401,7 @@
end
end
- def do_method_missing(package, method, klass, this, *args)
+ def Internal.do_method_missing(package, method, klass, this, *args)
classname = @@cpp_names[klass.name]
if classname.nil?
if klass != Object and klass != KDE and klass != Qt
@@ -512,16 +512,15 @@
return nil
end
- def init_all_classes()
- getClassList().each {
- |c|
+ def Internal.init_all_classes()
+ Qt::Internal::getClassList().each do |c|
if c == "Qt"
# Don''t change Qt to Qt::t, just leave as is
@@cpp_names["Qt"] = c
elsif c != "QInternal"
- init_class(c)
+ Qt::Internal::init_class(c)
end
- }
+ end
# Special case QByteArray, as it''s disguised as a ruby String
# and not in the public api.
@@classes[''Qt::ByteArray''] = Qt::ByteArray.class
@@ -530,41 +529,132 @@
@@classes[''Qt::Enum''] = Qt::Enum.class
end
- def create_qbytearray(string, data)
+ def Internal.create_qbytearray(string, data)
return Qt::ByteArray.new(string, data)
end
- def get_qbytearray(str)
+ def Internal.get_qbytearray(str)
if str.private_data.nil?
return str.data
end
return str.private_data
end
- def get_qinteger(num)
+ def Internal.get_qinteger(num)
return num.value
end
- def set_qinteger(num, val)
+ def Internal.set_qinteger(num, val)
return num.value = val
end
- def create_qenum(num, type)
+ def Internal.create_qenum(num, type)
return Qt::Enum.new(num, type)
end
- def get_qenum_type(e)
+ def Internal.get_qenum_type(e)
return e.type
end
- def get_qboolean(b)
+ def Internal.get_qboolean(b)
return b.value
end
- def set_qboolean(b, val)
+ def Internal.set_qboolean(b, val)
return b.value = val
end
- end
+
+ def Internal.getAllParents(class_id, res)
+ getIsa(class_id).each do |s|
+ c = idClass(s)
+ res << c
+ getAllParents(c, res)
+ end
+ end
+
+ def Internal.getSignalNames(klass)
+ meta = Meta[klass.name] || MetaInfo.new(klass)
+ signal_names = []
+ meta.get_signals.each do |signal|
+ signal_names.push signal.name
+ end
+ return signal_names
+ end
+
+ def Internal.signalInfo(qobject, signal_name)
+ signals = Meta[qobject.class.name].get_signals
+ signals.each_with_index do |signal, i|
+ if signal.name == signal_name
+ return [signal.full_name, i]
+ end
+ end
+ end
+
+ def Internal.signalAt(qobject, index)
+ classname = qobject.class.name
+ Meta[classname].get_signals[index].full_name
+ end
+
+ def Internal.slotAt(qobject, index)
+ classname = qobject.class.name
+ Meta[classname].get_slots[index].full_name
+ end
+
+ def Internal.getMocArguments(member)
+ argStr = member.sub(/.*\(/, '''').sub(/\)$/,
'''')
+ args = argStr.scan(/([^,]*<[^>]+>)|([^,]+)/)
+ mocargs = allocateMocArguments(args.length)
+ args.each_with_index do |arg, i|
+ arg = arg.to_s
+ a = arg.sub(/^const\s+/, '''')
+ a = (a =~ /^(bool|int|double|char\*|QString)&?$/) ? $1 :
''ptr''
+ valid = setMocType(mocargs, i, arg, a)
+ end
+ result = []
+ result << args.length << mocargs
+ result
+ end
+
+ def Internal.makeMetaData(data)
+ return nil if data.nil?
+ tbl = []
+ data.each do |entry|
+ name = entry.name
+ argStr = entry.arg_types
+ params = []
+ args = argStr.scan(/[^,]+/)
+ args.each do |arg|
+ name = '''' # umm.. is this the aim?, well. it works.
soo... ;-)
+ param = make_QUParameter(name, arg, 0, 1)
+ params << param
+ end
+ method = make_QUMethod(name, params)
+ tbl << make_QMetaData(entry.full_name, method)
+ end
+ make_QMetaData_tbl(tbl)
+ end
+
+ def Internal.getMetaObject(qobject)
+ meta = Meta[qobject.class.name]
+ return nil if meta.nil?
+
+ if meta.metaobject.nil? or meta.changed
+ slots = meta.get_slots
+ slotTable = makeMetaData(slots)
+ signals = meta.get_signals
+ signalTable = makeMetaData(signals)
+ meta.metaobject = make_metaObject(qobject.class.name,
+ qobject.staticMetaObject(),
+ slotTable,
+ slots.length,
+ signalTable,
+ signals.length)
+ meta.changed = false
+ end
+
+ meta.metaobject
+ end
+ end # Qt::Internal
Meta = {}
@@ -636,103 +726,7 @@
end
return all_slots
end
- end
-
- def getAllParents(class_id, res)
- getIsa(class_id).each {
- |s|
- c = idClass(s)
- res << c
- getAllParents(c, res)
- }
- end
-
- def getSignalNames(klass)
- meta = Meta[klass.name] || MetaInfo.new(klass)
- signal_names = []
- meta.get_signals.each do |signal|
- signal_names.push signal.name
- end
- return signal_names
- end
-
- def signalInfo(qobject, signal_name)
- signals = Meta[qobject.class.name].get_signals
- signals.each_with_index {
- |signal, i|
- if signal.name == signal_name
- return [signal.full_name, i]
- end
- }
- end
-
- def signalAt(qobject, index)
- classname = qobject.class.name
- Meta[classname].get_signals[index].full_name
- end
-
- def slotAt(qobject, index)
- classname = qobject.class.name
- Meta[classname].get_slots[index].full_name
- end
-
- def getMocArguments(member)
- argStr = member.sub(/.*\(/, '''').sub(/\)$/,
'''')
- args = argStr.scan(/([^,]*<[^>]+>)|([^,]+)/)
- mocargs = allocateMocArguments(args.length)
- args.each_with_index {
- |arg, i|
- arg = arg.to_s
- a = arg.sub(/^const\s+/, '''')
- a = (a =~ /^(bool|int|double|char\*|QString)&?$/) ? $1 :
''ptr''
- valid = setMocType(mocargs, i, arg, a)
- }
- result = []
- result << args.length << mocargs
- result
- end
-
- def makeMetaData(data)
- return nil if data.nil?
- tbl = []
- data.each {
- |entry|
- name = entry.name
- argStr = entry.arg_types
- params = []
- args = argStr.scan(/[^,]+/)
- args.each {
- |arg|
- name = '''' # umm.. is this the aim?, well. it works.
soo... ;-)
- param = make_QUParameter(name, arg, 0, 1)
- params << param
- }
- method = make_QUMethod(name, params)
- tbl << make_QMetaData(entry.full_name, method)
- }
- make_QMetaData_tbl(tbl)
- end
-
- def getMetaObject(qobject)
- meta = Meta[qobject.class.name]
- return nil if meta.nil?
-
- if meta.metaobject.nil? or meta.changed
- slots = meta.get_slots
- slotTable = makeMetaData(slots)
- signals = meta.get_signals
- signalTable = makeMetaData(signals)
- meta.metaobject = make_metaObject(qobject.class.name,
- qobject.staticMetaObject(),
- slotTable,
- slots.length,
- signalTable,
- signals.length)
- meta.changed = false
- end
-
- meta.metaobject
- end
+ end # Qt::MetaInfo
IO_Direct = 0x0100
IO_Sequential = 0x0200
@@ -760,7 +754,7 @@
IO_TimeOutError = 7
IO_UnspecifiedError= 8
-end
+end # Qt
class Object
# The Object.display() method conflicts with display() methods in Qt,
@@ -774,16 +768,14 @@
end
class Module
- include Qt
-
def signals(*signal_list)
- meta = Meta[self.name] || MetaInfo.new(self)
+ meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
meta.add_signals(signal_list)
meta.changed = true
end
def slots(*slot_list)
- meta = Meta[self.name] || MetaInfo.new(self)
+ meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
meta.add_slots(slot_list)
meta.changed = true
end
Index: rubylib/qtruby/Qt.cpp
==================================================================RCS file:
/home/kde/kdebindings/qtruby/rubylib/qtruby/Qt.cpp,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -p -r1.125 -r1.126
--- kdebindings/qtruby/rubylib/qtruby/Qt.cpp 24 Mar 2005 04:59:58 -0000 1.125
+++ kdebindings/qtruby/rubylib/qtruby/Qt.cpp 30 Mar 2005 13:35:01 -0000 1.126
@@ -2509,49 +2509,48 @@ Init_qtruby()
rb_define_singleton_method(kate_module, "method_missing", (VALUE
(*) (...)) kde_module_method_missing, -1);
rb_define_singleton_method(kate_module, "const_missing", (VALUE
(*) (...)) kde_module_method_missing, -1);
- rb_define_method(qt_internal_module, "getMethStat", (VALUE (*)
(...)) getMethStat, 0);
- rb_define_method(qt_internal_module, "getClassStat", (VALUE (*)
(...)) getClassStat, 0);
- rb_define_method(qt_internal_module, "getIsa", (VALUE (*) (...))
getIsa, 1);
- rb_define_method(qt_internal_module, "allocateMocArguments",
(VALUE (*) (...)) allocateMocArguments, 1);
- rb_define_method(qt_internal_module, "setMocType", (VALUE (*)
(...)) setMocType, 4);
- rb_define_method(qt_internal_module, "setDebug", (VALUE (*)
(...)) setDebug, 1);
- rb_define_method(qt_internal_module, "debug", (VALUE (*) (...))
debugging, 0);
- rb_define_method(qt_internal_module, "getTypeNameOfArg", (VALUE
(*) (...)) getTypeNameOfArg, 2);
- rb_define_method(qt_internal_module, "classIsa", (VALUE (*)
(...)) classIsa, 2);
- rb_define_method(qt_internal_module, "isEnum", (VALUE (*) (...))
isEnum, 1);
- rb_define_method(qt_internal_module, "insert_pclassid", (VALUE
(*) (...)) insert_pclassid, 2);
- rb_define_method(qt_internal_module, "find_pclassid", (VALUE (*)
(...)) find_pclassid, 1);
- rb_define_method(qt_internal_module, "insert_mcid", (VALUE (*)
(...)) insert_mcid, 2);
- rb_define_method(qt_internal_module, "find_mcid", (VALUE (*)
(...)) find_mcid, 1);
- rb_define_method(qt_internal_module, "getVALUEtype", (VALUE (*)
(...)) getVALUEtype, 1);
- rb_define_method(qt_internal_module, "make_QUParameter", (VALUE
(*) (...)) make_QUParameter, 4);
- rb_define_method(qt_internal_module, "make_QMetaData", (VALUE (*)
(...)) make_QMetaData, 2);
- rb_define_method(qt_internal_module, "make_QUMethod", (VALUE (*)
(...)) make_QUMethod, 2);
- rb_define_method(qt_internal_module, "make_QMetaData_tbl", (VALUE
(*) (...)) make_QMetaData_tbl, 1);
- rb_define_method(qt_internal_module, "make_metaObject", (VALUE
(*) (...)) make_metaObject, 6);
- rb_define_method(qt_internal_module, "setAllocated", (VALUE (*)
(...)) setAllocated, 2);
- rb_define_method(qt_internal_module, "mapObject", (VALUE (*)
(...)) mapObject, 1);
+ rb_define_module_function(qt_internal_module, "getMethStat",
(VALUE (*) (...)) getMethStat, 0);
+ rb_define_module_function(qt_internal_module, "getClassStat",
(VALUE (*) (...)) getClassStat, 0);
+ rb_define_module_function(qt_internal_module, "getIsa", (VALUE
(*) (...)) getIsa, 1);
+ rb_define_module_function(qt_internal_module,
"allocateMocArguments", (VALUE (*) (...)) allocateMocArguments, 1);
+ rb_define_module_function(qt_internal_module, "setMocType",
(VALUE (*) (...)) setMocType, 4);
+ rb_define_module_function(qt_internal_module, "setDebug", (VALUE
(*) (...)) setDebug, 1);
+ rb_define_module_function(qt_internal_module, "debug", (VALUE (*)
(...)) debugging, 0);
+ rb_define_module_function(qt_internal_module, "getTypeNameOfArg",
(VALUE (*) (...)) getTypeNameOfArg, 2);
+ rb_define_module_function(qt_internal_module, "classIsa", (VALUE
(*) (...)) classIsa, 2);
+ rb_define_module_function(qt_internal_module, "isEnum", (VALUE
(*) (...)) isEnum, 1);
+ rb_define_module_function(qt_internal_module, "insert_pclassid",
(VALUE (*) (...)) insert_pclassid, 2);
+ rb_define_module_function(qt_internal_module, "find_pclassid",
(VALUE (*) (...)) find_pclassid, 1);
+ rb_define_module_function(qt_internal_module, "insert_mcid",
(VALUE (*) (...)) insert_mcid, 2);
+ rb_define_module_function(qt_internal_module, "find_mcid", (VALUE
(*) (...)) find_mcid, 1);
+ rb_define_module_function(qt_internal_module, "getVALUEtype",
(VALUE (*) (...)) getVALUEtype, 1);
+ rb_define_module_function(qt_internal_module, "make_QUParameter",
(VALUE (*) (...)) make_QUParameter, 4);
+ rb_define_module_function(qt_internal_module, "make_QMetaData",
(VALUE (*) (...)) make_QMetaData, 2);
+ rb_define_module_function(qt_internal_module, "make_QUMethod",
(VALUE (*) (...)) make_QUMethod, 2);
+ rb_define_module_function(qt_internal_module,
"make_QMetaData_tbl", (VALUE (*) (...)) make_QMetaData_tbl, 1);
+ rb_define_module_function(qt_internal_module, "make_metaObject",
(VALUE (*) (...)) make_metaObject, 6);
+ rb_define_module_function(qt_internal_module, "setAllocated",
(VALUE (*) (...)) setAllocated, 2);
+ rb_define_module_function(qt_internal_module, "mapObject", (VALUE
(*) (...)) mapObject, 1);
// isQOjbect => isaQObject
- rb_define_method(qt_internal_module, "isQObject", (VALUE (*)
(...)) isaQObject, 1);
- rb_define_method(qt_internal_module, "isValidAllocatedPointer",
(VALUE (*) (...)) isValidAllocatedPointer, 1);
- rb_define_method(qt_internal_module, "findAllocatedObjectFor",
(VALUE (*) (...)) findAllocatedObjectFor, 1);
- rb_define_method(qt_internal_module, "idClass", (VALUE (*) (...))
idClass, 1);
- rb_define_method(qt_internal_module, "idMethodName", (VALUE (*)
(...)) idMethodName, 1);
- rb_define_method(qt_internal_module, "idMethod", (VALUE (*)
(...)) idMethod, 2);
- rb_define_method(qt_internal_module, "findMethod", (VALUE (*)
(...)) findMethod, 2);
- rb_define_method(qt_internal_module, "findAllMethods", (VALUE (*)
(...)) findAllMethods, -1);
- rb_define_method(qt_internal_module, "dumpCandidates", (VALUE (*)
(...)) dumpCandidates, 1);
- rb_define_method(qt_internal_module, "isObject", (VALUE (*)
(...)) isObject, 1);
- rb_define_method(qt_internal_module, "setCurrentMethod", (VALUE
(*) (...)) setCurrentMethod, 1);
- rb_define_method(qt_internal_module, "getClassList", (VALUE (*)
(...)) getClassList, 0);
- rb_define_method(qt_internal_module, "create_qt_class", (VALUE
(*) (...)) create_qt_class, 1);
- rb_define_method(qt_internal_module, "create_qobject_class",
(VALUE (*) (...)) create_qobject_class, 1);
- rb_define_method(qt_internal_module, "version", (VALUE (*) (...))
version, 0);
- rb_define_method(qt_internal_module, "qtruby_version", (VALUE (*)
(...)) qtruby_version, 0);
- rb_define_method(qt_internal_module, "cast_object_to", (VALUE (*)
(...)) cast_object_to, 2);
- rb_define_method(qt_internal_module, "application_terminated=",
(VALUE (*) (...)) set_application_terminated, 1);
+ rb_define_module_function(qt_internal_module, "isQObject", (VALUE
(*) (...)) isaQObject, 1);
+ rb_define_module_function(qt_internal_module,
"isValidAllocatedPointer", (VALUE (*) (...)) isValidAllocatedPointer,
1);
+ rb_define_module_function(qt_internal_module,
"findAllocatedObjectFor", (VALUE (*) (...)) findAllocatedObjectFor,
1);
+ rb_define_module_function(qt_internal_module, "idClass", (VALUE
(*) (...)) idClass, 1);
+ rb_define_module_function(qt_internal_module, "idMethodName",
(VALUE (*) (...)) idMethodName, 1);
+ rb_define_module_function(qt_internal_module, "idMethod", (VALUE
(*) (...)) idMethod, 2);
+ rb_define_module_function(qt_internal_module, "findMethod",
(VALUE (*) (...)) findMethod, 2);
+ rb_define_module_function(qt_internal_module, "findAllMethods",
(VALUE (*) (...)) findAllMethods, -1);
+ rb_define_module_function(qt_internal_module, "dumpCandidates",
(VALUE (*) (...)) dumpCandidates, 1);
+ rb_define_module_function(qt_internal_module, "isObject", (VALUE
(*) (...)) isObject, 1);
+ rb_define_module_function(qt_internal_module, "setCurrentMethod",
(VALUE (*) (...)) setCurrentMethod, 1);
+ rb_define_module_function(qt_internal_module, "getClassList",
(VALUE (*) (...)) getClassList, 0);
+ rb_define_module_function(qt_internal_module, "create_qt_class",
(VALUE (*) (...)) create_qt_class, 1);
+ rb_define_module_function(qt_internal_module,
"create_qobject_class", (VALUE (*) (...)) create_qobject_class, 1);
+ rb_define_module_function(qt_internal_module, "version", (VALUE
(*) (...)) version, 0);
+ rb_define_module_function(qt_internal_module, "qtruby_version",
(VALUE (*) (...)) qtruby_version, 0);
+ rb_define_module_function(qt_internal_module, "cast_object_to",
(VALUE (*) (...)) cast_object_to, 2);
+ rb_define_module_function(qt_internal_module,
"application_terminated=", (VALUE (*) (...))
set_application_terminated, 1);
- rb_include_module(qt_module, qt_internal_module);
rb_require("Qt/qtruby.rb");
// Do package initialization
--bp/iNruPH9dso1Pn--
Richard Dale
2005-Apr-10 09:29 UTC
[Pkg-kde-talk] Re: [Kde-bindings] qtruby.rb: backporting the ''Module includes Qt'' bug to 3.3
--Boundary-00=_PIPWCSrRkjLwTCd Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Disposition: inline On Saturday 09 April 2005 21:50, Adeodato Simó wrote:> Hello Richard, > > I''m one of the KDE packagers in Debian. Our next release, Sarge, will > be shipping with KDE 3.3, and a user has requested [1] that we > backport the "include ''Qt'' in Module pollutes its namespace" fix from > KDE_3_4_BRANCH. > > [1] http://bugs.debian.org/303608 > > I''ve digged into it today and backported the CVS commit. I''ve tested > the resulting package and seems to work, but I''d really appreciate if > you could have a quick look at the patch we''ll be applying (attached). > > I''m asking this because, although the patch came from CVS, I''ve needed > to do a bit of tweaking to it, and I fear having left something out, > or having included something that will have some nasty effects that my > testing hasn''t discovered. > > The changes are explained at the top of the diff, the involved CVS > revisions are listed in it too.I''ve had a look at the changes, and they look ok. I did reformat some code at the same time as making the fix which makes it a bit less backporting friendly - sorry about that. I fixed a couple of small regressions yesterday, Qt::version and Qt::ruby_version shouldn''t have been moved to the Qt::Internal module, so these lines should be removed from the patch: - rb_define_method(qt_internal_module, "version", (VALUE (*) (...)) version, 0); - rb_define_method(qt_internal_module, "qtruby_version", (VALUE (*) (...)) qtruby_version, 0); + rb_define_module_function(qt_internal_module, "version", (VALUE (*) (...)) version, 0); + rb_define_module_function(qt_internal_module, "qtruby_version", (VALUE (*) (...)) The rbqtapi script in qtruby/bin also need changing to work with the methods moved to the Internal module. I''ve attached the current version. Also a similar change was needed for korunudum.rb, otherwise ruby dcop won''t work, I''ve attached a patch of that change. So please make sure that the examples in korundum/rubylib/examples/dcop still work ok after the fix. Regards -- Richard --Boundary-00=_PIPWCSrRkjLwTCd Content-Type: text/x-diff; charset="utf-8"; name="korunundum-namespace.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="korunundum-namespace.patch" Index: rubylib/korundum/lib/KDE/korundum.rb ==================================================================RCS file: /home/kde/kdebindings/korundum/rubylib/korundum/lib/KDE/korundum.rb,v retrieving revision 1.45 retrieving revision 1.45.2.1 diff -U3 -r1.45 -r1.45.2.1 --- rubylib/korundum/lib/KDE/korundum.rb 29 Dec 2004 13:49:06 -0000 1.45 +++ rubylib/korundum/lib/KDE/korundum.rb 31 Mar 2005 08:39:28 -0000 1.45.2.1 @@ -18,8 +18,6 @@ =end module KDE - include Qt - DCOPMeta = {} # An entry for each dcop signal or slot @@ -68,27 +66,27 @@ end end end - end + end # DCOPMetaInfo - def hasDCOPSignals(aClass) + def KDE.hasDCOPSignals(aClass) classname = aClass.name if aClass.is_a? Module meta = DCOPMeta[classname] return !meta.nil? && meta.k_dcop_signals.length > 0 end - def hasDCOPSlots(aClass) + def KDE.hasDCOPSlots(aClass) classname = aClass.name if aClass.is_a? Module meta = DCOPMeta[classname] return !meta.nil? && meta.k_dcop.length > 0 end - def getDCOPSignalNames(aClass) + def KDE.getDCOPSignalNames(aClass) classname = aClass.name if aClass.is_a? Module signals = DCOPMeta[classname].k_dcop_signals return signals.keys end - def fullSignalName(instance, signalName) + def KDE.fullSignalName(instance, signalName) classname = instance.class.name if instance.class.is_a? Module signals = DCOPMeta[classname].k_dcop_signals return signals[signalName].full_name @@ -114,10 +112,10 @@ replyType << dcop_slot.reply_type KDE::dcop_process( @client, dcop_slot.name, - Qt::getMocArguments(fun), + Qt::Internal::getMocArguments(fun), data, replyType, - (replyType == ''void'' or replyType == ''ASYNC'') ? nil : Qt::getMocArguments(replyType), + (replyType == ''void'' or replyType == ''ASYNC'') ? nil : Qt::Internal::getMocArguments(replyType), replyData ) end @@ -158,7 +156,7 @@ # If a class contains a k_dcop slots list declaration, then create a DCOPObject # associated with it - def createDCOPObject(instance) + def KDE.createDCOPObject(instance) meta = DCOPMeta[instance.class.name] return nil if meta.nil? @@ -309,7 +307,7 @@ end return KDE::dcop_call( self, full_name, - Qt::getMocArguments(full_name), + Qt::Internal::getMocArguments(full_name), *k ) end @@ -332,7 +330,7 @@ end return KDE::dcop_send( self, fun, - Qt::getMocArguments(sig), + Qt::Internal::getMocArguments(sig), *k ) end @@ -511,16 +509,14 @@ end class Module - include KDE - def k_dcop_signals(*signal_list) - meta = DCOPMeta[self.name] || DCOPMetaInfo.new(self) + meta = KDE::DCOPMeta[self.name] || KDE::DCOPMetaInfo.new(self) meta.add_signals(signal_list) meta.changed = true end def k_dcop(*slot_list) - meta = DCOPMeta[self.name] || DCOPMetaInfo.new(self) + meta = KDE::DCOPMeta[self.name] || KDE::DCOPMetaInfo.new(self) meta.add_slots(slot_list) meta.changed = true end --Boundary-00=_PIPWCSrRkjLwTCd Content-Type: application/x-ruby; name="rbqtapi" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rbqtapi" #!/usr/bin/env ruby # Note: this program is part of qtruby and makes use of its internal functions. # You should not rely on those in your own programs. require ''getopts'' getopts(''r:hvimp'') case File.basename $0 when "rbqtapi" require ''Qt'' when "rbkdeapi" require ''Korundum'' end if $OPT_v # TODO add and use version number #{Qt::VERSION} print "qtruby using Qt-#{Qt::version}\n" exit 0 elsif $OPT_h print $usage exit 0 end if $OPT_m while 1 line = STDIN.readline.chomp line.gsub!(/^Q(?=[A-Z])/,''Qt::'') line.gsub!(/^K/,''KDE::'') unless line =~ /^(KDE)|(KIO)|(KParts)/ classid = Qt::Internal::find_pclassid($_) puts "__START__" if classid a = Qt::Internal::findAllMethods(classid) ids = (a.keys.sort.map{|k|a[k]}).flatten candidates = Qt::dumpCandidates(ids) sup = [] Qt::Internal::getAllParents(classid, sup) sup.each { |sup_item| a = Qt::Internal::findAllMethods(sup_item) ids = (a.keys.sort.map{|k|a[k]}).flatten candidates << Qt::Internal::dumpCandidates(ids) } candidates.gsub("\t","") # erm. whats the "s" mean on s/\t//gs ? print candidates end puts "__END__" end end search_string = ARGV[0] ? ARGV[0].dup : nil search_string.gsub!(/^Q(?=[A-Z])/,''Qt::'') if search_string # search_string.gsub!(/^K(?=[^D][^E])/,''KDE::'') if search_string search_string.gsub!(/^K/,''KDE::'') unless search_string.nil? or search_string =~ /^(KDE)|(KIO)|(KParts)/ classid = search_string ? Qt::Internal::find_pclassid(search_string) : 1 if classid == 0 puts "Class #{search_string} not found" exit 1 end regexp = nil regexp = ( $OPT_i ? Regexp.new($OPT_r, Regexp::IGNORECASE) : Regexp.new($OPT_r) ) if $OPT_r candidates = "" while true a = Qt::Internal::findAllMethods(classid) break if a.nil? ids = (a.keys.sort.map{|k|a[k]}).flatten candidates = Qt::Internal::dumpCandidates(ids) if $OPT_p and !search_string.empty? and classid sup = [] Qt::Internal::getAllParents(classid, sup) sup.each { |sup_item| a = Qt::Internal::findAllMethods(sup_item) ids = (a.keys.sort.map{|k|a[k]}).flatten candidates << Qt::Internal::dumpCandidates(ids) } end if regexp candidates.split("\n").each { |candidate| puts candidate if candidate =~ regexp } else print candidates end break unless search_string.nil? classid += 1 end BEGIN { $usage = <<USAGE rbqtapi - a qtruby introspection tool\t(c) Germain Garand 2003 <germain\@ebooksfrance.org> usage: rbqtapi [-r <re>] [<class>] options: \t-r <re> : find all functions matching regular expression/keyword <re> \t-i : together with -r, performs a case insensitive search \t-p : display also inherited methods for <class>. \t-v : print qtruby and Qt versions \t-h : print this help message USAGE } --Boundary-00=_PIPWCSrRkjLwTCd--