13
0
livetrax/tools/process-metadata

68 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/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 (<>) {
2023-01-27 17:22:59 -05:00
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";