File: extract_protos.rb

package info (click to toggle)
chipmunk 7.0.3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,968 kB
  • sloc: ansic: 29,265; objc: 4,313; ruby: 409; makefile: 10; sh: 1
file content (22 lines) | stat: -rw-r--r-- 689 bytes parent folder | download | duplicates (3)
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