alias.patch
| b/data/bitclust/template/class Thu Sep 15 13:54:43 2011 +0900 | ||
|---|---|---|
| 16 | 16 |
myself, *supers = @entry.ancestors |
| 17 | 17 |
n = 0 |
| 18 | 18 |
%> |
| 19 |
<% unless @entry.alias? %> |
|
| 19 | 20 |
<%= _('ancestors') %>: <%= escape_html(myself.name) %>
|
| 20 | 21 |
<% supers.each do |c| %> |
| 21 | 22 |
<%= @conf[:tochm_mode] ? "<" : a_href("?a=#{n}", "<") %> <%= class_link(c.name) %>
|
| 22 | 23 |
<% n += 1 %> |
| 23 | 24 |
<% end %> |
| 25 |
<% end %> |
|
| 24 | 26 | |
| 25 | 27 |
<% unless @entry.extended.empty? %> |
| 26 | 28 |
<br>extend: <%= @entry.extended.map {|c| class_link(c.name) }.join(', ') %>
|
| 27 | 29 |
<% end %> |
| 30 |
<% unless @entry.aliases.empty? %> |
|
| 31 |
<br>aliases: <%=h @entry.aliases.map{|c| c.name}.join(', ') %>
|
|
| 32 |
<% end %> |
|
| 28 | 33 |
</p> |
| 29 | 34 |
<% |
| 30 | 35 |
headline_push |
| b/data/bitclust/template/library Thu Sep 15 13:54:43 2011 +0900 | ||
|---|---|---|
| 31 | 31 |
<table class="entries libraries"> |
| 32 | 32 |
<% cs.each do |c| %> |
| 33 | 33 |
<tr> |
| 34 |
<td class="signature"><%= class_link(c.name, "#{c.type} #{c.name}") %></td>
|
|
| 34 |
<td class="signature"><%= class_link(c.realname, "#{c.type} #{c.name}") %></td>
|
|
| 35 | 35 |
<td class="description"><%= compile_rd(c.synopsis_source) %></td> |
| 36 | 36 |
</tr> |
| 37 | 37 |
<% end %> |
| b/lib/bitclust/classentry.rb Thu Sep 15 13:54:43 2011 +0900 | ||
|---|---|---|
| 60 | 60 |
name() == n |
| 61 | 61 |
end |
| 62 | 62 | |
| 63 |
# Return the real class name |
|
| 64 |
def realname |
|
| 65 |
alias? ? aliasof.name : name |
|
| 66 |
end |
|
| 67 |
|
|
| 63 | 68 |
def name_match?(re) |
| 64 | 69 |
re =~ name() |
| 65 | 70 |
end |
| ... | ... | |
| 77 | 82 |
property :included, '[ClassEntry]' |
| 78 | 83 |
property :extended, '[ClassEntry]' |
| 79 | 84 |
property :library, 'LibraryEntry' |
| 85 |
property :aliases, '[ClassEntry]' |
|
| 86 |
property :aliasof, 'ClassEntry' |
|
| 80 | 87 |
property :source, 'String' |
| 81 | 88 |
} |
| 82 | 89 | |
| ... | ... | |
| 105 | 112 |
type() == :object |
| 106 | 113 |
end |
| 107 | 114 | |
| 115 |
def alias? |
|
| 116 |
!! aliasof() |
|
| 117 |
end |
|
| 118 | ||
| 108 | 119 |
def include(m) |
| 109 | 120 |
included().push m |
| 110 | 121 |
end |
| ... | ... | |
| 113 | 124 |
extended().push m |
| 114 | 125 |
end |
| 115 | 126 | |
| 127 |
# Add a alias +c+ to the alias list. |
|
| 128 |
def alias(c) |
|
| 129 |
aliases().push c |
|
| 130 |
end |
|
| 131 | ||
| 116 | 132 |
def check_ancestor_type |
| 117 | 133 |
s = superclass() |
| 118 | 134 |
if s and not s.class? and not s.dummy? |
| ... | ... | |
| 360 | 376 |
private |
| 361 | 377 | |
| 362 | 378 |
def makemap(typechar, inherited_modules, ents) |
| 379 |
if alias? |
|
| 380 |
return aliasof().__send__("_#{typechar}map").dup
|
|
| 381 |
end |
|
| 363 | 382 |
s = superclass() |
| 364 | 383 |
map = s ? s.__send__("_#{typechar}map").dup : {}
|
| 365 | 384 |
inherited_modules.each do |mod| |
| b/lib/bitclust/completion.rb Thu Sep 15 13:54:43 2011 +0900 | ||
|---|---|---|
| 512 | 512 |
@specs |= other.specs |
| 513 | 513 |
end |
| 514 | 514 | |
| 515 | ||
| 516 |
def owned_method? |
|
| 517 |
@specs.any? {|spec| spec.klass == origin().klass }
|
|
| 518 |
end |
|
| 519 |
|
|
| 520 |
def method_of_alias_class? |
|
| 521 |
@entry.klass.aliases.any?{|aliasclass| aliasclass.name?(class_name())}
|
|
| 522 |
end |
|
| 523 | ||
| 515 | 524 |
def inherited_method? |
| 516 |
not @specs.any? {|spec| spec.klass == origin().klass }
|
|
| 525 |
!owned_method?() && !method_of_alias_class?()
|
|
| 517 | 526 |
end |
| 527 | ||
| 518 | 528 |
end |
| 519 | 529 | |
| 520 | 530 |
end |
| b/lib/bitclust/methoddatabase.rb Thu Sep 15 13:54:43 2011 +0900 | ||
|---|---|---|
| 269 | 269 |
end |
| 270 | 270 |
private :classmap |
| 271 | 271 | |
| 272 |
# get a class entry if it exists, or create a new class entry object |
|
| 273 |
# if it doesn't exist. |
|
| 272 | 274 |
def get_class(name) |
| 273 | 275 |
if id = intern_classname(name) |
| 274 | 276 |
load_class(id) or |
| b/lib/bitclust/rrdparser.rb Thu Sep 15 13:54:43 2011 +0900 | ||
|---|---|---|
| 184 | 184 | |
| 185 | 185 |
def read_aliases(f) |
| 186 | 186 |
f.while_match(/\Aalias\s/) do |line| |
| 187 |
#tty_warn "#{line.location}: class alias is not implemented yet"
|
|
| 188 |
# FIXME |
|
| 187 |
@context.alias line.split[1] |
|
| 189 | 188 |
end |
| 190 | 189 |
end |
| 191 | 190 | |
| ... | ... | |
| 396 | 395 |
@klass.extend @db.get_class(name) |
| 397 | 396 |
end |
| 398 | 397 | |
| 398 |
# Add a alias +name+ to the alias list. |
|
| 399 |
def alias(name) |
|
| 400 |
@db.open_class(name) do |c| |
|
| 401 |
c.type = @klass.type |
|
| 402 |
c.library = @library |
|
| 403 |
c.aliasof = @klass |
|
| 404 |
c.source = "Alias of [[c:#{@klass.name}]]\n"
|
|
| 405 |
@library.add_class c |
|
| 406 |
@klass.alias c |
|
| 407 |
end |
|
| 408 |
end |
|
| 409 | ||
| 399 | 410 |
def module_function |
| 400 | 411 |
@type = :module_function |
| 401 | 412 |
end |
| b/lib/bitclust/searcher.rb Thu Sep 15 13:54:43 2011 +0900 | ||
|---|---|---|
| 409 | 409 |
end |
| 410 | 410 | |
| 411 | 411 |
def describe_class(c) |
| 412 |
if c.alias? |
|
| 413 |
describe_class(c.aliasof) |
|
| 414 |
return |
|
| 415 |
end |
|
| 416 |
|
|
| 412 | 417 |
unless c.library.name == '_builtin' |
| 413 | 418 |
puts "require '#{c.library.name}'"
|
| 414 | 419 |
puts |
| ... | ... | |
| 420 | 425 |
puts "include #{mod.name}"
|
| 421 | 426 |
end |
| 422 | 427 |
end |
| 428 |
unless c.aliases.empty? |
|
| 429 |
puts |
|
| 430 |
c.aliases.each do |al| |
|
| 431 |
puts "alias #{al.name}"
|
|
| 432 |
end |
|
| 433 |
end |
|
| 423 | 434 |
unless c.source.strip.empty? |
| 424 | 435 |
puts |
| 425 | 436 |
puts @compiler.compile(c.source.strip) |
| ... | ... | |
| 431 | 442 |
puts "require '#{rec.entry.library.name}'"
|
| 432 | 443 |
end |
| 433 | 444 |
# FIXME: replace method signature by method spec |
| 434 |
unless rec.inherited_method? |
|
| 445 |
if rec.method_of_alias_class? |
|
| 446 |
rec.specs.each do |spec| |
|
| 447 |
puts "#{rec.origin.klass}#{rec.origin.type}#{spec.method} (#{spec.klass} is an alias of #{rec.origin.klass})"
|
|
| 448 |
end |
|
| 449 |
elsif rec.inherited_method? |
|
| 450 |
rec.specs.each do |spec| |
|
| 451 |
puts "#{spec.klass}\t< #{rec.origin.klass}#{rec.origin.type}#{spec.method}"
|
|
| 452 |
end |
|
| 453 |
else |
|
| 435 | 454 |
rec.names.each do |name| |
| 436 | 455 |
puts name |
| 437 | 456 |
end |
| 438 |
else |
|
| 439 |
rec.specs.each do |spec| |
|
| 440 |
puts "#{spec.klass}\t< #{rec.origin.klass}#{rec.origin.type}#{spec.method}"
|
|
| 441 |
end |
|
| 442 | 457 |
end |
| 458 |
|
|
| 443 | 459 |
puts @compiler.compile(rec.entry.source.strip) |
| 444 | 460 |
puts |
| 445 | 461 |
end |