-
Notifications
You must be signed in to change notification settings - Fork 2
/
shared
45 lines (34 loc) · 842 Bytes
/
shared
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env ruby
# coding: utf-8
unless ARGV.size.eql? 3 and [ "amd64", "i386" ].include? ARGV[0]
exit 1
end
fi = File.open ARGV[1], "r"
fo = File.open ARGV[2], "w"
if fi.closed? or fo.closed?
exit 1
end
struct = false
index = 0
level = 0
if ARGV[0].eql? "i386"
fi.each_line do |line|
fo.puts line
struct = true if line[/\b(struct|class)\b/]
if struct
level += line.scan(/\{/).size
level -= line.scan(/\}/).size
if line[/\*|&/]
fo.puts " /* ruby */ const void *const _shared_reserved_#{index} = reinterpret_cast<const void *const>(0);"
index += 1
end
struct = false if level.eql? 0 and line[/;/]
end
end
else
fi.each_line do |line|
fo.puts line
end
end
fi.close
fo.close