Class: RubyHeaderParser::Config
- Inherits:
-
Object
- Object
- RubyHeaderParser::Config
- Defined in:
- lib/ruby_header_parser/config.rb
Overview
Manager for config file
Instance Attribute Summary collapse
- #data ⇒ Hash readonly
Instance Method Summary collapse
-
#function_arg_pointer_hint(function_name:, pos:) ⇒ Symbol
:ref, :array, :ref_array, :function, :sref, :str_array, :in_ref.
-
#function_self_pointer_hint(function_name) ⇒ Symbol
:ref, :raw.
-
#initialize(config_file) ⇒ Config
constructor
A new instance of Config.
-
#should_generate_enum?(enum_name) ⇒ Boolean
Whether generate C enum to go.
-
#should_generate_function?(function_name) ⇒ Boolean
Whether generate C function to go.
-
#should_generate_struct?(struct_name) ⇒ Boolean
Whether generate C struct to go.
-
#should_generate_type?(type_name) ⇒ Boolean
Whether generate C type to go.
Constructor Details
#initialize(config_file) ⇒ Config
Note:
See CONFIG.md for config file details
Returns a new instance of Config.
13 14 15 16 17 |
# File 'lib/ruby_header_parser/config.rb', line 13 def initialize(config_file) erb = File.read(config_file) yaml = ERB.new(erb).result @data = YAML.safe_load(yaml, aliases: true, permitted_classes: [Regexp]) end |
Instance Attribute Details
#data ⇒ Hash (readonly)
8 9 10 |
# File 'lib/ruby_header_parser/config.rb', line 8 def data @data end |
Instance Method Details
#function_arg_pointer_hint(function_name:, pos:) ⇒ Symbol
Returns :ref, :array, :ref_array, :function, :sref, :str_array, :in_ref.
22 23 24 25 26 27 |
# File 'lib/ruby_header_parser/config.rb', line 22 def function_arg_pointer_hint(function_name:, pos:) pointer_hint = data["function"]["pointer_hint"].dig(function_name, pos) return pointer_hint.to_sym if pointer_hint :ref end |
#function_self_pointer_hint(function_name) ⇒ Symbol
Returns :ref, :raw.
31 32 33 34 35 36 |
# File 'lib/ruby_header_parser/config.rb', line 31 def function_self_pointer_hint(function_name) pointer_hint = data["function"]["pointer_hint"].dig(function_name, "self") return pointer_hint.to_sym if pointer_hint :ref end |
#should_generate_enum?(enum_name) ⇒ Boolean
Whether generate C enum to go
70 71 72 73 74 |
# File 'lib/ruby_header_parser/config.rb', line 70 def should_generate_enum?(enum_name) return false if data["enum"]["exclude_name"].any? { |format| format === enum_name } data["enum"]["include_name"].any? { |format| format === enum_name } end |
#should_generate_function?(function_name) ⇒ Boolean
Whether generate C function to go
43 44 45 46 47 |
# File 'lib/ruby_header_parser/config.rb', line 43 def should_generate_function?(function_name) return false if data["function"]["exclude_name"].any? { |format| format === function_name } data["function"]["include_name"].any? { |format| format === function_name } end |
#should_generate_struct?(struct_name) ⇒ Boolean
Whether generate C struct to go
52 53 54 55 56 |
# File 'lib/ruby_header_parser/config.rb', line 52 def should_generate_struct?(struct_name) return false if data["struct"]["exclude_name"].any? { |format| format === struct_name } data["struct"]["include_name"].any? { |format| format === struct_name } end |
#should_generate_type?(type_name) ⇒ Boolean
Whether generate C type to go
61 62 63 64 65 |
# File 'lib/ruby_header_parser/config.rb', line 61 def should_generate_type?(type_name) return false if data["type"]["exclude_name"].any? { |format| format === type_name } data["type"]["include_name"].any? { |format| format === type_name } end |