Class: Rubber::C_GBoxed

Inherits:
C_Class show all
Defined in:
lib/rubber/codegen/gboxed.rb

Instance Attribute Summary collapse

Attributes inherited from C_Class

#child_names, #doc, #post_except, #post_func, #post_only, #pre_except, #pre_only

Attributes included from RegisterChildren

#child_names, #source_file, #source_line

Attributes inherited from C_Module

#child_names, #doc

Instance Method Summary collapse

Methods inherited from C_Class

#check_wrap_ok, #code, #declare, #default_cname, #fullname, #get_root, #is_root?

Methods included from RegisterChildren

#cname, #register_children

Methods inherited from C_Module

#add_alias, #code, #contents, #declare, #default_cname, #external?, #fullname, #get_root, #is_root?, #register_aliases

Instance Attribute Details

#c_type_nameObject

Returns the value of attribute c_type_name.



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

def c_type_name
  @c_type_name
end

#flag_nocopyObject

Returns the value of attribute flag_nocopy.



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

def flag_nocopy
  @flag_nocopy
end

#gparent_classObject

Returns the value of attribute gparent_class.



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

def gparent_class
  @gparent_class
end

Instance Method Details

#default_typeObject



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

def default_type
 c_type_name && (c_type_name + ' *') || 'gpointer'
end

#doc_rd(io) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/rubber/codegen/gboxed.rb', line 13

def doc_rd(io)
  id = fullname()
  id += " < #{gparent_class} " if gparent_class
  depth = (fullname.gsub(/[^:]/,'').size >> 1)
  io.puts "=#{'=' * depth} class #{id}"
  io.puts @doc if @doc
  contents.each { |f| f.doc_rd(io) }
end

#pre_func(io, func) ⇒ Object



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

def pre_func(io, func)
  io.puts "  #{default_type} _self = ((#{default_type})RVAL2BOXED(self, #{superclass}));" if func.text =~ /_self/
  super(io, func)
end

#register(io, already_defined = false) ⇒ Object



7
8
9
10
11
12
# File 'lib/rubber/codegen/gboxed.rb', line 7

def register(io, already_defined=false)
    io.puts "  #{cname} = G_DEF_CLASS(#{superclass}, #{name.inspect}, #{parent.cname});"
    io.puts "  rbgobj_boxed_not_copy_obj(#{superclass});" if self.flag_nocopy
    
    register_children(io)
end