Class: DataType
Overview
Constant Summary
Constants inherited
from ErbPP
ErbPP::ATTRS
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from DefMethod
#accum, #accum_binary, #accum_index, #binary, #binary2, #bit_binary, #bit_count, #bit_unary, #cast_array, #cast_func, #cond_binary, #cond_unary, #cum, #def_alias, #def_allocate, #def_id, #def_method, #def_singleton, #find_method, #find_tmpl, #math, #pow, #qsort, #set2, #store, #store_array, #store_from, #store_numeric, #unary, #unary2
Methods inherited from ErbPP
#attr_method, #attrs, #check_params, define_attrs, #has_attr?, #load_erb, #method_missing, #method_missing_alias, #parents, #result, #run, #search_method_in_parents
Constructor Details
#initialize(erb_path, type_file) ⇒ DataType
156
157
158
159
160
161
162
163
|
# File 'lib/erbpp/narray_def.rb', line 156
def initialize(erb_path, type_file)
super(nil, erb_path)
@class_alias = []
@upcast = []
@mod_var = "cT"
@tmpl_dir = File.join(File.dirname(erb_path),"tmpl")
load_type(type_file) if type_file
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class ErbPP
Instance Attribute Details
#tmpl_dir ⇒ Object
Returns the value of attribute tmpl_dir.
165
166
167
|
# File 'lib/erbpp/narray_def.rb', line 165
def tmpl_dir
@tmpl_dir
end
|
Instance Method Details
#class_alias(*args) ⇒ Object
228
229
230
|
# File 'lib/erbpp/narray_def.rb', line 228
def class_alias(*args)
@class_alias.concat(args)
end
|
#load_type(file) ⇒ Object
167
168
169
|
# File 'lib/erbpp/narray_def.rb', line 167
def load_type(file)
eval File.read(file)
end
|
#math_var ⇒ Object
200
201
202
|
# File 'lib/erbpp/narray_def.rb', line 200
def math_var
@math_var ||= "numo_m"+class_name+"Math"
end
|
#real_class_name(arg = nil) ⇒ Object
204
205
206
207
208
209
210
|
# File 'lib/erbpp/narray_def.rb', line 204
def real_class_name(arg=nil)
if arg.nil?
@real_class_name ||= class_name
else
@real_class_name = arg
end
end
|
#real_ctype(arg = nil) ⇒ Object
212
213
214
215
216
217
218
|
# File 'lib/erbpp/narray_def.rb', line 212
def real_ctype(arg=nil)
if arg.nil?
@real_ctype ||= ctype
else
@real_ctype = arg
end
end
|
#real_type_name ⇒ Object
224
225
226
|
# File 'lib/erbpp/narray_def.rb', line 224
def real_type_name
@real_type_name ||= real_class_name.downcase
end
|
#real_type_var ⇒ Object
220
221
222
|
# File 'lib/erbpp/narray_def.rb', line 220
def real_type_var
@real_type_var ||= "numo_c"+real_class_name
end
|
#type_name ⇒ Object
Also known as:
tp
191
192
193
|
# File 'lib/erbpp/narray_def.rb', line 191
def type_name
@type_name ||= class_name.downcase
end
|
#type_var ⇒ Object
196
197
198
|
# File 'lib/erbpp/narray_def.rb', line 196
def type_var
@type_var ||= "numo_c"+class_name
end
|
#upcast(c = nil, t = nil) ⇒ Object
232
233
234
235
236
237
238
239
240
241
242
243
|
# File 'lib/erbpp/narray_def.rb', line 232
def upcast(c=nil,t=nil)
if c
if t
t = "numo_c#{t}"
else
t = "cT"
end
@upcast << "rb_hash_aset(hCast, numo_c#{c}, #{t});"
else
@upcast
end
end
|
#upcast_rb(c, t = nil) ⇒ Object
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
# File 'lib/erbpp/narray_def.rb', line 245
def upcast_rb(c,t=nil)
if t
t = "numo_c#{t}"
else
t = "cT"
end
if c=="Integer"
if RUBY_VERSION >= "2.4.0"
@upcast << "rb_hash_aset(hCast, rb_cInteger, #{t});"
else
@upcast << "rb_hash_aset(hCast, rb_cFixnum, #{t});"
@upcast << "rb_hash_aset(hCast, rb_cBignum, #{t});"
end
else
@upcast << "rb_hash_aset(hCast, rb_c#{c}, #{t});"
end
end
|