$type->{items}->{$inc->{match}} = $inc->{literal};
}
- my $v = optionValue('select', undef, $obj);
+ my $v = config::optionValue('select', undef, $obj);
$type->{select} = $v if defined($v);
#print "init $obj->{name}\n";
- foreach my $c (split /,/,optionValue('copy', undef, $obj)) {
+ foreach my $c (split /,/,config::optionValue('copy', undef, $obj)) {
my $copy = $index->{$c};
if ($copy) {
my $s = shift;
my $sname = $s->{"$s->{type}:template"};
my $def = $api->{index}->{"$s->{type}:<default>"};
- my $name = $sname ? $sname : api::optionValue('template', $s->{size} == 0 ? 'code:class=handle' : 'code:class=struct', $obj, $def);
+ my $name = $sname ? $sname : config::optionValue('template', $s->{size} == 0 ? 'code:class=handle' : 'code:class=struct', $obj, $def);
return $name;
}
my $s = shift;
my $sname = $s->{"$s->{type}:template"};
my $def = $api->{index}->{"$s->{type}:<default>"};
- my $name = $sname ? $sname : api::optionValue('template', $s->{size} == 0 ? 'code:class=handle' : 'code:class=struct', $obj, $def);
+ my $name = $sname ? $sname : config::optionValue('template', $s->{size} == 0 ? 'code:class=handle' : 'code:class=struct', $obj, $def);
print "template: $s->{name} -> $name\n" if ($api->{vars}->{verbose} > 1);
return findTemplateName($api, $name);
}
-# find value of first option of the given name
-# TBD: moved to config.pm
-sub optionValue {
- my $name = shift;
- my $or = shift;
-
- #my $match = sub { $_ =~ m/^\Q$name\E=(.*)$/on ? $1 : undef };
-
- #print "optionValue $name\n";
- foreach my $obj (@_) {
- foreach my $opt (@{$obj->{options}}) {
- #print "? $name $opt = ".($opt =~m/^\Q$name\E=(.*)$/)."\n";
- #print " = $opt\n" if ($opt =~m/^\Q$name\E=(.*)$/);
- return $1 if ($opt =~m/^\Q$name\E=(.*)$/);
- #my $x = $match->($opt);
- #return $x if defined($x);
- }
- }
- $or;
-}
-
-# look for all matching options of the given name
-# multiple objects are searched, the first one with
-# the given parameter overrides the rest.
-# name, object, object *
-sub optionValues {
- my $name = shift;
- my $rx = qr/$name/;
- my @list;
-
- foreach my $obj (@_) {
- foreach my $opt (@{$obj->{options}}) {
- push @list, $1 if ($opt =~m/^$rx=(.*)$/);
- }
- last if ($#list >= 0);
- }
- @list;
-}
-
-# same as above but doesn't short-circuit
-sub optionValuesAll {
- my $name = shift;
- my $rx = qr/$name/;
- my @list;
-
- foreach my $obj (@_) {
- foreach my $opt (@{$obj->{options}}) {
- push @list, $1 if ($opt =~m/^$rx=(.*)$/);
- }
- }
- @list;
-}
-
-# find first occurance of a flag
-# TBD: moved to config.pm
-sub optionFlag {
- my $name = shift;
-
- foreach my $obj (@_) {
- foreach my $opt (@{$obj->{options}}) {
- return 1 if ($opt eq $name);
- }
- }
- undef;
-}
-
sub findItem {
my $s = shift;
my $name = shift;
}
}
- if (optionValue('default', undef, $obj, $api->{index}->{'struct:<default>'}) eq 'all') {
+ if (config::optionValue('default', undef, $obj, $api->{index}->{'struct:<default>'}) eq 'all') {
#print "* add all items\n";
foreach my $d (@all) {
next if $visited{$d->{type}.':'.$d->{name}}++;
print "Root types\n";
foreach my $obj (@{$api->{api}}) {
- if ($obj->{type} eq 'library') {
+ # Objects that can include others
+ if ($obj->{type} =~ m/^(library|struct|union)$/) {
foreach my $inc (@{$obj->{items}}) {
next if ($inc->{type} eq 'library');
addDependencies($api, $obj, $s, $setdeps);
}
}
- } elsif ($obj->{type} =~ m/^(struct|union|call|func|enum|define)$/) {
+ }
+ # Add all matching objects
+ if ($obj->{type} =~ m/^(struct|union|call|func|enum|define)$/) {
#foreach my $n (grep { $_ =~ m/$obj->{regex}/ } keys %data) {
print "? $obj->{name}\n";
print " $m->{name}\n" if ($api->{vars}->{verbose} > 1);
foreach my $flag (@itemFlags) {
- my $value = optionFlag("$flag", $inc);
- $value = optionFlag("$flag:$m->{name}", $obj, $def) if !defined($value);
+ my $value = config::optionFlag("$flag", $inc);
+ $value = config::optionFlag("$flag:$m->{name}", $obj, $def) if !defined($value);
$m->{$flag} = $value if (defined($value));
$m->{select}->{$flag} = 1 if (defined($value));
}
foreach my $option (@itemOptions) {
- my $value = optionValue("$option", undef, $inc);
- $value = optionValue("$option:$m->{name}", undef, $obj, $def) if !defined($value);
+ my $value = config::optionValue("$option", undef, $inc);
+ $value = config::optionValue("$option:$m->{name}", undef, $obj, $def) if !defined($value);
$m->{$option} = $value if (defined($value));
$m->{select}->{$option} = 1 if (defined($value));
}
foreach my $option (@itemAnyOptions) {
- my $value = optionValue("$option", undef, $inc);
- $value = optionValue("$option:$m->{name}", undef, $obj, $def) if !defined($value);
- $value = optionValue("$option", undef, $obj, $def) if !defined($value);
+ my $value = config::optionValue("$option", undef, $inc);
+ $value = config::optionValue("$option:$m->{name}", undef, $obj, $def) if !defined($value);
+ $value = config::optionValue("$option", undef, $obj, $def) if !defined($value);
$m->{$option} = $value if (defined($value));
}
}
$s->{rename} = (first { defined $_ } $obj->{"$s->{type}:rename"}, $renameTable{identity})->($s->{name}, $s);
- $s->{access} = optionValue('access', '', $obj, $def);
- $v = optionValue('onsuccess', undef, $obj, $def);
+ $s->{access} = config::optionValue('access', '', $obj, $def);
+ $v = config::optionValue('onsuccess', undef, $obj, $def);
$s->{onsuccess} = $v if defined $v;
postProcessType($s);
#print "[$index] [$lindex] $m->{name}\n";
foreach my $flag (@itemFlags) {
- my $value = optionFlag("$flag:$m->{name}", $inc, $obj, $def);
- $value = optionFlag("$flag:$index", $inc, $obj, $def) if !defined($value);
- $value = optionFlag("$flag:$lindex", $inc, $obj, $def) if !defined($value);
+ my $value = config::optionFlag("$flag:$m->{name}", $inc, $obj, $def);
+ $value = config::optionFlag("$flag:$index", $inc, $obj, $def) if !defined($value);
+ $value = config::optionFlag("$flag:$lindex", $inc, $obj, $def) if !defined($value);
$m->{$flag} = $value if (defined($value));
$m->{select}->{$flag} = 1 if (defined($value));
}
foreach my $option (@itemOptions) {
- my $value = optionValue("$option:$m->{name}", undef, $inc, $obj, $def);
- $value = optionValue("$option:$index", undef, $inc, $obj, $def) if !defined($value);
- $value = optionValue("$option:$lindex", undef, $inc, $obj, $def) if !defined($value);
+ my $value = config::optionValue("$option:$m->{name}", undef, $inc, $obj, $def);
+ $value = config::optionValue("$option:$index", undef, $inc, $obj, $def) if !defined($value);
+ $value = config::optionValue("$option:$lindex", undef, $inc, $obj, $def) if !defined($value);
$m->{$option} = $value if (defined($value));
$m->{select}->{$option} = 1 if (defined($value));
}
foreach my $option (@itemAnyOptions) {
- my $value = optionValue("$option:$m->{name}", undef, $inc, $obj, $def);
- $value = optionValue("$option:$index", undef, $inc, $obj, $def) if !defined($value);
- $value = optionValue("$option:$lindex", undef, $inc, $obj, $def) if !defined($value);
- $value = optionValue("$option", undef, $inc, $obj, $def) if !defined($value);
+ my $value = config::optionValue("$option:$m->{name}", undef, $inc, $obj, $def);
+ $value = config::optionValue("$option:$index", undef, $inc, $obj, $def) if !defined($value);
+ $value = config::optionValue("$option:$lindex", undef, $inc, $obj, $def) if !defined($value);
+ $value = config::optionValue("$option", undef, $inc, $obj, $def) if !defined($value);
$m->{$option} = $value if (defined($value));
}
$m->{output} = 1;
}
$s->{rename} = (first { defined $_ } $inc->{"$s->{type}:rename"}, $obj->{"$s->{type}:rename"}, $renameTable{identity})->($s->{name}, $s);
- $s->{access} = optionValue('access', '', $inc, $obj, $def);
- $v = optionValue('onsuccess', undef, $inc, $obj, $def);
+ $s->{access} = config::optionValue('access', '', $inc, $obj, $def);
+ $v = config::optionValue('onsuccess', undef, $inc, $obj, $def);
$s->{onsuccess} = $v if defined ($v);
postProcessType($s);
processFields($api, $memberseen, $obj, $inc, $s, @list);
}
- if (optionValue('default', undef, $obj, $def) eq 'all') {
+ if (config::optionValue('default', undef, $obj, $def) eq 'all') {
print " + adding all fields\n" if ($api->{vars}->{verbose} > 1);
processFields($api, $memberseen, $obj, undef, $s, @{$s->{items}});
}
}
}
- if (defined optionValue('import', undef, $lib)) {
- my @x = map { split /,/,$_ } optionValues('import', $lib);
+ if (defined config::optionValue('import', undef, $lib)) {
+ my @x = map { split /,/,$_ } config::optionValues('import', $lib);
$lib->{imports} = \@x;
}
}