Class: Dub::Function
Constant Summary
EntitiesUnescape::Decoder
Instance Attribute Summary collapse
Instance Method Summary
collapse
#unescape
Constructor Details
#initialize(parent, name, xml, prefix = '') ⇒ Function
Returns a new instance of Function.
10
11
12
13
14
15
|
# File 'lib/dub/function.rb', line 10
def initialize(parent, name, xml, prefix = '')
@parent, @name = parent, name
@xml, @prefix = xml, prefix
parse_xml
parse_template_params
end
|
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
7
8
9
|
# File 'lib/dub/function.rb', line 7
def arguments
@arguments
end
|
#gen=(value) ⇒ Object
8
9
10
|
# File 'lib/dub/function.rb', line 8
def gen=(value)
@gen = value
end
|
#is_constructor ⇒ Object
Returns the value of attribute is_constructor.
8
9
10
|
# File 'lib/dub/function.rb', line 8
def is_constructor
@is_constructor
end
|
#name ⇒ Object
Returns the value of attribute name.
8
9
10
|
# File 'lib/dub/function.rb', line 8
def name
@name
end
|
#overloaded_index ⇒ Object
Returns the value of attribute overloaded_index.
8
9
10
|
# File 'lib/dub/function.rb', line 8
def overloaded_index
@overloaded_index
end
|
#parent ⇒ Object
Returns the value of attribute parent.
7
8
9
|
# File 'lib/dub/function.rb', line 7
def parent
@parent
end
|
#prefix ⇒ Object
Returns the value of attribute prefix.
7
8
9
|
# File 'lib/dub/function.rb', line 7
def prefix
@prefix
end
|
#return_value ⇒ Object
Returns the value of attribute return_value.
7
8
9
|
# File 'lib/dub/function.rb', line 7
def return_value
@return_value
end
|
#xml ⇒ Object
Returns the value of attribute xml.
7
8
9
|
# File 'lib/dub/function.rb', line 7
def xml
@xml
end
|
Instance Method Details
#<=>(other) ⇒ Object
135
136
137
|
# File 'lib/dub/function.rb', line 135
def <=>(other)
name <=> other.name
end
|
#arg_is_list(list_position, count_position) ⇒ Object
114
115
116
117
|
# File 'lib/dub/function.rb', line 114
def arg_is_list(list_position, count_position)
@arguments[list_position ].is_list = true
@arguments[count_position].is_list_count = true
end
|
#bind(generator) ⇒ Object
22
23
24
|
# File 'lib/dub/function.rb', line 22
def bind(generator)
@gen = generator.function_generator
end
|
#call_name ⇒ Object
69
70
71
72
73
74
75
|
# File 'lib/dub/function.rb', line 69
def call_name
if klass
static? ? "#{klass.name}::#{name}" : name
else
name
end
end
|
#constructor? ⇒ Boolean
42
43
44
|
# File 'lib/dub/function.rb', line 42
def constructor?
@is_constructor
end
|
#custom_body(lang) ⇒ Object
52
53
54
|
# File 'lib/dub/function.rb', line 52
def custom_body(lang)
klass ? klass.custom_bind(lang)[self.name] : nil
end
|
#generator ⇒ Object
Also known as:
gen
30
31
32
|
# File 'lib/dub/function.rb', line 30
def generator
@gen || (@parent && @parent.function_generator)
end
|
#has_array_arguments? ⇒ Boolean
95
96
97
98
|
# File 'lib/dub/function.rb', line 95
def has_array_arguments?
return @has_array_arguments if defined?(@has_array_arguments)
@has_array_arguments = !@arguments.detect {|a| a.array_suffix }.nil?
end
|
#has_class_pointer_arguments? ⇒ Boolean
100
101
102
103
|
# File 'lib/dub/function.rb', line 100
def has_class_pointer_arguments?
return @has_class_pointer_arguments if defined?(@has_class_pointer_arguments)
@has_class_pointer_arguments = !@arguments.detect {|a| !a.is_native? && a.is_pointer? }.nil?
end
|
#has_complex_arguments? ⇒ Boolean
105
106
107
108
|
# File 'lib/dub/function.rb', line 105
def has_complex_arguments?
return @has_complex_arguments if defined?(@has_complex_arguments)
@has_complex_arguments = !(@arguments + [@return_value]).compact.detect {|a| a.complex? }.nil?
end
|
#has_default_arguments? ⇒ Boolean
90
91
92
93
|
# File 'lib/dub/function.rb', line 90
def has_default_arguments?
return @has_defaults if defined?(@has_defaults)
@has_defaults = !@arguments.detect {|a| a.has_default? }.nil?
end
|
#id_name ⇒ Object
77
78
79
|
# File 'lib/dub/function.rb', line 77
def id_name
@parent ? "#{@parent.id_name}.#{name}" : name
end
|
#inspect ⇒ Object
131
132
133
|
# File 'lib/dub/function.rb', line 131
def inspect
"#<Function #{@prefix}_#{@name}(#{@arguments.inspect[1..-2]})>"
end
|
#klass ⇒ Object
34
35
36
|
# File 'lib/dub/function.rb', line 34
def klass
@parent.kind_of?(Klass) ? @parent : nil
end
|
#member_method? ⇒ Boolean
38
39
40
|
# File 'lib/dub/function.rb', line 38
def member_method?
!klass.nil?
end
|
#method_name(overloaded_index = nil) ⇒ Object
these methods are alias to
generator methods on this object
142
143
144
|
# File 'lib/dub/function.rb', line 142
def method_name(overloaded_index = nil)
gen.method_name(self, overloaded_index)
end
|
#original_signature ⇒ Object
86
87
88
|
# File 'lib/dub/function.rb', line 86
def original_signature
unescape "#{(@xml/'definition').innerHTML}#{(@xml/'argsstring').innerHTML}"
end
|
#public? ⇒ Boolean
123
124
125
|
# File 'lib/dub/function.rb', line 123
def public?
@xml[:prot] == 'public'
end
|
#set_as_constructor ⇒ Object
17
18
19
20
|
# File 'lib/dub/function.rb', line 17
def set_as_constructor
@return_value = Argument.new(self, (Hpricot::XML("<type>#{name} *</type>")/''))
@is_constructor = true
end
|
#source ⇒ Object
81
82
83
84
|
# File 'lib/dub/function.rb', line 81
def source
loc = (@xml/'location').first.attributes
"#{loc['file'].split('/')[-3..-1].join('/')}:#{loc['line']}"
end
|
#static? ⇒ Boolean
56
57
58
|
# File 'lib/dub/function.rb', line 56
def static?
@is_static
end
|
#template? ⇒ Boolean
119
120
121
|
# File 'lib/dub/function.rb', line 119
def template?
!@template_params.nil?
end
|
#template_params ⇒ Object
127
128
129
|
# File 'lib/dub/function.rb', line 127
def template_params
@template_params
end
|
#throws? ⇒ Boolean
46
47
48
49
50
|
# File 'lib/dub/function.rb', line 46
def throws?
@throw ||= (@xml/'exceptions').innerHTML || ''
@throw = (@throw =~ /throw\s*\(\s*\)/) ? :nothing : :any
@throw != :nothing
end
|
#to_s ⇒ Object
26
27
28
|
# File 'lib/dub/function.rb', line 26
def to_s
generator.function(self)
end
|
#vararg? ⇒ Boolean
110
111
112
|
# File 'lib/dub/function.rb', line 110
def vararg?
@arguments.last && @arguments.last.vararg?
end
|