[ruby/rdoc] Allow any single-word token upto 2 before C method implementation
Previously only unknown word `intern` is allowed between a single-word token before a C method. Now any single-word token, such as `inline` which is used for `ArithmeticSequence` in enumerator.c, is allowed instead. https://github.com/ruby/rdoc/commit/3a214c1dd1
This commit is contained in:
parent
c0baa3783f
commit
113f5d7fd7
@ -575,9 +575,8 @@ class RDoc::Parser::C < RDoc::Parser
|
|||||||
table = {}
|
table = {}
|
||||||
file_content.scan(%r{
|
file_content.scan(%r{
|
||||||
((?>/\*.*?\*/\s*)?)
|
((?>/\*.*?\*/\s*)?)
|
||||||
((?:(?:\w+)\s+)?
|
((?:\w+\s+){0,2} VALUE\s+(\w+)
|
||||||
(?:intern\s+)?VALUE\s+(\w+)
|
\s*(?:\([^\)]*\))(?:[^\);]|$))
|
||||||
\s*(?:\([^)]*\))(?:[^\);]|$))
|
|
||||||
| ((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+(\w+)\s+(\w+))
|
| ((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+(\w+)\s+(\w+))
|
||||||
| ^\s*\#\s*define\s+(\w+)\s+(\w+)
|
| ^\s*\#\s*define\s+(\w+)\s+(\w+)
|
||||||
}xm) do
|
}xm) do
|
||||||
|
@ -1373,6 +1373,36 @@ Init_Foo(void) {
|
|||||||
assert_equal "DLL_LOCAL VALUE\nother_function() {\n}", code
|
assert_equal "DLL_LOCAL VALUE\nother_function() {\n}", code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_find_body_static_inline
|
||||||
|
content = <<-EOF
|
||||||
|
/*
|
||||||
|
* a comment for other_function
|
||||||
|
*/
|
||||||
|
static inline VALUE
|
||||||
|
other_function() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Init_Foo(void) {
|
||||||
|
VALUE foo = rb_define_class("Foo", rb_cObject);
|
||||||
|
|
||||||
|
rb_define_method(foo, "my_method", other_function, 0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
klass = util_get_class content, 'foo'
|
||||||
|
other_function = klass.method_list.first
|
||||||
|
|
||||||
|
assert_equal 'my_method', other_function.name
|
||||||
|
assert_equal "a comment for other_function",
|
||||||
|
other_function.comment.text
|
||||||
|
assert_equal '()', other_function.params
|
||||||
|
|
||||||
|
code = other_function.token_stream.first[:text]
|
||||||
|
|
||||||
|
assert_equal "static inline VALUE\nother_function() {\n}", code
|
||||||
|
end
|
||||||
|
|
||||||
def test_find_modifiers_call_seq
|
def test_find_modifiers_call_seq
|
||||||
comment = RDoc::Comment.new <<-COMMENT
|
comment = RDoc::Comment.new <<-COMMENT
|
||||||
call-seq:
|
call-seq:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user