Class: Rubber::C_GEnum

Inherits:
C_Enum
  • Object
show all
Includes:
RegisterChildren
Defined in:
lib/rubber/codegen/genum.rb

Instance Attribute Summary collapse

Attributes included from RegisterChildren

#child_names, #source_file, #source_line

Attributes inherited from C_Enum

#child_names

Instance Method Summary collapse

Methods included from RegisterChildren

#cname, #register_children

Methods inherited from C_Enum

#fullname, #same_prefix, #strip_prefixes

Instance Attribute Details

#define_on_selfObject

Returns the value of attribute define_on_self.



6
7
8
# File 'lib/rubber/codegen/genum.rb', line 6

def define_on_self
  @define_on_self
end

Instance Method Details

#code(io) ⇒ Object



19
20
# File 'lib/rubber/codegen/genum.rb', line 19

def code(io)
end

#declare(io) ⇒ Object



21
22
23
# File 'lib/rubber/codegen/genum.rb', line 21

def declare(io)
 io.puts " VALUE #{cname} = Qnil;"
end

#default_cnameObject



25
26
27
# File 'lib/rubber/codegen/genum.rb', line 25

def default_cname
  "genum"+name
end

#doc_rd(io) ⇒ Object



32
33
34
35
# File 'lib/rubber/codegen/genum.rb', line 32

def doc_rd(io)
  depth = (fullname.gsub(/[^:]/,'').size >> 1)
  io.puts "=#{'=' * depth} enum #{fullname}"
end

#get_rootObject



28
# File 'lib/rubber/codegen/genum.rb', line 28

def get_root(); is_root? ? self : parent.get_root; end

#initObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rubber/codegen/genum.rb', line 8

def init()
  ($custom_maps[name] ||= {})["VALUE"] = "GENUM2RVAL(%%, #{g_type})"
  ($custom_maps["VALUE"] ||= {})[name] = "RVAL2GENUM(%%, #{g_type})"

  gt = g_type.dup
  gt.sub!("#{$1}_TYPE","#{$1}") if gt =~ /\A([A-Z]+)_TYPE/ # Strip TYPE bit
  tc = gt.downcase.capitalize.gsub(/_[a-z]/){ |i| i[1..1].upcase}

  ($custom_maps["VALUE"] ||= {})[tc] = "RVAL2GFLAGS(%%, #{g_type})"
  ($custom_maps[tc] ||= {})["VALUE"] = "GFLAGS2RVAL(%%, #{g_type})"
end

#is_root?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rubber/codegen/genum.rb', line 29

def is_root?()
  not parent.respond_to?(:fullname)
end

#register(io, already_defined = false) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/rubber/codegen/genum.rb', line 36

def register(io, already_defined=false)
    io.puts "  #{cname} = G_DEF_CLASS(#{g_type}, #{name.inspect}, #{get_root.cname});"
 if @define_on_self
   	 io.puts "  G_DEF_CONSTANTS(#{cname}, #{g_type}, #{prefix.inspect});"
 else
   	 io.puts "  G_DEF_CONSTANTS(#{parent.cname}, #{g_type}, #{prefix.inspect});"
 end
    #io.puts "  G_DEF_CONSTANTS(#{cname}, #{g_type}, #{prefix.inspect});"
#    strip = args.first.length - splits.first.length
end