ardour/tools/process-metadata

68 lines
1.1 KiB
Perl
Executable File

#!/bin/perl
$in_section = 0;
$in_heading = 0;
$section = "";
$heading = "";
$accumulated = "";
print "
/* This file was generated by tools/process-metadata. DO NOT EDIT THIS FILE. EVER! */
void
UIConfiguration::build_metadata ()
{
#define VAR_META(name,...) { char const * _x[] { __VA_ARGS__ }; all_metadata.insert (std::make_pair<std::string,Metadata> ((name), PBD::upcase (_x))); }\n\n";
while (<>) {
if (/^#/) {
next;
}
if (/\[SECTION:/) {
chop;
s/\[SECTION://;
s/\]//;
$section = $_;
$in_section = 1;
$in_heading = 0;
$heading = "";
$accumulated = "";
next;
}
if (!$in_section) {
next;
}
if (/\[[a-z0-9_-]+\]/) {
if ($accumulated ne "") {
@arr = split (/\s+/, $accumulated);
print "\tVAR_META (X_(\"$heading\"), ";
for my $word (@arr) {
if ($word ne "") {
print "_(\"$word\"), ";
}
}
print " NULL);\n";
$accumulated = "";
}
chop;
chop;
$heading = substr ($_, 1);
$in_heading = 1;
next;
}
if (!$in_heading) {
next;
}
$accumulated .= $_;
}
print "\n}\n";