@@ -340,10 +340,33 @@ sub builtinmacro {
340
340
}
341
341
return (exists ($macros -> {" with_$args [0]" }) ? 1 : 0) ^ ($macname eq ' without' ? 1 : 0) if $macname eq ' with' || $macname eq ' without' ;
342
342
return (exists ($macros -> {$args [0]}) ? 1 : 0) ^ ($macname eq ' undefined' ? 1 : 0) if $macname eq ' defined' || $macname eq ' undefined' ;
343
+ if ($macname eq ' load' && ref ($macros -> {' load' }) eq ' ARRAY' ) {
344
+ my $l = $macros -> {' load' };
345
+ my $c = {};
346
+ add_macros($c , $l -> [0]-> ($args [0]));
347
+ initmacros($c , $l -> [1], $l -> [2]);
348
+ return ' ' ;
349
+ }
343
350
do_warn($config , " unsupported builtin macro $macname " );
344
351
return ' ' ;
345
352
}
346
353
354
+ sub add_macros {
355
+ my ($config , $rawmacros ) = @_ ;
356
+ $config -> {' macros' } ||= [];
357
+ return unless defined $rawmacros ;
358
+ my $macros = $config -> {' macros' };
359
+ for my $rm (split (" \n " , $rawmacros )) {
360
+ if (@$macros && $macros -> [-1] =~ / \\\z /s ) {
361
+ $macros -> [-1] = substr ($macros -> [-1], 0, -1)." \n $rm " ;
362
+ } elsif ($rm !~ / ^%/ ) {
363
+ push @$macros , $rm ;
364
+ } else {
365
+ push @$macros , " %define " .substr ($rm , 1);
366
+ }
367
+ }
368
+ }
369
+
347
370
sub initmacros {
348
371
my ($config , $macros , $macros_args ) = @_ ;
349
372
for my $line (@{$config -> {' macros' } || []}) {
@@ -412,6 +435,7 @@ my %builtin_macros = (
412
435
' dirname' => \&builtinmacro,
413
436
' shrink' => \&builtinmacro,
414
437
' suffix' => \&builtinmacro,
438
+ ' load' => \&builtinmacro,
415
439
416
440
' gsub' => \&luamacro,
417
441
' len' => \&luamacro,
@@ -714,6 +738,12 @@ sub parse {
714
738
my $multilinedefine ;
715
739
my $multilinecondition ;
716
740
my $substitute = $config -> {' substitute' };
741
+
742
+ # setup load macro if we have an include callback
743
+ if ($includecallback && !$config -> {' parsing_config' }) {
744
+ $macros {' load' } = [ $includecallback , \%macros , \%macros_args ];
745
+ }
746
+
717
747
while (1) {
718
748
my $line ;
719
749
my $doxspec = $xspec ? 1 : 0;
0 commit comments