Class: Genprovider::ClassInfo
- Inherits:
-
Object
- Object
- Genprovider::ClassInfo
- Defined in:
- lib/genprovider/classinfo.rb
Instance Method Summary collapse
-
#initialize(c, out) ⇒ ClassInfo
constructor
A new instance of ClassInfo.
Constructor Details
#initialize(c, out) ⇒ ClassInfo
Returns a new instance of ClassInfo.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/genprovider/classinfo.rb', line 10 def initialize c, out out.comment.comment "Class information for #{c.name}" out.comment.comment "Generated by 'genprovider' for use with ruby-sfcc" out.puts out.puts "require 'rubygems'" out.puts "require 'cim'" s = c while s.parent s = s.parent out.puts "require 'mof/#{s.name}'" end out.puts s = c.superclass ? " < #{c.superclass}" : "" # module MOF out.puts "module MOF" out.inc # class <Class> out.puts "class #{c.name}#{s}" out.inc # methods method_count = 0 s = nil c.features.each do |f| next unless f.method? if method_count == 0 out.puts "METHODS = {" out.inc end if method_count > 0 out.puts "#{s}," if s s = nil end s = "#{f.name.inspect} => { :type => #{f.type.to_sym.inspect}" unless f.parameters.empty? s << ", :parameters => {" have_in = 0 f.parameters.each do |p| next if p.out? # non-out parameters are input if have_in == 0 s << ":in => [" else s << ", " end s << "#{p.name.inspect}, #{p.type.to_sym.inspect}" have_in += 1 end s << "]" if have_in > 0 have_out = 0 f.parameters.each do |p| next unless p.out? # output parameters must have explicit qualifier if have_out == 0 s << ", " if have_in > 0 s << ":out => [" else s << ", " end s << "#{p.name.inspect}, #{p.type.to_sym.inspect}" have_out += 1 end s << "]" if have_out > 0 s << "}" end s << " }" method_count += 1 end if method_count > 0 out.puts s out.dec.puts "}" end out.end # class out.end # module end |