File: extract_protos.rb

package info (click to toggle)
chipmunk 6.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 1,492 kB
  • sloc: ansic: 11,062; ruby: 82; makefile: 20
file content (22 lines) | stat: -rw-r--r-- 686 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# match 0 is the whole function proto
# match 1 is either "static inline " or nil
# match 2 is the return type
# match 3 is the function symbol name
# match 4 is the arguments
PATTERN = /.*?((static inline )?(\w*\*?)\s(cp\w*)\((.*?)\))/

IO.readlines("|gcc -DNDEBUG -E include/chipmunk/chipmunk.h").each do|line|
	str = line
	
	while match = PATTERN.match(str)
		str = match.post_match
		
		proto, inline, ret, name, args = match.captures.values_at(0, 1, 2, 3, 4)
		next if ret == "return" || ret == ""
		
		inline = !!inline
		
		p({:inline => inline, :return => ret, :name => name, :args => args})
#		puts "#{name} - #{inline ? "static inline " : ""}#{ret} #{name}(#{args})"
	end
end