bitclust-core 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. data/ChangeLog +2907 -0
  2. data/Gemfile +7 -0
  3. data/README +21 -0
  4. data/Rakefile +20 -0
  5. data/bin/bitclust +14 -0
  6. data/bin/refe +36 -0
  7. data/bitclust-dev.gemspec +33 -0
  8. data/bitclust.gemspec +30 -0
  9. data/config.in +23 -0
  10. data/config.ru +48 -0
  11. data/config.ru.sample +31 -0
  12. data/data/bitclust/catalog/ja_JP.EUC-JP +78 -0
  13. data/data/bitclust/catalog/ja_JP.UTF-8 +78 -0
  14. data/data/bitclust/template.lillia/class +98 -0
  15. data/data/bitclust/template.lillia/class-index +28 -0
  16. data/data/bitclust/template.lillia/doc +48 -0
  17. data/data/bitclust/template.lillia/layout +19 -0
  18. data/data/bitclust/template.lillia/library +129 -0
  19. data/data/bitclust/template.lillia/library-index +32 -0
  20. data/data/bitclust/template.lillia/method +20 -0
  21. data/data/bitclust/template.lillia/rd_file +6 -0
  22. data/data/bitclust/template.offline/class +67 -0
  23. data/data/bitclust/template.offline/class-index +28 -0
  24. data/data/bitclust/template.offline/doc +13 -0
  25. data/data/bitclust/template.offline/function +22 -0
  26. data/data/bitclust/template.offline/function-index +24 -0
  27. data/data/bitclust/template.offline/layout +18 -0
  28. data/data/bitclust/template.offline/library +87 -0
  29. data/data/bitclust/template.offline/library-index +32 -0
  30. data/data/bitclust/template.offline/method +21 -0
  31. data/data/bitclust/template.offline/rd_file +6 -0
  32. data/data/bitclust/template/class +133 -0
  33. data/data/bitclust/template/class-index +30 -0
  34. data/data/bitclust/template/doc +14 -0
  35. data/data/bitclust/template/function +21 -0
  36. data/data/bitclust/template/function-index +25 -0
  37. data/data/bitclust/template/layout +19 -0
  38. data/data/bitclust/template/library +89 -0
  39. data/data/bitclust/template/library-index +35 -0
  40. data/data/bitclust/template/method +24 -0
  41. data/data/bitclust/template/opensearchdescription +10 -0
  42. data/data/bitclust/template/search +57 -0
  43. data/lib/bitclust.rb +9 -0
  44. data/lib/bitclust/app.rb +129 -0
  45. data/lib/bitclust/classentry.rb +425 -0
  46. data/lib/bitclust/compat.rb +39 -0
  47. data/lib/bitclust/completion.rb +531 -0
  48. data/lib/bitclust/crossrubyutils.rb +91 -0
  49. data/lib/bitclust/database.rb +181 -0
  50. data/lib/bitclust/docentry.rb +83 -0
  51. data/lib/bitclust/entry.rb +223 -0
  52. data/lib/bitclust/exception.rb +38 -0
  53. data/lib/bitclust/functiondatabase.rb +115 -0
  54. data/lib/bitclust/functionentry.rb +81 -0
  55. data/lib/bitclust/functionreferenceparser.rb +76 -0
  56. data/lib/bitclust/htmlutils.rb +80 -0
  57. data/lib/bitclust/interface.rb +87 -0
  58. data/lib/bitclust/libraryentry.rb +211 -0
  59. data/lib/bitclust/lineinput.rb +165 -0
  60. data/lib/bitclust/messagecatalog.rb +95 -0
  61. data/lib/bitclust/methoddatabase.rb +401 -0
  62. data/lib/bitclust/methodentry.rb +202 -0
  63. data/lib/bitclust/methodid.rb +209 -0
  64. data/lib/bitclust/methodsignature.rb +82 -0
  65. data/lib/bitclust/nameutils.rb +236 -0
  66. data/lib/bitclust/parseutils.rb +60 -0
  67. data/lib/bitclust/preprocessor.rb +273 -0
  68. data/lib/bitclust/rdcompiler.rb +507 -0
  69. data/lib/bitclust/refsdatabase.rb +66 -0
  70. data/lib/bitclust/requesthandler.rb +330 -0
  71. data/lib/bitclust/ridatabase.rb +349 -0
  72. data/lib/bitclust/rrdparser.rb +522 -0
  73. data/lib/bitclust/runner.rb +143 -0
  74. data/lib/bitclust/screen.rb +554 -0
  75. data/lib/bitclust/searcher.rb +518 -0
  76. data/lib/bitclust/server.rb +59 -0
  77. data/lib/bitclust/simplesearcher.rb +84 -0
  78. data/lib/bitclust/subcommand.rb +746 -0
  79. data/lib/bitclust/textutils.rb +51 -0
  80. data/lib/bitclust/version.rb +3 -0
  81. data/packer.rb +224 -0
  82. data/refe2.gemspec +29 -0
  83. data/server.exe +0 -0
  84. data/server.exy +159 -0
  85. data/server.rb +10 -0
  86. data/setup.rb +1596 -0
  87. data/standalone.rb +193 -0
  88. data/test/run_test.rb +15 -0
  89. data/test/test_bitclust.rb +81 -0
  90. data/test/test_entry.rb +39 -0
  91. data/test/test_functiondatabase.rb +55 -0
  92. data/test/test_libraryentry.rb +31 -0
  93. data/test/test_methoddatabase.rb +81 -0
  94. data/test/test_methodsignature.rb +14 -0
  95. data/test/test_nameutils.rb +324 -0
  96. data/test/test_preprocessor.rb +84 -0
  97. data/test/test_rdcompiler.rb +534 -0
  98. data/test/test_refsdatabase.rb +76 -0
  99. data/test/test_rrdparser.rb +26 -0
  100. data/test/test_runner.rb +102 -0
  101. data/test/test_simplesearcher.rb +48 -0
  102. data/theme/default/images/external.png +0 -0
  103. data/theme/default/rurema.png +0 -0
  104. data/theme/default/style.css +288 -0
  105. data/theme/default/test.css +254 -0
  106. data/theme/lillia/rurema.png +0 -0
  107. data/theme/lillia/style.css +331 -0
  108. data/theme/lillia/test.css +254 -0
  109. data/tools/bc-ancestors.rb +153 -0
  110. data/tools/bc-checkparams.rb +246 -0
  111. data/tools/bc-classes.rb +80 -0
  112. data/tools/bc-convert.rb +165 -0
  113. data/tools/bc-list.rb +63 -0
  114. data/tools/bc-methods.rb +171 -0
  115. data/tools/bc-preproc.rb +42 -0
  116. data/tools/bc-rdoc.rb +343 -0
  117. data/tools/bc-tochm.rb +301 -0
  118. data/tools/bc-tohtml.rb +125 -0
  119. data/tools/bc-tohtmlpackage.rb +241 -0
  120. data/tools/check-signature.rb +19 -0
  121. data/tools/forall-ruby.rb +20 -0
  122. data/tools/gencatalog.rb +69 -0
  123. data/tools/statrefm.rb +98 -0
  124. data/tools/stattodo.rb +150 -0
  125. data/tools/update-database.rb +146 -0
  126. data/view.cgi +6 -0
  127. metadata +222 -0
