Class: Store

Inherits:
DefMethod show all
Defined in:
ext/numo/narray/gen/narray_def.rb

Overview


Direct Known Subclasses

StoreArray, StoreNum

Instance Attribute Summary

Attributes inherited from ErbPP

#children, #parent

Instance Method Summary collapse

Methods inherited from DefMethod

#c_iter, #c_name, #define_method_args, #id_op, #init_def, #initialize, #op_map, #singleton

Methods included from DeclMethod

#def_alias, #def_alloc_func, #def_const, #def_method, #def_module_function, #def_singleton_method, #undef_alloc_func, #undef_method, #undef_singleton_method

Methods inherited from ErbPP

#add_child, #description, #find, #find_tmpl, #get, #init_def, #initialize, #load_erb, #method_missing, #method_missing_alias, #result, #run, #set, #write

Constructor Details

This class inherits a constructor from DefMethod

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ErbPP

Instance Method Details

#c_func(n = nil) ⇒ Object



224
225
226
# File 'ext/numo/narray/gen/narray_def.rb', line 224

def c_func(n=nil)
  "#{parent.parent.name}_store_#{name}"
end

#condition(klass) ⇒ Object



228
229
230
# File 'ext/numo/narray/gen/narray_def.rb', line 228

def condition(klass)
  "#{klass}==#{type_var}"
end

#extract_data(ptr, pos, x) ⇒ Object



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'ext/numo/narray/gen/narray_def.rb', line 232

def extract_data(ptr,pos,x)
  case type_name
  when "Bit"
    "{BIT_DIGIT b; LOAD_BIT(#{ptr},#{pos},b); x = m_from_sint(b);}"
  when "RObject"
    "#{x} = m_num_to_data(*(#{dtype}*)(#{ptr}+#{pos}))"
  when /Complex/
    "{#{dtype} *p = (#{dtype}*)(#{ptr}+#{pos}); #{x} = c_new(REAL(*p),IMAG(*p));}"
  when /Float/
    "#{x} = m_from_real(*(#{dtype}*)(#{ptr}+#{pos}))"
  when /UInt64/
    "#{x} = m_from_uint64(*(#{dtype}*)(#{ptr}+#{pos}))"
  when /UInt32/
    "#{x} = m_from_uint32(*(#{dtype}*)(#{ptr}+#{pos}))"
  when /Int64/
    "#{x} = m_from_int64(*(#{dtype}*)(#{ptr}+#{pos}))"
  when /Int32/
    "#{x} = m_from_int32(*(#{dtype}*)(#{ptr}+#{pos}))"
  when /Int/
    "#{x} = m_from_sint(*(#{dtype}*)(#{ptr}+#{pos}))"
  else
    raise "unknown type: #{type_name}"
  end
end