Class: GirFFI::Builders::BaseArgumentBuilder
- Inherits:
-
Object
- Object
- GirFFI::Builders::BaseArgumentBuilder
- Defined in:
- lib/gir_ffi/builders/base_argument_builder.rb
Overview
Abstract parent class of the argument building classes. These classes are used by FunctionBuilder to create the code that processes each argument before and after the actual function call.
Direct Known Subclasses
ArgumentBuilder, CallbackArgumentBuilder, CallbackReturnValueBuilder, ErrorArgumentBuilder, ReturnValueBuilder
Constant Summary collapse
- KEYWORDS =
[ "alias", "and", "begin", "break", "case", "class", "def", "do", "else", "elsif", "end", "ensure", "false", "for", "if", "in", "module", "next", "nil", "not", "or", "redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless", "until", "when", "while", "yield" ]
Instance Attribute Summary collapse
-
#arginfo ⇒ Object
readonly
Returns the value of attribute arginfo.
-
#array_arg ⇒ Object
Returns the value of attribute array_arg.
-
#is_closure ⇒ Object
Returns the value of attribute is_closure.
-
#length_arg ⇒ Object
Returns the value of attribute length_arg.
Instance Method Summary collapse
-
#argument_class_name ⇒ Object
TODO: Use class rather than class name.
- #array_length_idx ⇒ Object
- #callarg ⇒ Object
- #direction ⇒ Object
-
#initialize(var_gen, arginfo) ⇒ BaseArgumentBuilder
constructor
A new instance of BaseArgumentBuilder.
- #name ⇒ Object
- #new_variable ⇒ Object
- #safe(name) ⇒ Object
- #specialized_type_tag ⇒ Object
- #type_info ⇒ Object
Constructor Details
#initialize(var_gen, arginfo) ⇒ BaseArgumentBuilder
Returns a new instance of BaseArgumentBuilder.
19 20 21 22 23 24 25 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 19 def initialize var_gen, arginfo @var_gen = var_gen @arginfo = arginfo @length_arg = nil @array_arg = nil @is_closure = false end |
Instance Attribute Details
#arginfo ⇒ Object (readonly)
Returns the value of attribute arginfo.
15 16 17 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 15 def arginfo @arginfo end |
#array_arg ⇒ Object
Returns the value of attribute array_arg.
16 17 18 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 16 def array_arg @array_arg end |
#is_closure ⇒ Object
Returns the value of attribute is_closure.
17 18 19 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 17 def is_closure @is_closure end |
#length_arg ⇒ Object
Returns the value of attribute length_arg.
16 17 18 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 16 def length_arg @length_arg end |
Instance Method Details
#argument_class_name ⇒ Object
TODO: Use class rather than class name
44 45 46 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 44 def argument_class_name type_info.argument_class_name end |
#array_length_idx ⇒ Object
48 49 50 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 48 def array_length_idx type_info.array_length end |
#callarg ⇒ Object
60 61 62 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 60 def callarg @callarg ||= new_variable end |
#direction ⇒ Object
31 32 33 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 31 def direction @direction ||= arginfo.direction end |
#name ⇒ Object
27 28 29 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 27 def name @name ||= safe(arginfo.name) end |
#new_variable ⇒ Object
64 65 66 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 64 def new_variable @var_gen.new_var end |
#safe(name) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 52 def safe name if KEYWORDS.include? name "#{name}_" else name end end |
#specialized_type_tag ⇒ Object
39 40 41 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 39 def specialized_type_tag type_info.flattened_tag end |
#type_info ⇒ Object
35 36 37 |
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 35 def type_info @type_info ||= arginfo.argument_type end |