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
16
17
|
# File 'lib/rubber/codegen/gflags.rb', line 16
def code(io)
end
|
#declare(io) ⇒ Object
18
19
|
# File 'lib/rubber/codegen/gflags.rb', line 18
def declare(io)
end
|
#default_cname ⇒ Object
21
22
23
|
# File 'lib/rubber/codegen/gflags.rb', line 21
def default_cname
"flags"+name
end
|
#doc_rd(io) ⇒ Object
24
25
26
27
|
# File 'lib/rubber/codegen/gflags.rb', line 24
def doc_rd(io)
depth = (fullname.gsub(/[^:]/,'').size >> 1)
io.puts "=#{'=' * depth} flags #{fullname}"
end
|
#get_root ⇒ Object
28
|
# File 'lib/rubber/codegen/gflags.rb', line 28
def get_root(); is_root? ? self : parent.get_root; end
|
#init ⇒ Object
7
8
9
10
11
12
13
14
15
|
# 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})"
end
|
#is_root? ⇒ Boolean
28
29
30
|
# File 'lib/rubber/codegen/gflags.rb', line 28
def is_root?()
not parent.respond_to?(:fullname)
end
|
#register(io, already_defined = false) ⇒ Object
31
32
33
34
35
|
# File 'lib/rubber/codegen/gflags.rb', line 31
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
|