Class: Rubber::C_Class
- Includes:
- RegisterChildren
- Defined in:
- lib/rubber/codegen/class.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#child_names ⇒ Object
readonly
Returns the value of attribute child_names.
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#post_except ⇒ Object
Returns the value of attribute post_except.
-
#post_func(io, func) ⇒ Object
Returns the value of attribute post_func.
-
#post_only ⇒ Object
Returns the value of attribute post_only.
-
#pre_except ⇒ Object
Returns the value of attribute pre_except.
-
#pre_func(io, func) ⇒ Object
Returns the value of attribute pre_func.
-
#pre_only ⇒ Object
Returns the value of attribute pre_only.
Attributes included from RegisterChildren
Instance Method Summary collapse
- #check_wrap_ok(io, fn, where) ⇒ Object
- #code(io) ⇒ Object
- #declare(io) ⇒ Object
- #default_cname ⇒ Object
- #doc_rd(io) ⇒ Object
- #fullname ⇒ Object
- #get_root ⇒ Object
- #is_root? ⇒ Boolean
- #register(io, already_defined = false) ⇒ Object
Methods included from RegisterChildren
Methods inherited from C_Module
#add_alias, #contents, #external?, #register_aliases
Instance Attribute Details
#child_names ⇒ Object (readonly)
Returns the value of attribute child_names.
8 9 10 |
# File 'lib/rubber/codegen/class.rb', line 8 def child_names @child_names end |
#doc ⇒ Object
Returns the value of attribute doc.
7 8 9 |
# File 'lib/rubber/codegen/class.rb', line 7 def doc @doc end |
#post_except ⇒ Object
Returns the value of attribute post_except.
7 8 9 |
# File 'lib/rubber/codegen/class.rb', line 7 def post_except @post_except end |
#post_func(io, func) ⇒ Object
Returns the value of attribute post_func.
7 8 9 |
# File 'lib/rubber/codegen/class.rb', line 7 def post_func @post_func end |
#post_only ⇒ Object
Returns the value of attribute post_only.
7 8 9 |
# File 'lib/rubber/codegen/class.rb', line 7 def post_only @post_only end |
#pre_except ⇒ Object
Returns the value of attribute pre_except.
7 8 9 |
# File 'lib/rubber/codegen/class.rb', line 7 def pre_except @pre_except end |
#pre_func(io, func) ⇒ Object
Returns the value of attribute pre_func.
7 8 9 |
# File 'lib/rubber/codegen/class.rb', line 7 def pre_func @pre_func end |
#pre_only ⇒ Object
Returns the value of attribute pre_only.
7 8 9 |
# File 'lib/rubber/codegen/class.rb', line 7 def pre_only @pre_only end |
Instance Method Details
#check_wrap_ok(io, fn, where) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rubber/codegen/class.rb', line 52 def check_wrap_ok(io, fn, where) case where when :pre code = @pre_func only = @pre_only except = @pre_except when :post code = @post_func only = @post_only except = @post_except end if code && ! fn.singleton return if only && ! only.empty? && ! only.include?(fn.name) return if except && except.include?(fn.name) io.puts code end end |
#code(io) ⇒ Object
29 30 31 |
# File 'lib/rubber/codegen/class.rb', line 29 def code(io) contents .each { |f| f.code(io) } end |
#declare(io) ⇒ Object
32 33 34 35 |
# File 'lib/rubber/codegen/class.rb', line 32 def declare(io) io.puts "static VALUE #{cname};"; contents .each { |f| f.declare(io) } end |
#default_cname ⇒ Object
49 50 51 |
# File 'lib/rubber/codegen/class.rb', line 49 def default_cname "c#{name}" end |
#doc_rd(io) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rubber/codegen/class.rb', line 17 def doc_rd(io) id = fullname() id += " < #{superclass}" if superclass depth = (fullname.gsub(/[^:]/,'').size >> 1) io.puts "=#{'=' * depth} class #{id}" io.puts @doc if @doc contents.each { |f| f.doc_rd(io) } end |
#fullname ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/rubber/codegen/class.rb', line 10 def fullname() if parent and parent.respond_to?(:fullname) "#{parent.fullname}::#{name}" else name end end |
#get_root ⇒ Object
25 |
# File 'lib/rubber/codegen/class.rb', line 25 def get_root(); is_root? ? self : parent.get_root; end |
#is_root? ⇒ Boolean
26 27 28 |
# File 'lib/rubber/codegen/class.rb', line 26 def is_root?() not parent.respond_to?(:fullname) end |
#register(io, already_defined = false) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubber/codegen/class.rb', line 36 def register(io, already_defined=false) if parent.child_names && parent.child_names[name] io.puts " c#{name} = #{cname};" else if parent and parent.cname io.puts " #{cname} = rb_define_class_under(#{parent.cname}, #{name.inspect}, #{Rubber.find_class(superclass) || 'rb_cObject'});" else io.puts " #{cname} = rb_define_class(#{name.inspect}, #{Rubber.find_class(superclass) || 'rb_cObject'});" end end register_children(io) end |