Class: Fiddle::CUnionEntity
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
CStructEntity ,
Pointer
|
|
Instance Chain:
|
|
Inherits: |
Fiddle::CStructEntity
|
Defined in: | ext/fiddle/lib/fiddle/struct.rb |
Overview
A pointer to a C union
Constant Summary
Class Method Summary
-
.size(types)
Returns the size needed for the union with the given
types
.
CStructEntity
- Inherited
.alignment, | |
.malloc | Allocates a C struct with the |
.new | Wraps the C pointer |
.size | Returns the offset for the packed sizes for the given |
Pointer
- Inherited
Instance Attribute Summary
Pointer
- Inherited
#free | Get the free function for this pointer. |
#free= | Set the free function for this pointer to |
#freed? | Returns if the free function for this pointer has been called. |
#null? | Returns |
#size | Get the size of this pointer. |
#size= | Set the size of this pointer to .size |
Instance Method Summary
-
#set_ctypes(types)
Calculate the necessary offset and for each union member with the given
types
CStructEntity
- Inherited
#[] | Fetch struct member |
#[]= | Set struct member |
#assign_names | Set the names of the |
#set_ctypes | Calculates the offsets and sizes for the given |
#to_s |
ValueUtil
- Included
PackInfo
- Included
Pointer
- Inherited
#+ | Returns a new pointer instance that has been advanced |
#+@ | Returns a new |
#- | Returns a new pointer instance that has been moved back |
#-@ | Returns a new |
#<=> | Returns -1 if less than, 0 if equal to, 1 if greater than |
#== | Returns true if |
#[] | Returns integer stored at index. |
#[]= | Set the value at |
#call_free | Call the free function for this pointer. |
#eql? | Alias for Pointer#==. |
#inspect | Returns a string formatted with an easily readable representation of the internal state of the pointer. |
#ptr | Alias for Pointer#+@. |
#ref | Alias for Pointer#-@. |
#to_i | Returns the integer memory location of this pointer. |
#to_int | Alias for Pointer#to_i. |
#to_s | Returns the pointer contents as a string. |
#to_str | Returns the pointer contents as a string. |
#to_value | Cast this pointer to a ruby object. |
Constructor Details
This class inherits a constructor from Fiddle::CStructEntity
Class Method Details
.size(types)
Returns the size needed for the union with the given types
.
Fiddle::CUnionEntity.size(
[ Fiddle::TYPE_DOUBLE,
Fiddle::TYPE_INT,
Fiddle::TYPE_CHAR,
Fiddle::TYPE_VOIDP ]) #=> 8
Instance Method Details
#set_ctypes(types)
Calculate the necessary offset and for each union member with the given types
# File 'ext/fiddle/lib/fiddle/struct.rb', line 533
def set_ctypes(types) @ctypes = types @offset = Array.new(types.length, 0) @size = self.class.size types end