Class: PreprocessinatorCodeFinder
- Defined in:
- lib/ceedling/preprocess/preprocessinator_code_finder.rb
Constant Summary collapse
- LINE_MARKER_REGEX =
/^#\s+(\d+)\s+"[^"]+"[^\n]*\n/- WHITESPACE_MARKER =
Regex-special-character-immune string
'<!@_ws_!@>'
Instance Method Summary collapse
-
#find_in_c_file(filepath, code) ⇒ Object
Open a C source file and search it for code.
-
#find_in_c_string(content, code) ⇒ Object
Wrap a C file content string in a StringIO and search it for code.
-
#find_in_preprpocessed_file(filepath, code) ⇒ Object
Open a GCC preprocessor output file and search it for code.
-
#find_in_preprpocessed_string(content, code) ⇒ Object
Wrap a GCC preprocessor output string in a StringIO and search it for code.
Instance Method Details
#find_in_c_file(filepath, code) ⇒ Object
Open a C source file and search it for code. Returns the 1-indexed source line number of the match, or nil if not found. Intended for production use where C file resides on disk.
38 39 40 41 42 |
# File 'lib/ceedling/preprocess/preprocessinator_code_finder.rb', line 38 def find_in_c_file(filepath, code) File.open( filepath, 'r' ) do |file| return find_in_c_code( io: file, search: code ) end end |
#find_in_c_string(content, code) ⇒ Object
Wrap a C file content string in a StringIO and search it for code. Returns the 1-indexed source line number of the match, or nil if not found. Intended for test use so that specs require no temporary files.
48 49 50 51 |
# File 'lib/ceedling/preprocess/preprocessinator_code_finder.rb', line 48 def find_in_c_string(content, code) buffer = StringIO.new( content ) return find_in_c_code( io: buffer, search: code ) end |
#find_in_preprpocessed_file(filepath, code) ⇒ Object
Open a GCC preprocessor output file and search it for code. Returns the 1-indexed source line number of the match, or nil if not found. Intended for production use where preprocessor output resides on disk.
20 21 22 23 24 |
# File 'lib/ceedling/preprocess/preprocessinator_code_finder.rb', line 20 def find_in_preprpocessed_file(filepath, code) File.open( filepath, 'r' ) do |file| return find_in_preprocessed_content( io: file, search: code ) end end |
#find_in_preprpocessed_string(content, code) ⇒ Object
Wrap a GCC preprocessor output string in a StringIO and search it for code. Returns the 1-indexed source line number of the match, or nil if not found. Intended for test use so that specs require no temporary files.
30 31 32 33 |
# File 'lib/ceedling/preprocess/preprocessinator_code_finder.rb', line 30 def find_in_preprpocessed_string(content, code) buffer = StringIO.new( content ) return find_in_preprocessed_content( io: buffer, search: code ) end |