Pointer support and embedded types in HIDL.
* Pointers work per transaction. Don't work
across transactions.
* ref<T> in HIDL translates to T const* in C++.
* No Java support.
* Embedded types like ref<vec<vec<int32_t>>>
or vec<ref<T>> is supported. Pointers to
pointers like ref<ref<ref<T>>> is supported.
* Array of pointers and pointer to array supported.
* Pointer inside a union is NOT supported.
Test: `mma`
Test: `make hidl_test && adb sync && adb shell hidl_test`
Note that this only works with a kernel patch.
Bug: 31300815
Bug: 31349114
Change-Id: I15b74ca74a801009cc8bdc7132bd53d0185dbcbf
diff --git a/hidl-gen_y.yy b/hidl-gen_y.yy
index 0e7483e..c494643 100644
--- a/hidl-gen_y.yy
+++ b/hidl-gen_y.yy
@@ -27,6 +27,7 @@
#include "Interface.h"
#include "Method.h"
#include "VectorType.h"
+#include "RefType.h"
#include "hidl-gen_y.h"
@@ -70,7 +71,7 @@
%token<str> STRING_LITERAL
%token<str> TYPEDEF
%token<str> UNION
-%token<str> VEC
+%token<templatedType> TEMPLATED
%token<void> ONEWAY
/* Operator precedence and associativity, as per
@@ -130,6 +131,7 @@
%union {
const char *str;
android::Type *type;
+ android::TemplatedType *templatedType;
android::FQName *fqName;
android::CompoundType *compoundType;
android::CompoundField *field;
@@ -730,7 +732,7 @@
type
: fqtype { $$ = $1; }
- | fqtype '[' const_expr ']'
+ | type '[' const_expr ']'
{
if ($1->isBinder()) {
std::cerr << "ERROR: Arrays of interface types are not supported."
@@ -745,16 +747,28 @@
$$ = new ArrayType($1, $3);
}
}
- | VEC '<' fqtype '>'
+ | TEMPLATED '<' type '>'
{
if ($3->isBinder()) {
- std::cerr << "ERROR: Vectors of interface types are not "
+ std::cerr << "ERROR: TemplatedType of interface types are not "
<< "supported. at " << @3 << "\n";
YYERROR;
}
+ $1->setElementType($3);
+ $$ = $1;
+ }
+ | TEMPLATED '<' TEMPLATED '<' type RSHIFT
+ {
+ if ($5->isBinder()) {
+ std::cerr << "ERROR: TemplatedType of interface types are not "
+ << "supported. at " << @5 << "\n";
- $$ = new VectorType($3);
+ YYERROR;
+ }
+ $3->setElementType($5);
+ $1->setElementType($3);
+ $$ = $1;
}
| annotated_compound_declaration { $$ = $1; }
| INTERFACE { $$ = new GenericBinder; }