Module: NArrayType

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

Overview


Instance Method Summary collapse

Instance Method Details

#class_alias(*args) ⇒ Object



141
142
143
144
145
146
147
148
149
150
# File 'ext/cumo/narray/gen/narray_def.rb', line 141

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



113
114
115
# File 'ext/cumo/narray/gen/narray_def.rb', line 113

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

#real_class_name(arg = nil) ⇒ Object



117
118
119
120
121
122
123
# File 'ext/cumo/narray/gen/narray_def.rb', line 117

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



125
126
127
128
129
130
131
# File 'ext/cumo/narray/gen/narray_def.rb', line 125

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

#real_type_nameObject



137
138
139
# File 'ext/cumo/narray/gen/narray_def.rb', line 137

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

#real_type_varObject



133
134
135
# File 'ext/cumo/narray/gen/narray_def.rb', line 133

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

#type_nameObject Also known as: tp



104
105
106
# File 'ext/cumo/narray/gen/narray_def.rb', line 104

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

#type_varObject



109
110
111
# File 'ext/cumo/narray/gen/narray_def.rb', line 109

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

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



152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'ext/cumo/narray/gen/narray_def.rb', line 152

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

#upcast_rb(c, t = nil) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'ext/cumo/narray/gen/narray_def.rb', line 166

def upcast_rb(c, t=nil)
  @opts[:upcast] ||= []
  if t
    t = "cumo_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