]>
git.saurik.com Git - apple/securityd.git/blob - src/generate.pl
7 my $disclaimer = "Automatically generated - do not edit on penalty of futility!";
11 my ($configfile, $out_h, $out_cpp, $types, $hdrpath) = @ARGV;
14 # open configuration file
15 open(CFG
, "$configfile") || die "$configfile: $!";
17 # open and load cssmtypes file
18 for my $hdrdir (split (/:/, $hdrpath)) {
19 open(TYPES
, "$hdrdir/$types") and last;
21 TYPES
or die "cannot find $types in $hdrpath: $!";
23 my $types_h = <TYPES
>;
24 close(TYPES
); $/="\n";
27 open(H
, ">$out_h") || die "$out_h: $!";
28 open(CPP
, ">$out_cpp") || die "$out_cpp: $!";
30 # cautionary headings to each file
33 // Flipping bytes for securityd transition.
40 // Flipping bytes for securityd transition.
45 # process generation instructions
53 my ($cssmName, @aliases) = split /\//;
55 print H
"void flip($cssmName &obj);\n";
56 for my $alias (@aliases) {
57 print H
"inline void flip($alias &obj) { flip(static_cast<$cssmName &>(obj)); }\n";
60 next if ($args[0] eq 'CUSTOM');
62 if ($args[0] eq '*') {
63 # extract definition from types file
64 my ($list) = $types_h =~ /{\s+([^}]+)\s+}\s*$cssmName,/;
65 die "cannot find struct definition for $cssmName in $types" unless $list;
66 @args = $list =~ /([A-Za-z0-9_]+);/gm;
69 print CPP
"void flip($cssmName &obj)\n{\n";
70 for my $field (@args) {
71 print CPP
"\tflip(obj.$field);\n";