Module: NArrayType

Defined in:
ext/numo/narray/gen/narray_def.rb

Overview


Instance Method Summary collapse

Instance Method Details

#class_alias(*args) ⇒ Object



135
136
137
138
139
140
141
142
143
144
# File 'ext/numo/narray/gen/narray_def.rb', line 135

def class_alias(*args)
  case a = @opts[:class_alias]
  when Array
  when nil
    a = @opts[:class_alias] = []
  else
    a = @opts[:class_alias] = [a]
  end
  a.concat(args)
end

#math_varObject



107
108
109
# File 'ext/numo/narray/gen/narray_def.rb', line 107

def math_var
  @opts[:math_var] ||= "numo_m"+class_name+"Math"
end

#real_class_name(arg = nil) ⇒ Object



111
112
113
114
115
116
117
# File 'ext/numo/narray/gen/narray_def.rb', line 111

def real_class_name(arg=nil)
  if arg.nil?
    @opts[:real_class_name] ||= class_name
  else
    @opts[:real_class_name] = arg
  end
end

#real_ctype(arg = nil) ⇒ Object



119
120
121
122
123
124
125
# File 'ext/numo/narray/gen/narray_def.rb', line 119

def real_ctype(arg=nil)
  if arg.nil?
    @opts[:real_ctype] ||= ctype
  else
    @opts[:real_ctype] = arg
  end
end

#real_type_nameObject



131
132
133
# File 'ext/numo/narray/gen/narray_def.rb', line 131

def real_type_name
  @opts[:real_type_name] ||= real_class_name.downcase
end

#real_type_varObject



127
128
129
# File 'ext/numo/narray/gen/narray_def.rb', line 127

def real_type_var
  @opts[:real_type_var] ||= "numo_c"+real_class_name
end

#type_nameObject Also known as: tp



98
99
100
# File 'ext/numo/narray/gen/narray_def.rb', line 98

def type_name
  @opts[:type_name] ||= class_name.downcase
end

#type_varObject



103
104
105
# File 'ext/numo/narray/gen/narray_def.rb', line 103

def type_var
  @opts[:type_var] ||= "numo_c"+class_name
end

#upcast(c = nil, t = nil) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'ext/numo/narray/gen/narray_def.rb', line 146

def upcast(c=nil,t=nil)
  @opts[:upcast] ||= []
  if c
    if t
      t = "numo_c#{t}"
    else
      t = "cT"
    end
    @opts[:upcast] << "rb_hash_aset(hCast, numo_c#{c}, #{t});"
  else
    @opts[:upcast]
  end
end

#upcast_rb(c, t = nil) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'ext/numo/narray/gen/narray_def.rb', line 160

def upcast_rb(c,t=nil)
  @opts[:upcast] ||= []
  if t
    t = "numo_c#{t}"
  else
    t = "cT"
  end
  if c=="Integer"
    @opts[:upcast] << "#ifdef RUBY_INTEGER_UNIFICATION"
    @opts[:upcast] << "rb_hash_aset(hCast, rb_cInteger, #{t});"
    @opts[:upcast] << "#else"
    @opts[:upcast] << "rb_hash_aset(hCast, rb_cFixnum, #{t});"
    @opts[:upcast] << "rb_hash_aset(hCast, rb_cBignum, #{t});"
    @opts[:upcast] << "#endif"
  else
    @opts[:upcast] << "rb_hash_aset(hCast, rb_c#{c}, #{t});"
  end
end