File: enum-gen.pl

package info (click to toggle)
aranym 0.9.4beta2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 7,468 kB
  • ctags: 15,193
  • sloc: cpp: 69,881; ansic: 28,236; sh: 3,470; asm: 1,818; makefile: 706; perl: 492; objc: 225
file content (49 lines) | stat: -rwxr-xr-x 1,011 bytes parent folder | download | duplicates (4)
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
46
47
48
49
#!/usr/bin/perl
# Read original include file, and generate enumeration
# Input: <file_name>

$file = @ARGV[0];
#$start = @ARGV[1];
$prefix = "NFOSMESA_";

if ( ! defined(open(FILE, $file)) ) {
	warn "Couldn't open $file: $!\n";
	exit;
}

print "/* Generated by enum-gen.pl from $file */\n\n";

$linecount=0;
while ($ligne = <FILE>) {
	if ($ligne =~ /^GLAPI/ ) {
		while (! ($ligne =~ /\);/)) {
			chomp($ligne);
			$ligne .= " " . <FILE>;
		}
		$ligne =~ s/\t//g;
		$ligne =~ s/ \(/\(/;

		if ($ligne =~ /^GLAPI *(\w+).* G?L?APIENTRY *(\w+) *\(.*/) {
			$return_type = $1 ;
			$function_name = $2 ;
		} else {
			$return_type = "" ;
			$function_name = "" ;
		}

		$ligne =~ s/GLAPI *// ;
		$ligne =~ s/ *GLAPIENTRY// ;
		$ligne =~ s/ *APIENTRY// ;
		$ligne =~ s/;$// ;
		$function_name =~ tr/a-z/A-Z/;
		chomp($ligne);

#		print "#define\t$prefix$function_name\t$start\n";
		print "\t$prefix$function_name,\n";

		$linecount++;
#		$start++;
	}
}
close(FILE);
print "\n/* Functions generated: $linecount */\n";