Class: Fiddle::Pointer
- Inherits:
-
Object
show all
- Defined in:
- lib/rbbcc/fiddle_ext.rb,
lib/rbbcc/clib.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *a) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/rbbcc/fiddle_ext.rb', line 25
def method_missing(name, *a)
fields = \
if self.respond_to?(:bcc_value_type) && \
self.bcc_value_type.respond_to?(:fields)
self.bcc_value_type.fields.map{|v| v.split.last.to_sym }
else
nil
end
return super unless fields
if fields.include?(name) && bcc_value.respond_to?(name)
bcc_value.send(name)
else
super
end
end
|
Instance Attribute Details
#bcc_size ⇒ Object
44
45
46
|
# File 'lib/rbbcc/fiddle_ext.rb', line 44
def bcc_size
@bcc_size || self.size
end
|
#bcc_value_type ⇒ Object
Returns the value of attribute bcc_value_type.
42
43
44
|
# File 'lib/rbbcc/fiddle_ext.rb', line 42
def bcc_value_type
@bcc_value_type
end
|
Instance Method Details
#_bcc_value ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/rbbcc/fiddle_ext.rb', line 10
def _bcc_value
if self.bcc_value_type.is_a?(Class)
return self.bcc_value_type.new(self)
end
case self.bcc_size
when Fiddle::Importer.sizeof("int")
self[0, self.size].unpack("i!").first
when Fiddle::Importer.sizeof("long")
self[0, self.size].unpack("l!").first
else
self[0, self.size].unpack("Z*").first
end
end
|
#bcc_value ⇒ Object
Also known as:
to_bcc_value
5
6
7
|
# File 'lib/rbbcc/fiddle_ext.rb', line 5
def bcc_value
@bcc_value ||= _bcc_value
end
|
185
186
187
|
# File 'lib/rbbcc/clib.rb', line 185
def
RbBCC::Clib.(self)
end
|