Class: Rubber::C_GObject

Inherits:
C_Class show all
Defined in:
lib/rubber/codegen/gobject.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/gobject.rb', line 6

def c_type_name
  @c_type_name
end

#gparent_classObject

Returns the value of attribute gparent_class


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

def gparent_class
  @gparent_class
end

Instance Method Details

#doc_rd(io) ⇒ Object


22
23
24
25
26
27
28
29
# File 'lib/rubber/codegen/gobject.rb', line 22

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

#feature_signal_marshal(signal, func_name) ⇒ Object


30
31
32
33
# File 'lib/rubber/codegen/gobject.rb', line 30

def feature_signal_marshal(signal,func_name)
	@signal_marshals ||= ""
	@signal_marshals << "  G_DEF_SIGNAL_FUNC(#{cname}, #{signal.inspect}, #{func_name});\n"
end

#initObject


7
8
9
# File 'lib/rubber/codegen/gobject.rb', line 7

def init()
 @c_type_name ||= 'GObject' # Default
end

#pre_func(io, func) ⇒ Object


34
35
36
37
38
39
# File 'lib/rubber/codegen/gobject.rb', line 34

def pre_func(io, func)
	if func.text =~ /_self/
   io.puts "  #{@c_type_name} *_self = ((#{@c_type_name}*)RVAL2GOBJ(self));"
	end
  super(io, func)
end

#register(io, already_defined = false) ⇒ Object

def c_type fullname.sub(/::/,'')+' *' end


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

def register(io, already_defined=false)
    if parent.child_names && parent.child_names[name]
    	io.puts "  c#{name} = #{cname};"
    else
    	io.puts "  #{cname} = G_DEF_CLASS(#{superclass}, #{name.inspect}, #{parent.cname});"
    end
    io.puts @signal_marshals if defined?(@signal_marshals)
    register_children(io)
end