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



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

def code(io)
end

#declare(io) ⇒ Object



14
15
16
# File 'lib/rubber/codegen/genum.rb', line 14

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

#default_cnameObject



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

def default_cname
  "genum"+name
end

#doc_rd(io) ⇒ Object



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

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

#get_rootObject



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

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

#initObject



8
9
10
11
# File 'lib/rubber/codegen/genum.rb', line 8

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

#is_root?Boolean

Returns:

  • (Boolean)


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

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

#register(io, already_defined = false) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/rubber/codegen/genum.rb', line 29

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