2012-11-13 01:13:39 -05:00
|
|
|
#!/usr/bin/ruby
|
2012-11-16 12:02:39 -05:00
|
|
|
# -*- coding: us-ascii -*-
|
2012-11-13 01:13:39 -05:00
|
|
|
|
|
|
|
text = ARGF.read
|
2012-11-22 03:41:19 -05:00
|
|
|
text.gsub!(/^(?!#)(.*)/){$1.upcase}
|
2012-11-13 01:13:39 -05:00
|
|
|
|
2013-01-10 01:39:55 -05:00
|
|
|
# remove comments
|
2013-03-11 01:25:06 -04:00
|
|
|
text.gsub!(%r'(?:^ *)?/\*.*?\*/\n?'m, '')
|
2013-01-10 01:39:55 -05:00
|
|
|
|
2012-11-13 01:13:39 -05:00
|
|
|
# remove the pragma declarations
|
2013-03-11 01:25:06 -04:00
|
|
|
text.gsub!(/^#pragma.*\n/, '')
|
2012-11-13 01:13:39 -05:00
|
|
|
|
|
|
|
# replace the provider section with the start of the header file
|
2012-11-16 12:02:39 -05:00
|
|
|
text.gsub!(/PROVIDER RUBY \{/, "#ifndef\t_PROBES_H\n#define\t_PROBES_H\n#define DTRACE_PROBES_DISABLED 1\n")
|
2012-11-13 01:13:39 -05:00
|
|
|
|
|
|
|
# finish up the #ifndef sandwich
|
2013-03-11 01:25:06 -04:00
|
|
|
text.gsub!(/\};/, "\n#endif\t/* _PROBES_H */")
|
2012-11-13 01:13:39 -05:00
|
|
|
|
|
|
|
text.gsub!(/__/, '_')
|
|
|
|
|
2013-03-11 01:25:06 -04:00
|
|
|
text.gsub!(/\((.+?)(?=\);)/) {
|
|
|
|
"(arg" << (0..$1.count(',')).to_a.join(", arg")
|
|
|
|
}
|
2012-11-13 01:13:39 -05:00
|
|
|
|
|
|
|
text.gsub!(/ *PROBE ([^\(]*)(\([^\)]*\));/, "#define RUBY_DTRACE_\\1_ENABLED() 0\n#define RUBY_DTRACE_\\1\\2\ do \{ \} while\(0\)")
|
2012-12-01 10:25:31 -05:00
|
|
|
puts "/* -*- c -*- */"
|
2012-11-13 01:13:39 -05:00
|
|
|
print text
|
2012-11-22 03:41:19 -05:00
|
|
|
|