enums.rb 688 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env ruby
  2. require "rtruckboris"
  3. #require File.dirname(__FILE__) + "/../lib/rtruckboris"
  4. parser = Rtruckboris::HeaderParser.new("./test_cpp", ["/usr/include"])
  5. if (!parser.parse) then
  6. puts "Whada fock??"
  7. exit
  8. end
  9. enums = parser.enums()
  10. puts "Enums number : #{enums.size}"
  11. enums.each do |e|
  12. puts "Enum Name : #{e.name}"
  13. puts "\thas name for linkage ? #{e.has_name_for_linkage}"
  14. puts "\thas linkage ? #{e.has_linkage}"
  15. puts "\ttypedef name: #{e.typedef_name}"
  16. constants = e.enum_constants
  17. print "\t\t"
  18. constants.each do |c|
  19. print "#{c.name} #{c.value} "
  20. end
  21. puts""
  22. end
  23. enums.each do |e|
  24. puts e.raw(parser.source_manager, parser.lang_opts)
  25. end