Class: C::Preprocessor
- Inherits:
-
Object
- Object
- C::Preprocessor
- Defined in:
- lib/cast/preprocessor.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- INCLUDE_REGEX =
/(?:[^ ]|\\ )+\.h/i- COMPILER =
RbConfig::CONFIG["CC"]
Class Attribute Summary collapse
-
.command ⇒ Object
Returns the value of attribute command.
Instance Attribute Summary collapse
-
#include_path ⇒ Object
Returns the value of attribute include_path.
-
#macros ⇒ Object
Returns the value of attribute macros.
-
#pwd ⇒ Object
Returns the value of attribute pwd.
Instance Method Summary collapse
-
#get_all_includes(text) ⇒ Object
if clean_gnu_artifacts output.gsub!(/\b__asm((?:"[^"]"|[^)"])*)/, '') output.gsub!(/\b__attribute__(((?:[^()]|([^()]+))+))/, '') output.gsub!(/ __inline /, ' ') end.
- #get_project_includes(text) ⇒ Object
- #get_system_includes(text) ⇒ Object
-
#initialize ⇒ Preprocessor
constructor
A new instance of Preprocessor.
- #preprocess(text, line_markers = false) ⇒ Object
- #preprocess_file(file_name) ⇒ Object
Constructor Details
#initialize ⇒ Preprocessor
Returns a new instance of Preprocessor.
24 25 26 27 |
# File 'lib/cast/preprocessor.rb', line 24 def initialize @include_path = [] @macros = {} end |
Class Attribute Details
.command ⇒ Object
Returns the value of attribute command.
19 20 21 |
# File 'lib/cast/preprocessor.rb', line 19 def command @command end |
Instance Attribute Details
#include_path ⇒ Object
Returns the value of attribute include_path.
22 23 24 |
# File 'lib/cast/preprocessor.rb', line 22 def include_path @include_path end |
#macros ⇒ Object
Returns the value of attribute macros.
22 23 24 |
# File 'lib/cast/preprocessor.rb', line 22 def macros @macros end |
#pwd ⇒ Object
Returns the value of attribute pwd.
22 23 24 |
# File 'lib/cast/preprocessor.rb', line 22 def pwd @pwd end |
Instance Method Details
#get_all_includes(text) ⇒ Object
if clean_gnu_artifacts output.gsub!(/\b__asm((?:"[^"]"|[^)"])*)/, '') output.gsub!(/\b__attribute__(((?:[^()]|([^()]+))+))/, '') output.gsub!(/ __inline /, ' ') end
40 41 42 43 |
# File 'lib/cast/preprocessor.rb', line 40 def get_all_includes(text) args = %w{-E -M} split_includes run(args, text) end |
#get_project_includes(text) ⇒ Object
47 48 49 50 |
# File 'lib/cast/preprocessor.rb', line 47 def get_project_includes(text) args = %w{-E -MM} split_includes run(args, text) end |
#get_system_includes(text) ⇒ Object
44 45 46 |
# File 'lib/cast/preprocessor.rb', line 44 def get_system_includes(text) get_all_includes(text) - get_project_includes(text) end |
#preprocess(text, line_markers = false) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cast/preprocessor.rb', line 28 def preprocess(text, line_markers = false) args = %w{-E} args << "-P" unless line_markers run args, text =begin if clean_gnu_artifacts output.gsub!(/\b__asm\((?:"[^"]*"|[^)"]*)*\)/, '') output.gsub!(/\b__attribute__\(\((?:[^()]|\([^()]+\))+\)\)/, '') output.gsub!(/ __inline /, ' ') end =end end |
#preprocess_file(file_name) ⇒ Object
51 52 53 |
# File 'lib/cast/preprocessor.rb', line 51 def preprocess_file(file_name) preprocess(File.read(file_name)) end |