Class: GirFFI::BaseArgumentBuilder
- Inherits:
-
Object
- Object
- GirFFI::BaseArgumentBuilder
- Defined in:
- lib/gir_ffi/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
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" ]
- TAG_TO_WRAPPER_CLASS_MAP =
{ :array => 'GLib::Array', :byte_array => 'GLib::ByteArray', :c => 'GLib::SizedArray', :callback => 'GirFFI::Callback', :error => 'GLib::Error', :ghash => 'GLib::HashTable', :glist => 'GLib::List', :gslist => 'GLib::SList', :ptr_array => 'GLib::PtrArray', :strv => 'GLib::Strv', :utf8 => 'GirFFI::InPointer', :void => 'GirFFI::InPointer', :zero_terminated => 'GirFFI::ZeroTerminated' }
Instance Attribute Summary collapse
-
#array_arg ⇒ Object
Returns the value of attribute array_arg.
-
#length_arg ⇒ Object
Returns the value of attribute length_arg.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#retname ⇒ Object
readonly
Returns the value of attribute retname.
Instance Method Summary collapse
-
#argument_class_name ⇒ Object
TODO: Use class rather than class name.
- #array_size ⇒ Object
- #callarg ⇒ Object
- #cleanup ⇒ Object
- #elm_t ⇒ Object
- #inarg ⇒ Object
-
#initialize(var_gen, name, typeinfo, direction) ⇒ BaseArgumentBuilder
constructor
A new instance of BaseArgumentBuilder.
- #post ⇒ Object
- #pre ⇒ Object
- #retval ⇒ Object
- #safe(name) ⇒ Object
- #specialized_type_tag ⇒ Object
- #subtype_tag_or_class_name ⇒ Object
- #type_info ⇒ Object
Constructor Details
#initialize(var_gen, name, typeinfo, direction) ⇒ BaseArgumentBuilder
Returns a new instance of BaseArgumentBuilder.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 18 def initialize var_gen, name, typeinfo, direction @var_gen = var_gen @typeinfo = typeinfo @direction = direction @name = safe(name) @inarg = nil @retname = nil @length_arg = nil @array_arg = nil end |
Instance Attribute Details
#array_arg ⇒ Object
Returns the value of attribute array_arg.
16 17 18 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 16 def array_arg @array_arg end |
#length_arg ⇒ Object
Returns the value of attribute length_arg.
16 17 18 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 16 def length_arg @length_arg end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 14 def name @name end |
#retname ⇒ Object (readonly)
Returns the value of attribute retname.
14 15 16 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 14 def retname @retname end |
Instance Method Details
#argument_class_name ⇒ Object
TODO: Use class rather than class name
57 58 59 60 61 62 63 64 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 57 def argument_class_name case (tag = type_info.flattened_tag) when :struct, :union, :object, :interface, :enum, :flags type_info.interface_type_name else TAG_TO_WRAPPER_CLASS_MAP[tag] end end |
#array_size ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 74 def array_size if @length_arg @length_arg.retname else type_info.array_fixed_size end end |
#callarg ⇒ Object
98 99 100 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 98 def callarg @callarg ||= @var_gen.new_var end |
#cleanup ⇒ Object
110 111 112 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 110 def cleanup [] end |
#elm_t ⇒ Object
70 71 72 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 70 def elm_t type_info.element_type.inspect end |
#inarg ⇒ Object
90 91 92 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 90 def inarg @array_arg.nil? ? @inarg : nil end |
#post ⇒ Object
106 107 108 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 106 def post [] end |
#pre ⇒ Object
102 103 104 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 102 def pre [] end |
#retval ⇒ Object
94 95 96 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 94 def retval @array_arg.nil? ? retname : nil end |
#safe(name) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 82 def safe name if KEYWORDS.include? name "#{name}_" else name end end |
#specialized_type_tag ⇒ Object
36 37 38 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 36 def specialized_type_tag type_info.flattened_tag end |
#subtype_tag_or_class_name ⇒ Object
66 67 68 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 66 def subtype_tag_or_class_name type_info.subtype_tag_or_class_name end |
#type_info ⇒ Object
32 33 34 |
# File 'lib/gir_ffi/base_argument_builder.rb', line 32 def type_info @typeinfo end |