Home | History | Annotate | Download | only in P_reduce_general_result
      1 #!/usr/bin/perl -w
      2 
      3 # Generate trivial test cases to exercise result types.
      4 
      5 use strict;
      6 
      7 my @basicTypes = ("half", "float", "double",
      8                   "char", "short", "int", "long",
      9                   "uchar", "ushort", "uint", "ulong",
     10                   "bool",
     11                   "MyStruct");
     12 
     13 # 1 signifies non-vector
     14 # 3 is not supported for exported types
     15 my @vecLengths = (1, 2, 4);
     16 
     17 print "// -Wall -Werror\n";
     18 print "#pragma version(1)\n";
     19 print "#pragma rs java_package_name(result)\n\n";
     20 print "// This test case was created by $0.\n";
     21 print "// It exercises all legal Java-reflectable result types, so that we can ensure\n";
     22 print "// (a) We do not choke when compiling them\n";
     23 print "// (b) We reflect them correctly\n\n";
     24 print "// One example struct type\n";
     25 print "typedef struct MyStruct { float f; double d; } MyStruct;\n";
     26 
     27 foreach my $basicType (@basicTypes) {
     28   for (my $isArray = 0; $isArray <= 1; ++$isArray) {
     29     foreach my $vecLen (@vecLengths) {
     30 
     31       # There are no bool vectors or struct vectors
     32       next if ($vecLen > 1) && (($basicType eq "bool") || ($basicType eq "MyStruct"));
     33 
     34       my $eltName = $basicType;
     35       $eltName .= $vecLen if ($vecLen > 1);
     36       my $resultName = ($isArray ? "array_${eltName}" : $eltName);
     37       my $reduceName = "my_${resultName}";
     38       my $accumName = "${reduceName}_accum";
     39       my $combName = "${reduceName}_comb";
     40       print "\n";
     41       print "#pragma rs reduce(${reduceName}) accumulator(${accumName}) combiner(${combName})\n";
     42       print "typedef ${eltName} ${resultName}[7];\n" if ($isArray);
     43       print "static void ${accumName}(${resultName} *accum, ${eltName} val) { }\n";
     44       print "static void ${combName}(${resultName} *accum, const ${resultName} *other) { }\n";
     45     }
     46   }
     47 }
     48