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_closure = false
@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
76
77
78
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 76
def array_length_parameter?
@array_arg
end
|
#call_argument_name ⇒ Object
104
105
106
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 104
def call_argument_name
@call_argument_name ||= new_variable
end
|
#closure=(arg) ⇒ Object
TODO: closure unfortunately means two things in GLib: a closure argument (user_data), and the Closure class (a callable object). Make the distinction more explicit in GirFFI.
65
66
67
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 65
def closure=(arg)
@is_closure = arg
end
|
80
81
82
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 80
def closure?
@is_closure
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
84
85
86
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 84
def destroy_notifier?
@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
88
89
90
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 88
def helper_argument?
array_length_parameter? || closure? || destroy_notifier?
end
|
#mark_as_destroy_notifier(callback) ⇒ Object
TODO: Unify relationship set-up methods and improve naming. We currently have length_arg=, array_arg=, closure= and mark_as_destroy_notifier.
72
73
74
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 72
def mark_as_destroy_notifier(callback)
@destroy_notifier = callback
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
108
109
110
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 108
def new_variable
@var_gen.new_var
end
|
#ownership_transfer ⇒ Object
92
93
94
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 92
def ownership_transfer
arginfo.ownership_transfer
end
|
#safe(name) ⇒ Object
96
97
98
99
100
101
102
|
# File 'lib/gir_ffi/builders/base_argument_builder.rb', line 96
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
|