Class: FFI::Pointer
- Inherits:
-
Object
- Object
- FFI::Pointer
- Defined in:
- lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#method_missing(m, *a, &b) ⇒ Object
if a missing write_type, read_type, get_array_of_type can transitively get a replacement, an alias is created and the method is called.
- #orig_method_missing ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a, &b) ⇒ Object
if a missing write_type, read_type, get_array_of_type can transitively get a replacement, an alias is created and the method is called
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 5 def method_missing(m, *a, &b) if m.to_s.match("read_") type = m.to_s.sub("read_","") type = FFI.find_type(type.to_sym) type, _ = FFI::TypeDefs.find do |(name, t)| Pointer.method_defined?("read_#{name}") if t == type end eval "alias :#{m} :read_#{type}" if type return eval "read_#{type}( *a, &b)" if type elsif m.to_s.match ("write_") type = m.to_s.sub("write_","") type = FFI.find_type(type.to_sym) type, _ = FFI::TypeDefs.find do |(name, t)| Pointer.method_defined?("write_#{name}") if t == type end eval "alias :#{m} :write_#{type}" if type return eval "write_#{type}( *a, &b)" if type elsif m.to_s.match ("get_array_of_") type = m.to_s.sub("get_array_of_","") type = FFI.find_type(type.to_sym) type, _ = FFI::TypeDefs.find do |(name, t)| Pointer.method_defined?("get_array_of_#{name}") if t == type end eval "alias :#{m} :get_array_of_#{type}" if type return eval "get_array_of_#{type}( *a, &b)" if type end orig_method_missing m, *a, &b end |
Instance Method Details
#orig_method_missing ⇒ Object
3 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 3 alias_method :orig_method_missing, :method_missing |