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 |
# File 'lib/ruby_header_parser/config.rb', line 13 def initialize(config_file) yaml = File.read(config_file) @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.
21 22 23 24 25 26 |
# File 'lib/ruby_header_parser/config.rb', line 21 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.
30 31 32 33 34 35 |
# File 'lib/ruby_header_parser/config.rb', line 30 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
69 70 71 72 73 |
# File 'lib/ruby_header_parser/config.rb', line 69 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
42 43 44 45 46 |
# File 'lib/ruby_header_parser/config.rb', line 42 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
51 52 53 54 55 |
# File 'lib/ruby_header_parser/config.rb', line 51 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
60 61 62 63 64 |
# File 'lib/ruby_header_parser/config.rb', line 60 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 |