• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/perl -w
2
3# Generate trivial test cases to exercise result types.
4
5use strict;
6
7my @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
15my @vecLengths = (1, 2, 4);
16
17print "// -Wall -Werror\n";
18print "#pragma version(1)\n";
19print "#pragma rs java_package_name(result)\n\n";
20print "// This test case was created by $0.\n";
21print "// It exercises all legal Java-reflectable result types, so that we can ensure\n";
22print "// (a) We do not choke when compiling them\n";
23print "// (b) We reflect them correctly\n\n";
24print "// One example struct type\n";
25print "typedef struct MyStruct { float f; double d; } MyStruct;\n";
26
27foreach 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