Class: GirFFI::Builders::BaseArgumentBuilder
- Inherits:
-
Object
- Object
- GirFFI::Builders::BaseArgumentBuilder
show all
- 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.
Constant Summary
collapse
- KEYWORDS =
%w(
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
).freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BaseArgumentBuilder.
20
21
22
23
24
25
26
27
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 20
def initialize(var_gen, arginfo)
@var_gen = var_gen
@arginfo = arginfo
@length_arg = nil
@array_arg = nil
@is_user_data = false
@is_destroy_notifier = false
end
|
Instance Attribute Details
#arginfo ⇒ Object
Returns the value of attribute arginfo.
17
18
19
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 17
def arginfo
@arginfo
end
|
#array_arg ⇒ Object
Returns the value of attribute array_arg.
18
19
20
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 18
def array_arg
@array_arg
end
|
#length_arg ⇒ Object
Returns the value of attribute length_arg.
18
19
20
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 18
def length_arg
@length_arg
end
|
Instance Method Details
#argument_class_name ⇒ Object
TODO: Use class rather than class name
46
47
48
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 46
def argument_class_name
type_info.argument_class_name
end
|
#array_length_idx ⇒ Object
50
51
52
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 50
def array_length_idx
type_info.array_length
end
|
#array_length_parameter? ⇒ Boolean
72
73
74
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 72
def array_length_parameter?
@array_arg
end
|
#call_argument_name ⇒ Object
100
101
102
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 100
def call_argument_name
@call_argument_name ||= new_variable
end
|
#closure_idx ⇒ Object
54
55
56
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 54
def closure_idx
arginfo.closure
end
|
#destroy_idx ⇒ Object
58
59
60
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 58
def destroy_idx
arginfo.destroy
end
|
#destroy_notifier? ⇒ Boolean
80
81
82
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 80
def destroy_notifier?
@is_destroy_notifier
end
|
#direction ⇒ Object
33
34
35
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 33
def direction
@direction ||= arginfo.direction
end
|
#helper_argument? ⇒ Boolean
84
85
86
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 84
def helper_argument?
array_length_parameter? || user_data? || destroy_notifier?
end
|
#mark_as_destroy_notifier(callback_builder) ⇒ Object
67
68
69
70
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 67
def mark_as_destroy_notifier(callback_builder)
@is_destroy_notifier = true
@related_callback_builder = callback_builder
end
|
#mark_as_user_data(callback_builder) ⇒ Object
62
63
64
65
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 62
def mark_as_user_data(callback_builder)
@is_user_data = true
@related_callback_builder = callback_builder
end
|
#name ⇒ Object
29
30
31
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 29
def name
@name ||= safe(arginfo.name)
end
|
#new_variable ⇒ Object
104
105
106
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 104
def new_variable
@var_gen.new_var
end
|
#ownership_transfer ⇒ Object
88
89
90
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 88
def ownership_transfer
arginfo.ownership_transfer
end
|
#safe(name) ⇒ Object
92
93
94
95
96
97
98
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 92
def safe(name)
if KEYWORDS.include? name
"#{name}_"
else
name
end
end
|
#specialized_type_tag ⇒ Object
41
42
43
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 41
def specialized_type_tag
type_info.flattened_tag
end
|
#type_info ⇒ Object
37
38
39
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 37
def type_info
@type_info ||= arginfo.argument_type
end
|
76
77
78
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 76
def user_data?
@is_user_data
end
|