glib-mkenums 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. #! /usr/bin/env perl
  2. use warnings;
  3. use File::Basename;
  4. use Safe;
  5. # glib-mkenums.pl
  6. # Information about the current enumeration
  7. my $flags; # Is enumeration a bitmask?
  8. my $option_underscore_name; # Overriden underscore variant of the enum name
  9. # for example to fix the cases we don't get the
  10. # mixed-case -> underscorized transform right.
  11. my $option_lowercase_name; # DEPRECATED. A lower case name to use as part
  12. # of the *_get_type() function, instead of the
  13. # one that we guess. For instance, when an enum
  14. # uses abnormal capitalization and we can not
  15. # guess where to put the underscores.
  16. my $seenbitshift; # Have we seen bitshift operators?
  17. my $enum_prefix; # Prefix for this enumeration
  18. my $enumname; # Name for this enumeration
  19. my $enumshort; # $enumname without prefix
  20. my $enumname_prefix; # prefix of $enumname
  21. my $enumindex = 0; # Global enum counter
  22. my $firstenum = 1; # Is this the first enumeration per file?
  23. my @entries; # [ $name, $val ] for each entry
  24. my $sandbox = Safe->new; # sandbox for safe evaluation of expressions
  25. sub parse_trigraph {
  26. my $opts = shift;
  27. my @opts;
  28. for $opt (split /\s*,\s*/, $opts) {
  29. $opt =~ s/^\s*//;
  30. $opt =~ s/\s*$//;
  31. my ($key,$val) = $opt =~ /(\w+)(?:=(.+))?/;
  32. defined $val or $val = 1;
  33. push @opts, $key, $val;
  34. }
  35. @opts;
  36. }
  37. sub parse_entries {
  38. my $file = shift;
  39. my $file_name = shift;
  40. my $looking_for_name = 0;
  41. while (<$file>) {
  42. # read lines until we have no open comments
  43. while (m@/\*([^*]|\*(?!/))*$@) {
  44. my $new;
  45. defined ($new = <$file>) || die "Unmatched comment in $ARGV";
  46. $_ .= $new;
  47. }
  48. # strip comments w/o options
  49. s@/\*(?!<)
  50. ([^*]+|\*(?!/))*
  51. \*/@@gx;
  52. # strip newlines
  53. s@\n@ @;
  54. # skip empty lines
  55. next if m@^\s*$@;
  56. if ($looking_for_name) {
  57. if (/^\s*(\w+)/) {
  58. $enumname = $1;
  59. return 1;
  60. }
  61. }
  62. # Handle include files
  63. if (/^\#include\s*<([^>]*)>/ ) {
  64. my $file= "../$1";
  65. open NEWFILE, $file or die "Cannot open include file $file: $!\n";
  66. if (parse_entries (\*NEWFILE, $NEWFILE)) {
  67. return 1;
  68. } else {
  69. next;
  70. }
  71. }
  72. if (/^\s*\}\s*(\w+)/) {
  73. $enumname = $1;
  74. $enumindex++;
  75. return 1;
  76. }
  77. if (/^\s*\}/) {
  78. $enumindex++;
  79. $looking_for_name = 1;
  80. next;
  81. }
  82. if (m@^\s*
  83. (\w+)\s* # name
  84. (?:=( # value
  85. \s*\w+\s*\(.*\)\s* # macro with multiple args
  86. | # OR
  87. (?:[^,/]|/(?!\*))* # anything but a comma or comment
  88. ))?,?\s*
  89. (?:/\*< # options
  90. (([^*]|\*(?!/))*)
  91. >\s*\*/)?,?
  92. \s*$
  93. @x) {
  94. my ($name, $value, $options) = ($1,$2,$3);
  95. if (!defined $flags && defined $value && $value =~ /<</) {
  96. $seenbitshift = 1;
  97. }
  98. if (defined $options) {
  99. my %options = parse_trigraph($options);
  100. if (!defined $options{skip}) {
  101. push @entries, [ $name, $value, $options{nick} ];
  102. }
  103. } else {
  104. push @entries, [ $name, $value ];
  105. }
  106. } elsif (m@^\s*\#@) {
  107. # ignore preprocessor directives
  108. } else {
  109. print STDERR "$0: $file_name:$.: Failed to parse `$_'\n";
  110. }
  111. }
  112. return 0;
  113. }
  114. sub version {
  115. print "glib-mkenums version glib-2.48.2\n";
  116. print "glib-mkenums comes with ABSOLUTELY NO WARRANTY.\n";
  117. print "You may redistribute copies of glib-mkenums under the terms of\n";
  118. print "the GNU General Public License which can be found in the\n";
  119. print "GLib source package. Sources, examples and contact\n";
  120. print "information are available at http://www.gtk.org\n";
  121. exit 0;
  122. }
  123. sub usage {
  124. print "Usage:\n";
  125. print " glib-mkenums [OPTION...] [FILES...]\n\n";
  126. print "Help Options:\n";
  127. print " -h, --help Show this help message\n\n";
  128. print "Utility Options:\n";
  129. print " --identifier-prefix <text> Identifier prefix\n";
  130. print " --symbol-prefix <text> Symbol prefix\n";
  131. print " --fhead <text> Output file header\n";
  132. print " --fprod <text> Per input file production\n";
  133. print " --ftail <text> Output file trailer\n";
  134. print " --eprod <text> Per enum text (produced prior to value iterations)\n";
  135. print " --vhead <text> Value header, produced before iterating over enum values\n";
  136. print " --vprod <text> Value text, produced for each enum value\n";
  137. print " --vtail <text> Value tail, produced after iterating over enum values\n";
  138. print " --comments <text> Comment structure\n";
  139. print " --template file Template file\n";
  140. print " -v, --version Print version informations\n\n";
  141. print "Production text substitutions:\n";
  142. print " \@EnumName\@ PrefixTheXEnum\n";
  143. print " \@enum_name\@ prefix_the_xenum\n";
  144. print " \@ENUMNAME\@ PREFIX_THE_XENUM\n";
  145. print " \@ENUMSHORT\@ THE_XENUM\n";
  146. print " \@ENUMPREFIX\@ PREFIX\n";
  147. print " \@VALUENAME\@ PREFIX_THE_XVALUE\n";
  148. print " \@valuenick\@ the-xvalue\n";
  149. print " \@valuenum\@ the integer value (limited support, Since: 2.26)\n";
  150. print " \@type\@ either enum or flags\n";
  151. print " \@Type\@ either Enum or Flags\n";
  152. print " \@TYPE\@ either ENUM or FLAGS\n";
  153. print " \@filename\@ name of current input file\n";
  154. print " \@basename\@ base name of the current input file (Since: 2.22)\n";
  155. exit 0;
  156. }
  157. # production variables:
  158. my $idprefix = ""; # "G", "Gtk", etc
  159. my $symprefix = ""; # "g", "gtk", etc, if not just lc($idprefix)
  160. my $fhead = ""; # output file header
  161. my $fprod = ""; # per input file production
  162. my $ftail = ""; # output file trailer
  163. my $eprod = ""; # per enum text (produced prior to value itarations)
  164. my $vhead = ""; # value header, produced before iterating over enum values
  165. my $vprod = ""; # value text, produced for each enum value
  166. my $vtail = ""; # value tail, produced after iterating over enum values
  167. my $comment_tmpl = ""; # comment template
  168. sub read_template_file {
  169. my ($file) = @_;
  170. my %tmpl = ('file-header', $fhead,
  171. 'file-production', $fprod,
  172. 'file-tail', $ftail,
  173. 'enumeration-production', $eprod,
  174. 'value-header', $vhead,
  175. 'value-production', $vprod,
  176. 'value-tail', $vtail,
  177. 'comment', $comment_tmpl);
  178. my $in = 'junk';
  179. open (FILE, $file) || die "Can't open $file: $!\n";
  180. while (<FILE>) {
  181. if (/^\/\*\*\*\s+(BEGIN|END)\s+([\w-]+)\s+\*\*\*\//) {
  182. if (($in eq 'junk') && ($1 eq 'BEGIN') && (exists($tmpl{$2}))) {
  183. $in = $2;
  184. next;
  185. }
  186. elsif (($in eq $2) && ($1 eq 'END') && (exists($tmpl{$2}))) {
  187. $in = 'junk';
  188. next;
  189. } else {
  190. die "Malformed template file $file\n";
  191. }
  192. }
  193. if (!($in eq 'junk')) {
  194. $tmpl{$in} .= $_;
  195. }
  196. }
  197. close (FILE);
  198. if (!($in eq 'junk')) {
  199. die "Malformed template file $file\n";
  200. }
  201. $fhead = $tmpl{'file-header'};
  202. $fprod = $tmpl{'file-production'};
  203. $ftail = $tmpl{'file-tail'};
  204. $eprod = $tmpl{'enumeration-production'};
  205. $vhead = $tmpl{'value-header'};
  206. $vprod = $tmpl{'value-production'};
  207. $vtail = $tmpl{'value-tail'};
  208. $comment_tmpl = $tmpl{'comment'};
  209. # default to C-style comments
  210. $comment_tmpl = "/* \@comment\@ */" if $comment_tmpl eq "";
  211. }
  212. if (!defined $ARGV[0]) {
  213. usage;
  214. }
  215. while ($_=$ARGV[0],/^-/) {
  216. shift;
  217. last if /^--$/;
  218. if (/^--template$/) { read_template_file (shift); }
  219. elsif (/^--identifier-prefix$/) { $idprefix = shift }
  220. elsif (/^--symbol-prefix$/) { $symprefix = shift }
  221. elsif (/^--fhead$/) { $fhead = $fhead . shift }
  222. elsif (/^--fprod$/) { $fprod = $fprod . shift }
  223. elsif (/^--ftail$/) { $ftail = $ftail . shift }
  224. elsif (/^--eprod$/) { $eprod = $eprod . shift }
  225. elsif (/^--vhead$/) { $vhead = $vhead . shift }
  226. elsif (/^--vprod$/) { $vprod = $vprod . shift }
  227. elsif (/^--vtail$/) { $vtail = $vtail . shift }
  228. elsif (/^--comments$/) { $comment_tmpl = shift }
  229. elsif (/^--help$/ || /^-h$/ || /^-\?$/) { usage; }
  230. elsif (/^--version$/ || /^-v$/) { version; }
  231. else { usage; }
  232. last if not defined($ARGV[0]);
  233. }
  234. # put auto-generation comment
  235. {
  236. my $comment = $comment_tmpl;
  237. $comment =~ s/\@comment\@/Generated data (by glib-mkenums)/;
  238. print "\n" . $comment . "\n\n";
  239. }
  240. if (length($fhead)) {
  241. my $prod = $fhead;
  242. my $base = basename ($ARGV[0]);
  243. $prod =~ s/\@filename\@/$ARGV[0]/g;
  244. $prod =~ s/\@basename\@/$base/g;
  245. $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
  246. $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
  247. chomp ($prod);
  248. print "$prod\n";
  249. }
  250. while (<>) {
  251. if (eof) {
  252. close (ARGV); # reset line numbering
  253. $firstenum = 1; # Flag to print filename at next enum
  254. }
  255. # read lines until we have no open comments
  256. while (m@/\*([^*]|\*(?!/))*$@) {
  257. my $new;
  258. defined ($new = <>) || die "Unmatched comment in $ARGV";
  259. $_ .= $new;
  260. }
  261. # strip comments w/o options
  262. s@/\*(?!<)
  263. ([^*]+|\*(?!/))*
  264. \*/@@gx;
  265. # ignore forward declarations
  266. next if /^\s*typedef\s+enum.*;/;
  267. if (m@^\s*typedef\s+enum\s*
  268. ({)?\s*
  269. (?:/\*<
  270. (([^*]|\*(?!/))*)
  271. >\s*\*/)?
  272. \s*({)?
  273. @x) {
  274. if (defined $2) {
  275. my %options = parse_trigraph ($2);
  276. next if defined $options{skip};
  277. $enum_prefix = $options{prefix};
  278. $flags = $options{flags};
  279. $option_lowercase_name = $options{lowercase_name};
  280. $option_underscore_name = $options{underscore_name};
  281. } else {
  282. $enum_prefix = undef;
  283. $flags = undef;
  284. $option_lowercase_name = undef;
  285. $option_underscore_name = undef;
  286. }
  287. if (defined $option_lowercase_name) {
  288. if (defined $option_underscore_name) {
  289. print STDERR "$0: $ARGV:$.: lowercase_name overriden with underscore_name\n";
  290. $option_lowercase_name = undef;
  291. } else {
  292. print STDERR "$0: $ARGV:$.: lowercase_name is deprecated, use underscore_name\n";
  293. }
  294. }
  295. # Didn't have trailing '{' look on next lines
  296. if (!defined $1 && !defined $4) {
  297. while (<>) {
  298. if (eof) {
  299. die "Hit end of file while parsing enum in $ARGV";
  300. }
  301. if (s/^\s*\{//) {
  302. last;
  303. }
  304. }
  305. }
  306. $seenbitshift = 0;
  307. @entries = ();
  308. # Now parse the entries
  309. parse_entries (\*ARGV, $ARGV);
  310. # figure out if this was a flags or enums enumeration
  311. if (!defined $flags) {
  312. $flags = $seenbitshift;
  313. }
  314. # Autogenerate a prefix
  315. if (!defined $enum_prefix) {
  316. for (@entries) {
  317. my $nick = $_->[2];
  318. if (!defined $nick) {
  319. my $name = $_->[0];
  320. if (defined $enum_prefix) {
  321. my $tmp = ~ ($name ^ $enum_prefix);
  322. ($tmp) = $tmp =~ /(^\xff*)/;
  323. $enum_prefix = $enum_prefix & $tmp;
  324. } else {
  325. $enum_prefix = $name;
  326. }
  327. }
  328. }
  329. if (!defined $enum_prefix) {
  330. $enum_prefix = "";
  331. } else {
  332. # Trim so that it ends in an underscore
  333. $enum_prefix =~ s/_[^_]*$/_/;
  334. }
  335. } else {
  336. # canonicalize user defined prefixes
  337. $enum_prefix = uc($enum_prefix);
  338. $enum_prefix =~ s/-/_/g;
  339. $enum_prefix =~ s/(.*)([^_])$/$1$2_/;
  340. }
  341. for $entry (@entries) {
  342. my ($name,$num,$nick) = @{$entry};
  343. if (!defined $nick) {
  344. ($nick = $name) =~ s/^$enum_prefix//;
  345. $nick =~ tr/_/-/;
  346. $nick = lc($nick);
  347. @{$entry} = ($name, $num, $nick);
  348. }
  349. }
  350. # Spit out the output
  351. if (defined $option_underscore_name) {
  352. $enumlong = uc $option_underscore_name;
  353. $enumsym = lc $option_underscore_name;
  354. $enumshort = $enumlong;
  355. $enumshort =~ s/^[A-Z][A-Z0-9]*_//;
  356. $enumname_prefix = $enumlong;
  357. $enumname_prefix =~ s/_$enumshort$//;
  358. } elsif (!$symprefix && !$idprefix) {
  359. # enumname is e.g. GMatchType
  360. $enspace = $enumname;
  361. $enspace =~ s/^([A-Z][a-z]*).*$/$1/;
  362. $enumshort = $enumname;
  363. $enumshort =~ s/^[A-Z][a-z]*//;
  364. $enumshort =~ s/([^A-Z])([A-Z])/$1_$2/g;
  365. $enumshort =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
  366. $enumshort = uc($enumshort);
  367. $enumname_prefix = $enumname;
  368. $enumname_prefix =~ s/^([A-Z][a-z]*).*$/$1/;
  369. $enumname_prefix = uc($enumname_prefix);
  370. $enumlong = uc($enspace) . "_" . $enumshort;
  371. $enumsym = lc($enspace) . "_" . lc($enumshort);
  372. if (defined($option_lowercase_name)) {
  373. $enumsym = $option_lowercase_name;
  374. }
  375. } else {
  376. $enumshort = $enumname;
  377. if ($idprefix) {
  378. $enumshort =~ s/^${idprefix}//;
  379. } else {
  380. $enumshort =~ s/^[A-Z][a-z]*//;
  381. }
  382. $enumshort =~ s/([^A-Z])([A-Z])/$1_$2/g;
  383. $enumshort =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
  384. $enumshort = uc($enumshort);
  385. $enumname_prefix = $symprefix && uc($symprefix) || uc($idprefix);
  386. $enumlong = $enumname_prefix . "_" . $enumshort;
  387. $enumsym = lc($enumlong);
  388. }
  389. if ($firstenum) {
  390. $firstenum = 0;
  391. if (length($fprod)) {
  392. my $prod = $fprod;
  393. my $base = basename ($ARGV);
  394. $prod =~ s/\@filename\@/$ARGV/g;
  395. $prod =~ s/\@basename\@/$base/g;
  396. $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
  397. $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
  398. chomp ($prod);
  399. print "$prod\n";
  400. }
  401. }
  402. if (length($eprod)) {
  403. my $prod = $eprod;
  404. $prod =~ s/\@enum_name\@/$enumsym/g;
  405. $prod =~ s/\@EnumName\@/$enumname/g;
  406. $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
  407. $prod =~ s/\@ENUMNAME\@/$enumlong/g;
  408. $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
  409. if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
  410. if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
  411. if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
  412. $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
  413. $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
  414. chomp ($prod);
  415. print "$prod\n";
  416. }
  417. if (length($vhead)) {
  418. my $prod = $vhead;
  419. $prod =~ s/\@enum_name\@/$enumsym/g;
  420. $prod =~ s/\@EnumName\@/$enumname/g;
  421. $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
  422. $prod =~ s/\@ENUMNAME\@/$enumlong/g;
  423. $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
  424. if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
  425. if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
  426. if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
  427. $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
  428. $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
  429. chomp ($prod);
  430. print "$prod\n";
  431. }
  432. if (length($vprod)) {
  433. my $prod = $vprod;
  434. my $next_num = 0;
  435. $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
  436. $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
  437. for (@entries) {
  438. my ($name,$num,$nick) = @{$_};
  439. my $tmp_prod = $prod;
  440. if ($prod =~ /\@valuenum\@/) {
  441. # only attempt to eval the value if it is requested
  442. # this prevents us from throwing errors otherwise
  443. if (defined $num) {
  444. # use sandboxed perl evaluation as a reasonable
  445. # approximation to C constant folding
  446. $num = $sandbox->reval ($num);
  447. # make sure it parsed to an integer
  448. if (!defined $num or $num !~ /^-?\d+$/) {
  449. die "Unable to parse enum value '$num'";
  450. }
  451. } else {
  452. $num = $next_num;
  453. }
  454. $tmp_prod =~ s/\@valuenum\@/$num/g;
  455. $next_num = $num + 1;
  456. }
  457. $tmp_prod =~ s/\@VALUENAME\@/$name/g;
  458. $tmp_prod =~ s/\@valuenick\@/$nick/g;
  459. if ($flags) { $tmp_prod =~ s/\@type\@/flags/g; } else { $tmp_prod =~ s/\@type\@/enum/g; }
  460. if ($flags) { $tmp_prod =~ s/\@Type\@/Flags/g; } else { $tmp_prod =~ s/\@Type\@/Enum/g; }
  461. if ($flags) { $tmp_prod =~ s/\@TYPE\@/FLAGS/g; } else { $tmp_prod =~ s/\@TYPE\@/ENUM/g; }
  462. chomp ($tmp_prod);
  463. print "$tmp_prod\n";
  464. }
  465. }
  466. if (length($vtail)) {
  467. my $prod = $vtail;
  468. $prod =~ s/\@enum_name\@/$enumsym/g;
  469. $prod =~ s/\@EnumName\@/$enumname/g;
  470. $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
  471. $prod =~ s/\@ENUMNAME\@/$enumlong/g;
  472. $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
  473. if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
  474. if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
  475. if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
  476. $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
  477. $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
  478. chomp ($prod);
  479. print "$prod\n";
  480. }
  481. }
  482. }
  483. if (length($ftail)) {
  484. my $prod = $ftail;
  485. my $base = basename ($ARGV);
  486. $prod =~ s/\@filename\@/$ARGV/g;
  487. $prod =~ s/\@basename\@/$base/g;
  488. $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
  489. $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
  490. chomp ($prod);
  491. print "$prod\n";
  492. }
  493. # put auto-generation comment
  494. {
  495. my $comment = $comment_tmpl;
  496. $comment =~ s/\@comment\@/Generated data ends here/;
  497. print "\n" . $comment . "\n\n";
  498. }