Add (un)linkToDeath to generated interfaces.
(un)linkToDeath is now a part of IBase, and can be
called on any generated HIDL interface. The implementation
is a no-op, except in proxy objects, which are by
definition a different process than the interface they point
to.
Since clients are not aware of the transport implementation, we must
wrap the transport-independent callback in a transport-specific
callback object. In case of binder, that object is a
hidl_binder_death_recipient.
The binder proxy object contains a list of registered death
recipients, as well as a mutex to protect access to the list.
The list is required to allow us to map back transport-independent
callbacks to transport-dependent callbacks in unlinkToDeath().
Bug: 31632518
Test: mma, hidl_test
Change-Id: I5083a8789dd706a886a8a09f8c733031a351a36a
diff --git a/hidl-gen_l.ll b/hidl-gen_l.ll
index a65bc9f..e6b4bef 100644
--- a/hidl-gen_l.ll
+++ b/hidl-gen_l.ll
@@ -34,6 +34,7 @@
#include "ArrayType.h"
#include "CompoundType.h"
#include "ConstantExpression.h"
+#include "DeathRecipientType.h"
#include "EnumType.h"
#include "HandleType.h"
#include "MemoryType.h"
@@ -111,6 +112,7 @@
"float" { SCALAR_TYPE(KIND_FLOAT); }
"double" { SCALAR_TYPE(KIND_DOUBLE); }
+"death_recipient" { yylval->type = new DeathRecipientType; return token::TYPE; }
"handle" { yylval->type = new HandleType; return token::TYPE; }
"memory" { yylval->type = new MemoryType; return token::TYPE; }
"pointer" { yylval->type = new PointerType; return token::TYPE; }