Class: Rubber::C_GFlags
Instance Attribute Summary
#child_names, #source_file, #source_line
Attributes inherited from C_Enum
#child_names
Instance Method Summary
collapse
#cname, #register_children
Methods inherited from C_Enum
#fullname, #same_prefix, #strip_prefixes
Instance Method Details
#code(io) ⇒ Object
18
19
|
# File 'lib/rubber/codegen/gflags.rb', line 18
def code(io)
end
|
#declare(io) ⇒ Object
20
21
|
# File 'lib/rubber/codegen/gflags.rb', line 20
def declare(io)
end
|
#default_cname ⇒ Object
23
24
25
|
# File 'lib/rubber/codegen/gflags.rb', line 23
def default_cname
"flags"+name
end
|
#doc_rd(io) ⇒ Object
26
27
28
29
|
# File 'lib/rubber/codegen/gflags.rb', line 26
def doc_rd(io)
depth = (fullname.gsub(/[^:]/,'').size >> 1)
io.puts "=#{'=' * depth} flags #{fullname}"
end
|
#get_root ⇒ Object
30
|
# File 'lib/rubber/codegen/gflags.rb', line 30
def get_root(); is_root? ? self : parent.get_root; end
|
#init ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/rubber/codegen/gflags.rb', line 7
def init()
($custom_maps[name] ||= {})["VALUE"] = "GFLAGS2RVAL(%%, #{g_type})"
($custom_maps["VALUE"] ||= {})[name] = "RVAL2GFLAGS(%%, #{g_type})"
gt = g_type.dup
gt.sub!("#{$1}_TYPE","#{$1}") if gt =~ /\A([A-Z]+)_TYPE/ 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
30
31
32
|
# File 'lib/rubber/codegen/gflags.rb', line 30
def is_root?()
not parent.respond_to?(:fullname)
end
|
#register(io, already_defined = false) ⇒ Object
33
34
35
36
37
|
# File 'lib/rubber/codegen/gflags.rb', line 33
def register(io, already_defined=false)
io.puts " G_DEF_CLASS(#{g_type}, #{name.inspect}, #{get_root.cname});"
io.puts " G_DEF_CONSTANTS(#{parent.cname}, #{g_type}, #{prefix.inspect});"
end
|