#!/usr/bin/perl -w

if ($#ARGV == -1) {
    print STDERR "No codename provided\n";
    exit 0
}

$codename = $ARGV[0];
if ($codename eq "") {
    print STDERR "Bad codename provided\n";
    exit 0
}

print "// \n";
print "// Automatically Generated File\n";
print "// DO NOT EDIT\n";
print "// \n";
print "\n";
print "uint32 $codename\_uCodeArr[] = {\n  ";

$started = 0;
while (<STDIN>) {
    next unless /\.[0-9]+ ([A-F0-9]+) .*/;
    print ",\n  " if $started;
    print "0x$1";
    $started = 1;
}

print "\n};\n\n";
print "struct uEng_uCodeInfo $codename\_uCode = { \n";
print "    $codename\_uCodeArr, \n";
print "    sizeof($codename\_uCodeArr) / 4 \n";
print "}; \n";
print "\n";
