summaryrefslogtreecommitdiffstats
path: root/qtruby/bin/rbqtapi
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /qtruby/bin/rbqtapi
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtruby/bin/rbqtapi')
-rwxr-xr-xqtruby/bin/rbqtapi103
1 files changed, 103 insertions, 0 deletions
diff --git a/qtruby/bin/rbqtapi b/qtruby/bin/rbqtapi
new file mode 100755
index 00000000..30735b48
--- /dev/null
+++ b/qtruby/bin/rbqtapi
@@ -0,0 +1,103 @@
+#!/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)|(KNS)/
+ 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)|(KNS)/
+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
+}