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}" : ""
out.puts "module MOF"
out.inc
out.puts "class #{c.name}#{s}"
out.inc
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?
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?
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
out.end
end