ghazel-ffi-clang 0.2.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +21 -0
- data/Gemfile +4 -0
- data/README.md +74 -0
- data/Rakefile +12 -0
- data/ext/rakefile.rb +12 -0
- data/ext/teapot.rb +16 -0
- data/ffi-clang.gemspec +26 -0
- data/lib/ffi/clang.rb +54 -0
- data/lib/ffi/clang/comment.rb +278 -0
- data/lib/ffi/clang/cursor.rb +378 -0
- data/lib/ffi/clang/diagnostic.rb +113 -0
- data/lib/ffi/clang/file.rb +69 -0
- data/lib/ffi/clang/index.rb +71 -0
- data/lib/ffi/clang/lib.rb +73 -0
- data/lib/ffi/clang/lib/comment.rb +117 -0
- data/lib/ffi/clang/lib/cursor.rb +353 -0
- data/lib/ffi/clang/lib/diagnostic.rb +87 -0
- data/lib/ffi/clang/lib/file.rb +57 -0
- data/lib/ffi/clang/lib/index.rb +34 -0
- data/lib/ffi/clang/lib/source_location.rb +53 -0
- data/lib/ffi/clang/lib/source_range.rb +46 -0
- data/lib/ffi/clang/lib/string.rb +45 -0
- data/lib/ffi/clang/lib/token.rb +58 -0
- data/lib/ffi/clang/lib/translation_unit.rb +106 -0
- data/lib/ffi/clang/lib/type.rb +154 -0
- data/lib/ffi/clang/lib/utils.rb +29 -0
- data/lib/ffi/clang/source_location.rb +149 -0
- data/lib/ffi/clang/source_range.rb +61 -0
- data/lib/ffi/clang/token.rb +95 -0
- data/lib/ffi/clang/translation_unit.rb +142 -0
- data/lib/ffi/clang/type.rb +135 -0
- data/lib/ffi/clang/unsaved_file.rb +49 -0
- data/lib/ffi/clang/utils.rb +58 -0
- data/lib/ffi/clang/version.rb +26 -0
- data/spec/clang/comment_spec.rb +470 -0
- data/spec/clang/cursor_spec.rb +709 -0
- data/spec/clang/diagnostic_spec.rb +89 -0
- data/spec/clang/file_spec.rb +84 -0
- data/spec/clang/index_spec.rb +70 -0
- data/spec/clang/source_location_spec.rb +140 -0
- data/spec/clang/source_range_spec.rb +76 -0
- data/spec/clang/token_spec.rb +83 -0
- data/spec/clang/translation_unit_spec.rb +214 -0
- data/spec/clang/type_spec.rb +289 -0
- data/spec/clang/utils_spec.rb +61 -0
- data/spec/fixtures/a.c +7 -0
- data/spec/fixtures/canonical.c +5 -0
- data/spec/fixtures/docs.c +1 -0
- data/spec/fixtures/docs.cc +1 -0
- data/spec/fixtures/docs.h +54 -0
- data/spec/fixtures/list.c +11 -0
- data/spec/fixtures/location1.c +7 -0
- data/spec/fixtures/simple.c +3 -0
- data/spec/fixtures/test.cxx +62 -0
- data/spec/spec_helper.rb +64 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 506649e109549d1903e03b67c447155675058565
|
4
|
+
data.tar.gz: b6db09a97418026ebcbde1f6566020e19c072b6a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e9ac59e87eb20103c844bf160ebe2c0bd9a433f3f98fcbaf3fa10cb6487add82e44c6ff21a0c3fc68e80c2f35b8cb13f92b092590fa6c8b64329041d5e8e050
|
7
|
+
data.tar.gz: 488e6bfd72f695c81a5ce2ad4455a82e65d00bcfd788163d9e2f592cb7523eacbdfff20d336e5797fce841af16a1cf79d00b7eb251c89ee683dac42dd2af541d
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- "2.0"
|
4
|
+
- "2.1"
|
5
|
+
env:
|
6
|
+
- LLVM_VERSION=3.2
|
7
|
+
- LLVM_VERSION=3.3
|
8
|
+
- LLVM_VERSION=3.4
|
9
|
+
- LLVM_VERSION=3.5
|
10
|
+
install:
|
11
|
+
- sudo add-apt-repository --yes ppa:h-rayflood/llvm
|
12
|
+
- sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
|
13
|
+
- sudo add-apt-repository --yes 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main'
|
14
|
+
- wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
|
15
|
+
- sudo apt-get -qq update
|
16
|
+
- sudo apt-get -qq install libclang-${LLVM_VERSION}-dev clang-${LLVM_VERSION}
|
17
|
+
- export LD_LIBRARY_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib/
|
18
|
+
- export PATH=/usr/lib/llvm-${LLVM_VERSION}/bin:$PATH
|
19
|
+
- if [ "${LLVM_VERSION}" = "3.5" ]; then sudo ln -s /usr/bin/clang /usr/lib/llvm-${LLVM_VERSION}/bin/clang; fi
|
20
|
+
- if [ "${LLVM_VERSION}" = "3.5" ]; then sudo ln -s /usr/bin/clang++ /usr/lib/llvm-${LLVM_VERSION}/bin/clang++; fi
|
21
|
+
- bundle install
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# FFI::Clang
|
2
|
+
|
3
|
+
A light weight wrapper for Ruby exposing [libclang][1].
|
4
|
+
|
5
|
+
[](http://travis-ci.org/ioquatix/ffi-clang)
|
6
|
+
[](https://codeclimate.com/github/ioquatix/ffi-clang)
|
7
|
+
|
8
|
+
[1]: http://llvm.org/devmtg/2010-11/Gregor-libclang.pdf
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'ffi-clang'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install ffi-clang
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Traverse the AST in the given file:
|
27
|
+
|
28
|
+
index = Index.new
|
29
|
+
translation_unit = index.parse_translation_unit("list.c")
|
30
|
+
cursor = translation_unit.cursor
|
31
|
+
cursor.visit_children do |cursor, parent|
|
32
|
+
puts "#{cursor.kind} #{cursor.spelling.inspect}"
|
33
|
+
|
34
|
+
next :recurse
|
35
|
+
end
|
36
|
+
|
37
|
+
### Library Version
|
38
|
+
|
39
|
+
Due to issues figuring out which library to use, we require you to manually specify it. For example, to run the tests, with MacPorts llvm/clang 3.4, use the following:
|
40
|
+
|
41
|
+
LLVM_CONFIG=llvm-config-mp-3.4 rake
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
Copyright, 2010-2012, by Jari Bakken.
|
54
|
+
Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
55
|
+
Copyright, 2013, by Garry C. Marshall. <http://www.meaningfulname.net>
|
56
|
+
Copyright, 2014, by Masahiro Sano.
|
57
|
+
|
58
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
59
|
+
of this software and associated documentation files (the "Software"), to deal
|
60
|
+
in the Software without restriction, including without limitation the rights
|
61
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
62
|
+
copies of the Software, and to permit persons to whom the Software is
|
63
|
+
furnished to do so, subject to the following conditions:
|
64
|
+
|
65
|
+
The above copyright notice and this permission notice shall be included in
|
66
|
+
all copies or substantial portions of the Software.
|
67
|
+
|
68
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
69
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
70
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
71
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
72
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
73
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
74
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
desc 'Default: run specs.'
|
6
|
+
task :default => :spec
|
7
|
+
|
8
|
+
desc "Run specs"
|
9
|
+
RSpec::Core::RakeTask.new do |t|
|
10
|
+
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
11
|
+
# Put spec opts in a file named .rspec in root
|
12
|
+
end
|
data/ext/rakefile.rb
ADDED
data/ext/teapot.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#
|
2
|
+
# This file is part of the "Teapot" project, and is released under the MIT license.
|
3
|
+
#
|
4
|
+
|
5
|
+
teapot_version "0.8.0"
|
6
|
+
|
7
|
+
define_target "ffi-clang" do |target|
|
8
|
+
target.depends "Library/clang"
|
9
|
+
target.provides "Dependencies/ffi-clang"
|
10
|
+
end
|
11
|
+
|
12
|
+
define_configuration "ffi-clang" do |configuration|
|
13
|
+
configuration[:source] = "https://github.com/dream-framework/"
|
14
|
+
|
15
|
+
configuration.require "clang"
|
16
|
+
end
|
data/ffi-clang.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ffi/clang/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ghazel-ffi-clang"
|
8
|
+
spec.version = FFI::Clang::VERSION
|
9
|
+
spec.authors = ["Jari Bakken", "Samuel Williams"]
|
10
|
+
spec.email = ["Jari Bakken", "samuel.williams@oriontransfer.co.nz"]
|
11
|
+
spec.description = %q{Ruby FFI bindings for libclang C interface.}
|
12
|
+
spec.summary = %q{Ruby FFI bindings for libclang C interface.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "ffi"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
data/lib/ffi/clang.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright, 2010-2012 by Jari Bakken.
|
2
|
+
# Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'ffi'
|
23
|
+
require "rbconfig"
|
24
|
+
|
25
|
+
module FFI::Clang
|
26
|
+
class Error < StandardError
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.platform
|
30
|
+
os = RbConfig::CONFIG["host_os"]
|
31
|
+
|
32
|
+
case os
|
33
|
+
when /darwin/
|
34
|
+
:darwin
|
35
|
+
when /linux/
|
36
|
+
:linux
|
37
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
38
|
+
:windows
|
39
|
+
else
|
40
|
+
os
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
require 'ffi/clang/utils'
|
46
|
+
require 'ffi/clang/lib'
|
47
|
+
require 'ffi/clang/index'
|
48
|
+
require 'ffi/clang/translation_unit'
|
49
|
+
require 'ffi/clang/diagnostic'
|
50
|
+
require 'ffi/clang/cursor'
|
51
|
+
require 'ffi/clang/source_location'
|
52
|
+
require 'ffi/clang/source_range'
|
53
|
+
require 'ffi/clang/unsaved_file'
|
54
|
+
require 'ffi/clang/token'
|
@@ -0,0 +1,278 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright, 2013, by Carlos Martín Nieto <cmn@dwim.me>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'ffi/clang/lib/cursor'
|
23
|
+
require 'ffi/clang/lib/comment'
|
24
|
+
require 'ffi/clang/source_location'
|
25
|
+
|
26
|
+
module FFI
|
27
|
+
module Clang
|
28
|
+
|
29
|
+
class Comment
|
30
|
+
include Enumerable
|
31
|
+
|
32
|
+
def self.build_from(comment)
|
33
|
+
kind = Lib.comment_get_kind(comment)
|
34
|
+
case kind
|
35
|
+
when :comment_null
|
36
|
+
Comment.new comment
|
37
|
+
when :comment_text
|
38
|
+
TextComment.new comment
|
39
|
+
when :comment_inline_command
|
40
|
+
InlineCommandComment.new comment
|
41
|
+
when :comment_html_start_tag
|
42
|
+
HTMLStartTagComment.new comment
|
43
|
+
when :comment_html_end_tag
|
44
|
+
HTMLEndTagComment.new comment
|
45
|
+
when :comment_paragraph
|
46
|
+
ParagraphComment.new comment
|
47
|
+
when :comment_block_command
|
48
|
+
BlockCommandComment.new comment
|
49
|
+
when :comment_param_command
|
50
|
+
ParamCommandComment.new comment
|
51
|
+
when :comment_tparam_command
|
52
|
+
TParamCommandComment.new comment
|
53
|
+
when :comment_verbatim_block_command
|
54
|
+
VerbatimBlockCommandComment.new comment
|
55
|
+
when :comment_verbatim_block_line
|
56
|
+
VerbatimBlockLineComment.new comment
|
57
|
+
when :comment_verbatim_line
|
58
|
+
VerbatimLine.new comment
|
59
|
+
when :comment_full
|
60
|
+
FullComment.new comment
|
61
|
+
else
|
62
|
+
raise NotImplementedError, kind
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def text
|
67
|
+
return ""
|
68
|
+
end
|
69
|
+
|
70
|
+
def initialize(comment)
|
71
|
+
@comment = comment
|
72
|
+
end
|
73
|
+
|
74
|
+
def kind
|
75
|
+
Lib.comment_get_kind(@comment)
|
76
|
+
end
|
77
|
+
|
78
|
+
def num_children
|
79
|
+
Lib.comment_get_num_children(@comment)
|
80
|
+
end
|
81
|
+
|
82
|
+
def child(n = 0)
|
83
|
+
Comment.build_from Lib.comment_get_child(@comment, n)
|
84
|
+
end
|
85
|
+
|
86
|
+
def children
|
87
|
+
num_children.times.map { |i| child(i) }
|
88
|
+
end
|
89
|
+
|
90
|
+
def whitespace?
|
91
|
+
Lib.comment_is_whitespace(@comment) != 0
|
92
|
+
end
|
93
|
+
|
94
|
+
def has_trailing_newline?
|
95
|
+
Lib.inline_content_comment_has_trailing_newline(@comment) != 0
|
96
|
+
end
|
97
|
+
|
98
|
+
def each(&block)
|
99
|
+
num_children.times.map do |i|
|
100
|
+
block.call(child(i))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
class HTMLTagComment < Comment
|
107
|
+
def name
|
108
|
+
Lib.extract_string Lib.html_tag_comment_get_tag_name(@comment)
|
109
|
+
end
|
110
|
+
alias_method :tag, :name
|
111
|
+
|
112
|
+
def text
|
113
|
+
Lib.extract_string Lib.html_tag_comment_get_as_string(@comment)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
class HTMLStartTagComment < HTMLTagComment
|
118
|
+
def self_closing?
|
119
|
+
Lib.html_start_tag_comment_is_self_closing(@comment) != 0
|
120
|
+
end
|
121
|
+
|
122
|
+
def num_attrs
|
123
|
+
Lib.html_start_tag_comment_get_num_attrs(@comment)
|
124
|
+
end
|
125
|
+
|
126
|
+
def attrs
|
127
|
+
num_attrs.times.map { |i|
|
128
|
+
{
|
129
|
+
name: Lib.extract_string(Lib.html_start_tag_comment_get_attr_name(@comment, i)),
|
130
|
+
value: Lib.extract_string(Lib.html_start_tag_comment_get_attr_value(@comment, i)),
|
131
|
+
}
|
132
|
+
}
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
class HTMLEndTagComment < HTMLTagComment
|
137
|
+
end
|
138
|
+
|
139
|
+
class ParagraphComment < Comment
|
140
|
+
def text
|
141
|
+
self.map(&:text).join("\n")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
class TextComment < Comment
|
146
|
+
def text
|
147
|
+
Lib.extract_string Lib.text_comment_get_text(@comment)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
class InlineCommandComment < Comment
|
152
|
+
def name
|
153
|
+
Lib.extract_string Lib.inline_command_comment_get_command_name(@comment)
|
154
|
+
end
|
155
|
+
|
156
|
+
def render_kind
|
157
|
+
Lib.inline_command_comment_get_render_kind(@comment)
|
158
|
+
end
|
159
|
+
|
160
|
+
def num_args
|
161
|
+
Lib.inline_command_comment_get_num_args(@comment)
|
162
|
+
end
|
163
|
+
|
164
|
+
def args
|
165
|
+
num_args.times.map { |i|
|
166
|
+
Lib.extract_string Lib.inline_command_comment_get_arg_text(@comment, i)
|
167
|
+
}
|
168
|
+
end
|
169
|
+
|
170
|
+
def text
|
171
|
+
args.join
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
class BlockCommandComment < Comment
|
176
|
+
def name
|
177
|
+
Lib.extract_string Lib.block_command_comment_get_command_name(@comment)
|
178
|
+
end
|
179
|
+
|
180
|
+
def paragraph
|
181
|
+
Comment.build_from Lib.block_command_comment_get_paragraph(@comment)
|
182
|
+
end
|
183
|
+
|
184
|
+
def text
|
185
|
+
self.paragraph.text
|
186
|
+
end
|
187
|
+
alias_method :comment, :text
|
188
|
+
|
189
|
+
def num_args
|
190
|
+
Lib.block_command_comment_get_num_args(@comment)
|
191
|
+
end
|
192
|
+
|
193
|
+
def args
|
194
|
+
num_args.times.map { |i|
|
195
|
+
Lib.extract_string Lib.block_command_comment_get_arg_text(@comment, i)
|
196
|
+
}
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
class ParamCommandComment < Comment
|
201
|
+
def name
|
202
|
+
Lib.extract_string Lib.param_command_comment_get_param_name(@comment)
|
203
|
+
end
|
204
|
+
|
205
|
+
def text
|
206
|
+
self.map(&:text).join("")
|
207
|
+
end
|
208
|
+
alias_method :comment, :text
|
209
|
+
|
210
|
+
def valid_index?
|
211
|
+
Lib.param_command_comment_is_param_index_valid(@comment) != 0
|
212
|
+
end
|
213
|
+
|
214
|
+
def index
|
215
|
+
Lib.param_command_comment_get_param_index(@comment)
|
216
|
+
end
|
217
|
+
|
218
|
+
def direction_explicit?
|
219
|
+
Lib.param_command_comment_is_direction_explicit(@comment) != 0
|
220
|
+
end
|
221
|
+
|
222
|
+
def direction
|
223
|
+
Lib.param_command_comment_get_direction(@comment)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
class TParamCommandComment < Comment
|
228
|
+
def text
|
229
|
+
self.child.text
|
230
|
+
end
|
231
|
+
alias_method :comment, :text
|
232
|
+
|
233
|
+
def name
|
234
|
+
Lib.extract_string Lib.tparam_command_comment_get_param_name(@comment)
|
235
|
+
end
|
236
|
+
|
237
|
+
def valid_position?
|
238
|
+
Lib.tparam_command_comment_is_param_position_valid(@comment) != 0
|
239
|
+
end
|
240
|
+
|
241
|
+
def depth
|
242
|
+
Lib.tparam_command_comment_get_depth(@comment)
|
243
|
+
end
|
244
|
+
|
245
|
+
def index(depth = 0)
|
246
|
+
Lib.tparam_command_comment_get_index(@comment, depth)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
class VerbatimBlockCommandComment < Comment
|
251
|
+
def text
|
252
|
+
children.map(&:text).join("\n")
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
class VerbatimBlockLineComment < Comment
|
257
|
+
def text
|
258
|
+
Lib.extract_string Lib.verbatim_block_line_comment_get_text(@comment)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
class VerbatimLine < Comment
|
263
|
+
def text
|
264
|
+
Lib.extract_string Lib.verbatim_line_comment_get_text(@comment)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
class FullComment < Comment
|
269
|
+
def to_html
|
270
|
+
Lib.extract_string Lib.full_comment_get_as_html(@comment)
|
271
|
+
end
|
272
|
+
|
273
|
+
def to_xml
|
274
|
+
Lib.extract_string Lib.full_comment_get_as_xml(@comment)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|