Sha256: ac58bdbee039d819905b5b3df608848d51cc0d45fa677c595aa39c8ef22e0a92
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
require 'gir_ffi' # File activesupport/lib/active_support/inflector/methods.rb, line 48 def underscore(camel_cased_word) word = camel_cased_word.to_s.dup word.gsub!(/::/, '/') word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') word.gsub!(/([a-z\d])([A-Z])/,'\1_\2') word.tr!("-", "_") word.downcase! word end namespace = 'Tracker' GirFFI.setup namespace gir = GirFFI::IRepository.default gir.require namespace, nil infos = gir.infos namespace main_file = File.open(File.join('.', "#{underscore(namespace)}.rb"), 'w') main_file.write "module #{namespace}\n" infos.each do |info| case info.info_type when :function fbuilder = GirFFI::Builder::Function.new info, Tracker::Lib main_file.write "\n" main_file.write fbuilder.generate main_file.write "\n" when :object main_file.write "class #{info.name} < #{info.parent.name}\n" info.get_methods.each do |minfo| main_file.write "\n" unless minfo.method? main_file.write "class << self\n" end if minfo.constructor? main_file.write "# This method is a constructor\n" end main_file.write "# @return [#{minfo.return_type.tag}]\n" fbuilder = GirFFI::Builder::Function.new minfo, Tracker::Lib main_file.write fbuilder.generate unless minfo.method? main_file.write "end\n" end main_file.write "\n" end main_file.write "end\n" else puts "#{info.info_type}: #{info.name}\n" end end main_file.write "end\n" main_file.close
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gir_ffi-0.0.14 | examples/print_class.rb |
gir_ffi-0.0.13 | examples/print_class.rb |
gir_ffi-0.0.12 | examples/print_class.rb |