Class: CShadow::BooleanAttribute

Inherits:
CNativeAttribute show all
Defined in:
lib/cgen/attribute.rb

Instance Attribute Summary

Attributes inherited from CNativeAttribute

#ctype

Attributes inherited from Attribute

#cdecl, #check, #cvar, #dump, #free, #init, #load, #mark, #owner_class, #persists, #reader, #var, #writer

Instance Method Summary collapse

Methods inherited from CNativeAttribute

match

Methods inherited from Attribute

inherited, #inspect, match

Constructor Details

#initialize(*args) ⇒ BooleanAttribute

Returns a new instance of BooleanAttribute.



312
313
314
315
316
317
318
319
# File 'lib/cgen/attribute.rb', line 312

def initialize(*args)
  super
  @cdecl = @cdecl.sub(@match[1], "int")
  @reader = "result = shadow->#{@cvar} ? Qtrue : Qfalse"
  @writer = "shadow->#{@cvar} = RTEST(arg)"   # type conversion
  @dump = "rb_ary_push(result, shadow->#{@cvar} ? Qtrue : Qfalse)"
  @load = "tmp = rb_ary_shift(from_array); shadow->#{@cvar} = RTEST(tmp)"
end