Created
October 7, 2014 14:38
-
-
Save jcward/6b91db14e5fe27d7b570 to your computer and use it in GitHub Desktop.
Script to inject Std.int on Float should be Int
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# Usage: haxe Test.hx -main Test -cpp test 2>&1 | float_fix.rb | |
# | |
# Modifies files which appear on error lines as: | |
# | |
# Test.hx:15: characters 12-18 : Float should be Int | |
# | |
# Changes Test.hx line 15 from: needInt( 4.5 - 3 ) ; | |
# to: needInt( Std.int(4.5 - 3) ) ; | |
# | |
# (does not work on multi-line errors, e.g. Test.hx:15: lines 15-16 : Float should be Int) | |
STDIN.each { |l| | |
if (l.match(/(.*?\.hx):(\d+): characters (\d+)\-(\d+) : Float should be Int/)) then | |
file, line, cs, ce = $1, $2.to_i, $3.to_i, $4.to_i | |
out = [] | |
File.read(file).split("\n").each_with_index { |b, idx| | |
if (idx+1==line) then | |
tag = "#{file}:#{line}" | |
puts "#{tag}:"+b; | |
b = b[0,cs]+"Std.int("+b[cs,ce-cs]+")"+b[ce,b.length] | |
puts "#{'-'*(tag.to_s.length)}>"+b | |
end | |
out.push(b) | |
} | |
File.open(file, 'w') { |f| f.write(out.join("\n")) } | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment