bitclust-core 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,38 @@
1
+ #
2
+ # bitclust/exception.rb
3
+ #
4
+ # Copyright (c) 2006-2007 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
+ class Error < StandardError; end
12
+ class RequestError < Error; end
13
+ class NotInTransaction < Error; end
14
+ class DocumentError < Error; end
15
+ class ScanError < DocumentError; end
16
+ class ParseError < DocumentError; end
17
+ class WrongInclude < DocumentError; end
18
+ class InvalidLink < DocumentError; end
19
+ class InvalidAncestor < DocumentError; end
20
+ class UserError < Error; end
21
+ class InvalidDatabase < UserError; end
22
+ class InvalidKey < UserError; end
23
+ class InvalidScheme < UserError; end
24
+ class NotFoundError < UserError; end
25
+ class LibraryNotFound < NotFoundError; end
26
+ class ClassNotFound < NotFoundError; end
27
+ class MethodNotFound < NotFoundError; end
28
+ class FunctionNotFound < NotFoundError; end
29
+ class DocNotFound < NotFoundError; end
30
+
31
+ module WriterError; end
32
+ class DocumentError
33
+ include WriterError
34
+ end
35
+ class UserError
36
+ include WriterError
37
+ end
38
+ end
@@ -0,0 +1,115 @@
1
+ #
2
+ # bitclust/functiondatabase.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/database'
11
+ require 'bitclust/functionentry'
12
+ require 'bitclust/completion'
13
+ require 'bitclust/functionreferenceparser'
14
+ require 'bitclust/exception'
15
+
16
+ module BitClust
17
+
18
+ class FunctionDatabase < Database
19
+
20
+ include Completion
21
+
22
+ def initialize(prefix)
23
+ super
24
+ @dirty_functions = {}
25
+ @functionmap = {}
26
+ @function_extent_loaded = false
27
+ end
28
+
29
+ def commit
30
+ each_dirty_function do |f|
31
+ f.save
32
+ end
33
+ clear_dirty
34
+ #save_completion_index
35
+ end
36
+ private :commit
37
+
38
+ def dirty_function(f)
39
+ @dirty_functions[f] = true
40
+ end
41
+
42
+ def dirty?
43
+ not @dirty_functions.empty?
44
+ end
45
+
46
+ def each_dirty_function(&block)
47
+ @dirty_functions.each_key(&block)
48
+ end
49
+
50
+ def clear_dirty
51
+ @dirty_functions.clear
52
+ end
53
+
54
+ def update_by_file(path, filename)
55
+ check_transaction
56
+ FunctionReferenceParser.new(self).parse_file(path, filename, properties())
57
+ end
58
+
59
+ def search_functions(pattern)
60
+ fs = _search_functions(pattern)
61
+ if fs.empty?
62
+ raise FunctionNotFound, "no such function: #{pattern}"
63
+ end
64
+ fs
65
+ end
66
+
67
+ def open_function(id)
68
+ check_transaction
69
+ if exist?("function/#{id}")
70
+ f = load_function(id)
71
+ f.clear
72
+ else
73
+ f = (@functionmap[id] ||= FunctionEntry.new(self, id))
74
+ end
75
+ yield f
76
+ dirty_function f
77
+ f
78
+ end
79
+
80
+ def fetch_function(id)
81
+ load_function(id) or
82
+ raise FunctionNotFound, "function not found: #{id.inspect}"
83
+ end
84
+
85
+ def load_function(id)
86
+ @functionmap[id] ||=
87
+ begin
88
+ return nil unless exist?("function/#{id}")
89
+ FunctionEntry.new(self, id)
90
+ end
91
+ end
92
+ private :load_function
93
+
94
+ def functions
95
+ functionmap().values
96
+ end
97
+
98
+ def functionmap
99
+ return @functionmap if @function_extent_loaded
100
+ id_extent(FunctionEntry).each do |id|
101
+ @functionmap[id] ||= FunctionEntry.new(self, id)
102
+ end
103
+ @function_extent_loaded = true
104
+ @functionmap
105
+ end
106
+ private :functionmap
107
+
108
+ def id_extent(entry_class)
109
+ entries(entry_class.type_id.to_s)
110
+ end
111
+ private :id_extent
112
+
113
+ end
114
+
115
+ end
@@ -0,0 +1,81 @@
1
+ #
2
+ # bitclust/functionentry.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 FunctionEntry < Entry
16
+
17
+ def FunctionEntry.type_id
18
+ :function
19
+ end
20
+
21
+ def initialize(db, id)
22
+ super db
23
+ @id = id
24
+ init_properties
25
+ end
26
+
27
+ def inspect
28
+ "\#<function #{@id}>"
29
+ end
30
+
31
+ def name_match?(re)
32
+ re =~ name()
33
+ end
34
+
35
+ def <=>(other)
36
+ @id.casecmp(other.id)
37
+ end
38
+
39
+ persistent_properties {
40
+ property :filename, 'String'
41
+ property :macro, 'bool'
42
+ property :private, 'bool'
43
+ property :type, 'String'
44
+ property :name, 'String'
45
+ property :params, 'String'
46
+ property :source, 'String'
47
+ }
48
+
49
+ attr_reader :id
50
+ remove_method :name
51
+ alias name id
52
+ alias label id
53
+
54
+ alias macro? macro
55
+ alias private? private
56
+
57
+ def public?
58
+ not private?
59
+ end
60
+
61
+ def callable?
62
+ not params().empty?
63
+ end
64
+
65
+ def type_label
66
+ macro? ? 'macro' : 'function'
67
+ end
68
+ alias kind type_label
69
+
70
+ def header
71
+ if callable?
72
+ base = "#{type()} #{name()}#{params()}"
73
+ else
74
+ base = "#{type()} #{name()}"
75
+ end
76
+ "#{private? ? 'static ' : ''}#{base}"
77
+ end
78
+
79
+ end
80
+
81
+ end
@@ -0,0 +1,76 @@
1
+ #
2
+ # bitclust/functionreferenceparser.rb
3
+ #
4
+ # Copyright (c) 2006-2007 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/exception'
11
+
12
+ module BitClust
13
+
14
+ class FunctionReferenceParser
15
+
16
+ def FunctionReferenceParser.parse_file(path, params = {"version" => "1.9.0"})
17
+ parser = new(FunctionDatabase.dummy(params))
18
+ parser.parse_file(path, File.basename(path, ".rd"), params)
19
+ end
20
+
21
+ def initialize(db)
22
+ @db = db
23
+ end
24
+
25
+ def parse_file(path, filename, properties)
26
+ fopen(path, 'r:UTF-8') {|f|
27
+ return parse(f, filename)
28
+ }
29
+ end
30
+
31
+ def parse(f, filename)
32
+ @filename = filename
33
+ file_entries LineInput.new(f)
34
+ @db.functions
35
+ end
36
+
37
+ private
38
+
39
+ def file_entries(f)
40
+ f.skip_blank_lines
41
+ f.while_match(/\A---/) do |header|
42
+ entry header.sub(/\A---/, '').strip, f.break(/\A---/)
43
+ f.skip_blank_lines
44
+ end
45
+ end
46
+
47
+ def entry(header, body)
48
+ h = parse_header(header)
49
+ @db.open_function(h.name) {|f|
50
+ f.filename = @filename
51
+ f.macro = h.macro
52
+ f.private = h.private
53
+ f.type = h.type
54
+ f.name = h.name
55
+ f.params = h.params
56
+ f.source = body.join('')
57
+ }
58
+ end
59
+
60
+ def parse_header(header)
61
+ h = FunctionHeader.new
62
+ m = header.match(/\A\s*(MACRO\s+)?(static\s+)?(.+?\W)(\w+)(\(.*\))?\s*\z/)
63
+ raise ParseError, "syntax error: #{header.inspect}" unless m
64
+ h.macro = m[1] ? true : false
65
+ h.private = m[2] ? true : false
66
+ h.type = m[3].strip
67
+ h.name = m[4]
68
+ h.params = m[5].strip if m[5]
69
+ h
70
+ end
71
+
72
+ end
73
+
74
+ FunctionHeader = Struct.new(:macro, :private, :type, :name, :params)
75
+
76
+ end
@@ -0,0 +1,80 @@
1
+ #
2
+ # bitclust/htmlutils.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/nameutils'
11
+
12
+ module BitClust
13
+
14
+ module HTMLUtils
15
+
16
+ include NameUtils
17
+
18
+ private
19
+
20
+ # make method anchor from MethodEntry
21
+ def link_to_method(m, specp = false)
22
+ label = specp ? m.label : m.short_label
23
+ a_href(@urlmapper.method_url(methodid2specstring(m.id)), label)
24
+ end
25
+
26
+ def library_link(name, label = nil, frag = nil)
27
+ a_href(@urlmapper.library_url(name) + fragment(frag), label || name)
28
+ end
29
+
30
+ def class_link(name, label = nil, frag = nil)
31
+ a_href(@urlmapper.class_url(name) + fragment(frag), label || name)
32
+ end
33
+
34
+ def method_link(spec, label = nil, frag = nil)
35
+ a_href(method_url(spec, frag), label || spec)
36
+ end
37
+
38
+ def method_url(spec, frag = nil)
39
+ @urlmapper.method_url(spec) + fragment(frag)
40
+ end
41
+
42
+ def function_link(name, label = nil, frag = nil)
43
+ a_href(@urlmapper.function_url(name) + fragment(frag), label || name)
44
+ end
45
+
46
+ def document_link(name, label = nil, frag = nil)
47
+ a_href(@urlmapper.document_url(name) + fragment(frag),
48
+ label || @option[:database].get_doc(name).title)
49
+ end
50
+
51
+ def fragment(str)
52
+ str ? '#' + str : ''
53
+ end
54
+
55
+ def a_href(url, label)
56
+ %Q(<a href="#{escape_html(url)}">#{escape_html(label)}</a>)
57
+ end
58
+
59
+ ESC = {
60
+ '&' => '&amp;',
61
+ '"' => '&quot;',
62
+ '<' => '&lt;',
63
+ '>' => '&gt;'
64
+ }
65
+
66
+ def escape_html(str)
67
+ table = ESC # optimize
68
+ str.gsub(/[&"<>]/) {|s| table[s] }
69
+ end
70
+
71
+ ESCrev = ESC.invert
72
+
73
+ def unescape_html(str)
74
+ table = ESCrev # optimize
75
+ str.gsub(/&\w+;/) {|s| table[s] }
76
+ end
77
+
78
+ end
79
+
80
+ end
@@ -0,0 +1,87 @@
1
+ #
2
+ # bitclust/interface.rb
3
+ #
4
+ # Copyright (c) 2006-2007 Minero Aoki
5
+ #
6
+ # This program is free software.
7
+ # You can distribute/modify this program under the Ruby License.
8
+ #
9
+
10
+ require 'webrick/cgi'
11
+ require 'webrick/httpservlet/abstract'
12
+ begin
13
+ require 'fcgi'
14
+ rescue LoadError
15
+ end
16
+
17
+ module BitClust
18
+
19
+ class Interface
20
+
21
+ def initialize(webrick_conf = {})
22
+ @webrick_conf = webrick_conf
23
+ @handler = ($bitclust_context_cache ||= yield)
24
+ end
25
+
26
+ # for WEBrick servlet
27
+ def get_instance(server)
28
+ WEBrickServlet.new(server, @handler)
29
+ end
30
+
31
+ def main
32
+ if fastcgi?
33
+ FCGI.new(@webrick_conf).main(@handler)
34
+ else
35
+ # CGI, mod_ruby
36
+ CGI.new(@webrick_conf).main(@handler)
37
+ end
38
+ end
39
+
40
+ # for rack
41
+ def call(env)
42
+ @handler.handle(Rack::Request.new(env)).rack_finish
43
+ end
44
+
45
+ private
46
+
47
+ def fastcgi?
48
+ defined?(::FCGI) and ::FCGI.fastcgi?
49
+ end
50
+
51
+ def mod_ruby?
52
+ false # FIXME
53
+ end
54
+
55
+ class CGI < ::WEBrick::CGI
56
+ def main(handler)
57
+ @handler = handler
58
+ start
59
+ end
60
+
61
+ def do_GET(wreq, wres)
62
+ @handler.handle(wreq).update wres
63
+ end
64
+
65
+ alias do_POST do_GET
66
+ end
67
+
68
+ class FCGI < CGI
69
+ def main(handler)
70
+ @handler = handler
71
+ ::FCGI.each_cgi_request do |req|
72
+ start req.env, req.in, req.out
73
+ end
74
+ end
75
+ end
76
+
77
+ class WEBrickServlet < ::WEBrick::HTTPServlet::AbstractServlet
78
+ def do_GET(wreq, wres)
79
+ @options.first.handle(wreq).update wres
80
+ end
81
+
82
+ alias do_POST do_GET
83
+ end
84
+
85
+ end
86
+
87
+ end