@@ -0,0 +1,211 @@
1
+ #
2
+ # bitclust/libraryentry.rb
3
+ #
4
+ # Copyright (c) 2006-2008 Minero Aoki
5
+ #
6
+ # This program is free software.
7
+ # You can distribute/modify this program under the Ruby License.
8
+ #
9
+
10
+ require 'bitclust/entry'
11
+ require 'bitclust/exception'
12
+
13
+ module BitClust
14
+
15
+ class LibraryEntry < Entry
16
+
17
+ include Enumerable
18
+
19
+ def LibraryEntry.type_id
20
+ :library
21
+ end
22
+
23
+ def initialize(db, id)
24
+ super db
25
+ @id = id
26
+ if saved?
27
+ @classmap = nil
28
+ @methodmap = nil
29
+ @link_checked = true
30
+ else
31
+ @classmap = {}
32
+ @methodmap = {}
33
+ @link_checked = false
34
+ end
35
+ init_properties
36
+ end
37
+
38
+ attr_reader :id
39
+
40
+ def ==(other)
41
+ @id == other.id
42
+ end
43
+
44
+ alias eql? ==
45
+
46
+ def hash
47
+ @id.hash
48
+ end
49
+
50
+ def <=>(other)
51
+ @id.casecmp(other.id)
52
+ end
53
+
54
+ def name
55
+ libid2name(@id)
56
+ end
57
+ alias label name
58
+
59
+ def labels
60
+ [label()]
61
+ end
62
+
63
+ def name?(n)
64
+ name() == n
65
+ end
66
+
67
+ persistent_properties {
68
+ property :requires, '[LibraryEntry]'
69
+ property :classes, '[ClassEntry]' # :defined classes
70
+ property :methods, '[MethodEntry]' # :added/:redefined entries
71
+ property :source, 'String'
72
+ property :sublibraries, '[LibraryEntry]'
73
+ property :is_sublibrary, 'bool'
74
+ }
75
+
76
+ def inspect
77
+ "#<library #{@id}>"
78
+ end
79
+
80
+ def check_link(path = [])
81
+ return if @link_checked
82
+ if path.include?(name())
83
+ raise InvalidLink, "looped require: #{path_string(path)}"
84
+ end
85
+ path.push name()
86
+ requires().each do |lib|
87
+ lib.check_link path
88
+ end
89
+ path.pop
90
+ @link_checked = true
91
+ end
92
+
93
+ def all_requires(libs = {})
94
+ requires.each{|l|
95
+ next if libs[l.name]
96
+ libs[l.name] = l
97
+ l.all_requires(libs)
98
+ }
99
+ libs.values
100
+ end
101
+
102
+ def all_classes
103
+ return @all_classes if @all_classes
104
+ required_classes = (sublibraries & requires).map{|l| l.classes }.flatten
105
+ @all_classes = (classes() + required_classes).uniq.sort
106
+ end
107
+
108
+ def error_classes
109
+ @error_classes ||= classes.select{|c| c.ancestors.any?{|k| k.name == 'Exception' }}
110
+ end
111
+
112
+ def all_error_classes
113
+ @all_error_classes ||= all_classes.select{|c| c.ancestors.any?{|k| k.name == 'Exception' }}
114
+ end
115
+
116
+ def require(lib)
117
+ requires().push lib
118
+ end
119
+
120
+ def sublibrary(lib)
121
+ unless sublibraries().include?(lib)
122
+ sublibraries().push lib
123
+ lib.is_sublibrary = true
124
+ end
125
+ end
126
+
127
+ def fetch_class(name)
128
+ get_class(name) or
129
+ raise ClassNotFound, "no such class in the library #{name()}: #{name}"
130
+ end
131
+
132
+ def get_class(name)
133
+ classes().detect {|c| c.name == name }
134
+ end
135
+
136
+ def classnames
137
+ classes().map {|c| c.name }
138
+ end
139
+
140
+ def each_class(&block)
141
+ classes().each(&block)
142
+ end
143
+
144
+ def classmap
145
+ @classmap ||=
146
+ begin
147
+ h = {}
148
+ classes().each do |c|
149
+ h[c.name] = c
150
+ end
151
+ h
152
+ end
153
+ end
154
+ private :classmap
155
+
156
+ def fetch_methods(spec)
157
+ ms = if c = get_class(spec.klass)
158
+ then c.fetch_methods(spec)
159
+ else []
160
+ end +
161
+ methods().select {|m| spec.match?(m) }
162
+ if ms.empty?
163
+ raise MethodNotFound, "no such method in the library #{name()}: #{name}"
164
+ end
165
+ ms
166
+ end
167
+
168
+ def fetch_method(spec)
169
+ classes().each do |c|
170
+ m = c.get_method(spec)
171
+ return m if m
172
+ end
173
+ methods().detect {|m| spec.match?(m) } or
174
+ raise MethodNotFound, "no such method in the library #{name()}: #{name}"
175
+ end
176
+
177
+ def each_method(&block)
178
+ methods().each(&block)
179
+ end
180
+
181
+ def methodmap
182
+ @methodmap ||=
183
+ begin
184
+ h = {}
185
+ methods().each do |m|
186
+ h[m] = m
187
+ end
188
+ h
189
+ end
190
+ end
191
+ private :methodmap
192
+
193
+ def add_class(c)
194
+ unless classmap()[c.name]
195
+ classes().push c
196
+ classmap()[c.name] = c
197
+ @db.dirty_library self
198
+ end
199
+ end
200
+
201
+ def add_method(m)
202
+ unless methodmap()[m]
203
+ methods().push m
204
+ methodmap()[m] = m
205
+ @db.dirty_library self
206
+ end
207
+ end
208
+
209
+ end
210
+
211
+ end
@@ -0,0 +1,165 @@
1
+ #
2
+ # $Id: lineinput.rb 3723 2007-03-28 21:34:13Z aamine $
3
+ #
4
+ # Copyright (c) 2002-2007 Minero Aoki
5
+ #
6
+ # This program is free software.
7
+ # You can distribute/modify this program under the terms of
8
+ # the GNU LGPL, Lesser General Public License version 2.1.
9
+ #
10
+
11
+ require 'stringio'
12
+
13
+ class LineInput
14
+
15
+ def LineInput.for_string(s)
16
+ new(StringIO.new(s))
17
+ end
18
+
19
+ def initialize(f)
20
+ @input = f
21
+ @buf = []
22
+ @lineno = 0
23
+ @eof_p = false
24
+ end
25
+
26
+ def inspect
27
+ "\#<#{self.class} file=#{@input.inspect} line=#{lineno()}>"
28
+ end
29
+
30
+ def eof?
31
+ @eof_p
32
+ end
33
+
34
+ def path
35
+ @input.path
36
+ end
37
+
38
+ def lineno
39
+ @lineno
40
+ end
41
+
42
+ def gets
43
+ unless @buf.empty?
44
+ @lineno += 1
45
+ return @buf.pop
46
+ end
47
+ return nil if @eof_p # to avoid ARGF blocking.
48
+ line = @input.gets
49
+ @eof_p = true unless line
50
+ @lineno += 1
51
+ line
52
+ end
53
+
54
+ def ungets(line)
55
+ return unless line
56
+ @lineno -= 1
57
+ @buf.push line
58
+ line
59
+ end
60
+
61
+ def peek
62
+ line = gets()
63
+ ungets line if line
64
+ line
65
+ end
66
+
67
+ def next?
68
+ peek() ? true : false
69
+ end
70
+
71
+ def skip_blank_lines
72
+ n = 0
73
+ while line = gets()
74
+ unless line.strip.empty?
75
+ ungets line
76
+ return n
77
+ end
78
+ n += 1
79
+ end
80
+ n
81
+ end
82
+
83
+ def gets_if(re)
84
+ line = gets()
85
+ if not line or not (re =~ line)
86
+ ungets line
87
+ return nil
88
+ end
89
+ line
90
+ end
91
+
92
+ def gets_unless(re)
93
+ line = gets()
94
+ if not line or re =~ line
95
+ ungets line
96
+ return nil
97
+ end
98
+ line
99
+ end
100
+
101
+ def each
102
+ while line = gets()
103
+ yield line
104
+ end
105
+ end
106
+
107
+ def while_match(re)
108
+ while line = gets()
109
+ unless re =~ line
110
+ ungets line
111
+ return
112
+ end
113
+ yield line
114
+ end
115
+ nil
116
+ end
117
+
118
+ def getlines_while(re)
119
+ buf = []
120
+ while_match(re) do |line|
121
+ buf.push line
122
+ end
123
+ buf
124
+ end
125
+
126
+ alias span getlines_while # from Haskell
127
+
128
+ def until_match(re)
129
+ while line = gets()
130
+ if re =~ line
131
+ ungets line
132
+ return
133
+ end
134
+ yield line
135
+ end
136
+ nil
137
+ end
138
+
139
+ def getlines_until(re)
140
+ buf = []
141
+ until_match(re) do |line|
142
+ buf.push line
143
+ end
144
+ buf
145
+ end
146
+
147
+ alias break getlines_until # from Haskell
148
+
149
+ def until_terminator(re)
150
+ while line = gets()
151
+ return if re =~ line # discard terminal line
152
+ yield line
153
+ end
154
+ nil
155
+ end
156
+
157
+ def getblock(term_re)
158
+ buf = []
159
+ until_terminator(term_re) do |line|
160
+ buf.push line
161
+ end
162
+ buf
163
+ end
164
+
165
+ end
@@ -0,0 +1,95 @@
1
+ #
2
+ # bitclust/messagecatalog.rb
3
+ #
4
+ # Copyright (c) 2006-2008 Minero Aoki
5
+ #
6
+ # This program is free software.
7
+ # You can distribute/modify this program under the Ruby License.
8
+ #
9
+
10
+ module BitClust
11
+
12
+ module Translatable
13
+
14
+ private
15
+
16
+ def init_message_catalog(catalog)
17
+ @__message_catalog = catalog
18
+ end
19
+
20
+ def message_catalog
21
+ @__message_catalog
22
+ end
23
+
24
+ def _(key, *args)
25
+ @__message_catalog.translate(key, *args)
26
+ end
27
+
28
+ end
29
+
30
+ # FIXME: support automatic encoding-conversion
31
+ class MessageCatalog
32
+
33
+ ENCODING_MAP = {
34
+ 'utf-8' => 'UTF-8',
35
+ 'euc-jp' => 'EUC-JP',
36
+ 'shift_jis' => 'Shift_JIS'
37
+ }
38
+
39
+ # FIXME: support non ja_JP locales
40
+ def MessageCatalog.encoding2locale(enc)
41
+ newenc = ENCODING_MAP[enc.downcase]
42
+ newenc ? "ja_JP.#{newenc}" : "C"
43
+ end
44
+
45
+ def MessageCatalog.load(prefix)
46
+ load_with_locales(prefix, env_locales())
47
+ end
48
+
49
+ def MessageCatalog.load_with_locales(prefix, locales)
50
+ path, loc = find_catalog(prefix, locales)
51
+ path ? load_file(path, loc) : new({}, 'C')
52
+ end
53
+
54
+ def MessageCatalog.env_locales
55
+ [ENV['LC_MESSAGES'], ENV['LC_ALL'], ENV['LANG'], 'C']\
56
+ .compact.uniq.reject {|loc| loc.empty? }
57
+ end
58
+ private_class_method :env_locales
59
+
60
+ def MessageCatalog.find_catalog(prefix, locales)
61
+ locales.each do |locale|
62
+ path = "#{prefix}/#{locale}"
63
+ return path, locale if File.file?(path)
64
+ end
65
+ nil
66
+ end
67
+ private_class_method :find_catalog
68
+
69
+ def MessageCatalog.load_file(path, locale)
70
+ h = {}
71
+ fopen(path, 'r:UTF-8') {|f|
72
+ f.each do |key|
73
+ h[key.chomp] = f.gets.chomp
74
+ end
75
+ }
76
+ new(h, locale)
77
+ end
78
+
79
+ def initialize(msgs, locale)
80
+ @msgs = msgs
81
+ @locale = locale
82
+ end
83
+
84
+ def inspect
85
+ "\#<#{self.class} #{@locale}>"
86
+ end
87
+
88
+ def translate(key, *args)
89
+ str = @msgs[key] || key
90
+ sprintf(str, *args)
91
+ end
92
+
93
+ end
94
+
95
+ end