summaryrefslogtreecommitdiffstats
path: root/scripts/alldcop.rb
blob: b15a1fdd1fd1bd38310bdae90ab7eed5e76fd334 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env ruby

module DCOP

  def dump_all_apps

    `dcop`.split(/\n/).each do

      |app|

      DCOP.dump_app(app)

    end

  end

  def dump_app(app)

    print "<app name=\"#{app}\">\n"

    `dcop #{app}`.split(/\n/).each do

      |object|

      DCOP.dump_object(app, object)

    end

    print "</app>\n"

  end

  def dump_object(app, object)

    object.gsub!(/\(default\)/, '')
    object.strip!

    print "  <object name=\"#{object}\">\n" unless object == "(default)"

    `dcop #{app} #{object}`.split(/\n/).each do

      |method|

      DCOP.dump_method(app, object, method)

    end

    print "  </object>\n"

  end

  def dump_method(app, object, method)

    return_type, method_name, arg_str = method.split(/[ \(]/, 3)

    arg_str.gsub!(/\)$/, '')

    arg_list = arg_str.split(',')

    print "    <method name=\"#{method_name}\" return-type=\"#{return_type}\""

    if arg_list.empty?

      print "/>\n"
      return

    else

      print ">\n"

      arg_list.each do

        |arg|

        type, name = arg.split

        print "      <parameter name=\"#{name}\" type=\"#{type}\"/>\n"

      end

      print "    </method>\n"

    end

  end

  module_function :dump_all_apps, :dump_app, :dump_object, :dump_method

end

DCOP.dump_all_apps if __FILE__ == $0