Class: RanMethod
- Defined in:
- ext/numo/gsl/rng/parse_rng.rb
Instance Attribute Summary
Attributes inherited from ErbPP
Instance Method Summary collapse
-
#initialize(parent, tmpl, **h) ⇒ RanMethod
constructor
A new instance of RanMethod.
Methods inherited from DefMethod
#c_func, #c_iter, #c_name, #define_method_args, #id_op, #init_def, #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, #load_erb, #method_missing, #method_missing_alias, #result, #run, #set, #write
Constructor Details
#initialize(parent, tmpl, **h) ⇒ RanMethod
Returns a new instance of RanMethod.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'ext/numo/gsl/rng/parse_rng.rb', line 65 def initialize(parent,tmpl,**h) name = h[:func_name].sub(/^gsl_ran_/,"") super(parent, tmpl, name:name, **h) args = get(:args).dup unless /gsl_rng */ =~ args.shift[0] $stderr.puts h.inspect raise end if desc desc.gsub!(/@{/,"[") desc.gsub!(/@}/,"]") end case h[:func_type] when "double" set func_type_var: "cDF" set ret_class: "Float or DFloat" when "unsigned int" set func_type_var: "cUInt" set ret_class: "Integer or UInt" end @an = [] @vn = [] @vardef = [] @varconv = [] @params = [] unknown = false args.each_with_index do |tn,i| if /^\w+$/ !~ tn[1] # pointer? unknown = true break end a = "a#{i}" v = "v#{i}" case tn[0] when "double" @varconv << "#{a} = NUM2DBL(#{v});" @params << [tn[1],"Float"] when "unsigned int" @varconv << "#{a} = NUM2UINT(#{v});" @params << [tn[1],"Integer"] when "double *" # skip next else unknown = true break end @vn << v @an << a @vardef << "#{tn[0]} #{a}" end if unknown $stderr.puts "not defined: #{name} #{h[:args].inspect}" end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ErbPP