Class: FFI::PrettyStruct
- Inherits:
-
Struct
- Object
- Struct
- FFI::PrettyStruct
show all
- Defined in:
- lib/ffi/prettystruct.rb
Overview
Direct Known Subclasses
SGC::CU::API::CUDevProp, SGC::CU::API::CudaArray3DDescriptor, SGC::CU::API::CudaArrayDescriptor, SGC::CU::API::CudaMemcpy2D, SGC::CU::API::CudaMemcpy3D, SGC::CU::API::CudaMemcpy3DPeer, SGC::Cuda::API::CudaChannelFormatDesc, SGC::Cuda::API::CudaDeviceProp, SGC::Cuda::API::CudaExtent, SGC::Cuda::API::CudaFunctionAttributes, SGC::Cuda::API::CudaMemcpy3DParms, SGC::Cuda::API::CudaMemcpy3DPeerParms, SGC::Cuda::API::CudaPitchedPtr, SGC::Cuda::API::CudaPointerAttributes, SGC::Cuda::API::CudaPos, SGC::Cuda::API::SurfaceReference, SGC::Cuda::API::TextureReference
Constant Summary
collapse
- ACCESSOR_CODE =
<<-CODE
def {name}; self[{sym}]; end
def {name}=(value) self[{sym}] = value; end
CODE
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.layout(*kvs) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/ffi/prettystruct.rb', line 13
def self.layout(*kvs)
kvs.each_slice(2) do |key, value|
eval ACCESSOR_CODE.gsub(/\{(.*?)\}/, '{name}' => key, '{sym}' => ":#{key}")
end
super
end
|
Instance Method Details
#inspect ⇒ Object
25
26
27
28
29
|
# File 'lib/ffi/prettystruct.rb', line 25
def inspect
kvs = members.zip(values)
kvs.map!{|key, value| "%s=%s" % [key, value.inspect] }
"<%s %s>" % [self.class, kvs.join(' ')]
end
|
#members ⇒ Object
21
22
23
|
# File 'lib/ffi/prettystruct.rb', line 21
def members
layout.members
end
|