|
1 | | -require 'set' |
2 | | - |
3 | 1 | module FFI |
4 | 2 | module Clang |
5 | 3 | class Cursor |
@@ -69,52 +67,6 @@ def anonymous_definer |
69 | 67 | result |
70 | 68 | end |
71 | 69 |
|
72 | | - # Monkey patch to handle extern "C" linkage spec in qualified names. |
73 | | - # See https://github.com/ioquatix/ffi-clang/pull/97 |
74 | | - def qualified_name |
75 | | - if self.kind != :cursor_translation_unit |
76 | | - if self.semantic_parent.kind == :cursor_invalid_file |
77 | | - raise(ArgumentError, "Invalid semantic parent: #{self}") |
78 | | - end |
79 | | - if self.kind == :cursor_linkage_spec |
80 | | - return self.semantic_parent.qualified_name |
81 | | - end |
82 | | - result = self.semantic_parent.qualified_name |
83 | | - result && !result.empty? ? "#{result}::#{self.spelling}" : self.spelling |
84 | | - end |
85 | | - end |
86 | | - |
87 | | - # Find first child cursor matching any of the given kinds. |
88 | | - # Short-circuits on first match via :break to properly terminate |
89 | | - # clang_visitChildren (a non-local return would skip CXChildVisit_Break |
90 | | - # and corrupt the outer visitor state). |
91 | | - def find_first_by_kind(recurse, *kinds) |
92 | | - result = nil |
93 | | - kinds_set = kinds.to_set |
94 | | - self.each(recurse) do |child, parent| |
95 | | - if kinds_set.include?(child.kind) |
96 | | - result = child |
97 | | - next :break |
98 | | - end |
99 | | - end |
100 | | - result |
101 | | - end |
102 | | - |
103 | | - # Monkey patch to use Set for faster lookup and support block/enumerator. |
104 | | - # See https://github.com/ioquatix/ffi-clang/pull/99 |
105 | | - def find_by_kind(recurse, *kinds, &block) |
106 | | - unless (recurse == nil || recurse == true || recurse == false) |
107 | | - raise("Recurse parameter must be nil or a boolean value. Value was: #{recurse}") |
108 | | - end |
109 | | - |
110 | | - return enum_for(__method__, recurse, *kinds) unless block_given? |
111 | | - |
112 | | - kinds_set = kinds.to_set |
113 | | - |
114 | | - self.each(recurse) do |child, parent| |
115 | | - yield child if kinds_set.include?(child.kind) |
116 | | - end |
117 | | - end |
118 | 70 | end |
119 | 71 | end |
120 | 72 | end |
0 commit comments