Module: Efl::ClassHelper
- Included in:
- EcoreEvas::REcoreEvas, Eet::REetFile, EinaHash::REinaHash, EinaList::REinaList, Evas::REvas, Evas::REvasObject
- Defined in:
- lib/efl/ffi.rb
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(m, *args, &block)
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/efl/ffi.rb', line 104
def method_missing m, *args, &block
m_s = m.to_s
if m_s =~/^(.*)=$/
m_s = $1+'_set'
args_s = '*args[0]'
elsif m_s =~/^(.*)\?$/
m_s = $1+'_get'
args_s = '*args'
else
args_s = '*args'
end
(['']+self.class.search_prefixes).each do |p|
sym = p+m_s
meth = (
if Efl::Native.respond_to? sym
sym
elsif Efl::Native.respond_to? m
m
elsif Efl::Native.respond_to? sym+'_get'
sym+'_get'
elsif Efl::Native.respond_to? m_s+'_get'
m_s+'_get'
else
nil
end
)
if not meth.nil?
self.class.class_eval "def #{m} *args, █ r=Efl::Native.#{meth}(@ptr,#{args_s}); yield r if block_given?; r; end"
return self.send m, *args, &block
end
end
Kernel.raise NameError.new "#{self.class.name} is unable to resolve #{m} within #{self.class.search_prefixes.inspect}"
end
|
Class Method Details
+ (Object) included(kls)
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/efl/ffi.rb', line 91
def self.included kls
kls.class_eval "@search_prefixes ||=[]"
kls.class_eval "def self.search_prefixes *args; @search_prefixes.unshift *args unless args.empty?; @search_prefixes; end"
kls.class_eval <<-EOF
def self.inherited sub
sub.class_eval '@search_prefixes = []'
sub.search_prefixes *self.search_prefixes
end
EOF
end
|
Instance Method Details
- (Object) ===(o)
88
|
# File 'lib/efl/ffi.rb', line 88
def === o; @ptr === o.to_ptr; end
|
- (Object) address
90
|
# File 'lib/efl/ffi.rb', line 90
def address; @ptr.address; end
|
- (Boolean) null?
89
|
# File 'lib/efl/ffi.rb', line 89
def null?; @ptr.null?; end
|
- (Object) to_a
84
|
# File 'lib/efl/ffi.rb', line 84
def to_a; [self] end
|
- (Object) to_ary
85
|
# File 'lib/efl/ffi.rb', line 85
def to_ary; [self] end
|
- (Object) to_ptr
87
|
# File 'lib/efl/ffi.rb', line 87
def to_ptr; @ptr; end
|
- (Object) to_s
86
|
# File 'lib/efl/ffi.rb', line 86
def to_s; Object.instance_method(:to_s).bind(self).call+' ['+self.to_ptr.to_s+']' end
|