Don't allow non-const pointers to Type instances
This makes the namespace into a read only datastructure of types
with a few methods to load types during parsing.
Bug: 24303749
Test: compiles, unittests
Change-Id: I0873e520d771b348a1a8ec9515b6e7b9a8a29298
diff --git a/generate_java_binder.cpp b/generate_java_binder.cpp
index 60c0c12..f44254f 100644
--- a/generate_java_binder.cpp
+++ b/generate_java_binder.cpp
@@ -15,7 +15,7 @@
class StubClass : public Class
{
public:
- StubClass(Type* type, Type* interfaceType);
+ StubClass(const Type* type, const Type* interfaceType);
virtual ~StubClass();
Variable* transact_code;
@@ -24,10 +24,10 @@
Variable* transact_flags;
SwitchStatement* transact_switch;
private:
- void make_as_interface(Type* interfaceType);
+ void make_as_interface(const Type* interfaceType);
};
-StubClass::StubClass(Type* type, Type* interfaceType)
+StubClass::StubClass(const Type* type, const Type* interfaceType)
:Class()
{
this->comment = "/** Local-side IPC implementation stub class. */";
@@ -97,7 +97,7 @@
}
void
-StubClass::make_as_interface(Type *interfaceType)
+StubClass::make_as_interface(const Type *interfaceType)
{
Variable* obj = new Variable(IBINDER_TYPE, "obj");
@@ -155,14 +155,14 @@
class ProxyClass : public Class
{
public:
- ProxyClass(Type* type, InterfaceType* interfaceType);
+ ProxyClass(const Type* type, const InterfaceType* interfaceType);
virtual ~ProxyClass();
Variable* mRemote;
bool mOneWay;
};
-ProxyClass::ProxyClass(Type* type, InterfaceType* interfaceType)
+ProxyClass::ProxyClass(const Type* type, const InterfaceType* interfaceType)
:Class()
{
this->modifiers = PRIVATE | STATIC;
@@ -201,7 +201,7 @@
// =================================================
static void
-generate_new_array(Type* t, StatementBlock* addTo, Variable* v,
+generate_new_array(const Type* t, StatementBlock* addTo, Variable* v,
Variable* parcel)
{
Variable* len = new Variable(INT_TYPE, v->name + "_length");
@@ -216,7 +216,7 @@
}
static void
-generate_write_to_parcel(Type* t, StatementBlock* addTo, Variable* v,
+generate_write_to_parcel(const Type* t, StatementBlock* addTo, Variable* v,
Variable* parcel, int flags)
{
if (v->dimension == 0) {
@@ -228,7 +228,7 @@
}
static void
-generate_create_from_parcel(Type* t, StatementBlock* addTo, Variable* v,
+generate_create_from_parcel(const Type* t, StatementBlock* addTo, Variable* v,
Variable* parcel, Variable** cl)
{
if (v->dimension == 0) {
@@ -240,7 +240,7 @@
}
static void
-generate_read_from_parcel(Type* t, StatementBlock* addTo, Variable* v,
+generate_read_from_parcel(const Type* t, StatementBlock* addTo, Variable* v,
Variable* parcel, Variable** cl)
{
if (v->dimension == 0) {
@@ -309,7 +309,7 @@
VariableFactory stubArgs("_arg");
arg = method->args;
while (arg != NULL) {
- Type* t = NAMES.Search(arg->type.type.data);
+ const Type* t = NAMES.Search(arg->type.type.data);
Variable* v = stubArgs.Get(t);
v->dimension = arg->type.dimension;
@@ -370,7 +370,7 @@
i = 0;
arg = method->args;
while (arg != NULL) {
- Type* t = NAMES.Search(arg->type.type.data);
+ const Type* t = NAMES.Search(arg->type.type.data);
Variable* v = stubArgs.Get(i++);
if (convert_direction(arg->direction.data) & OUT_PARAMETER) {
@@ -437,7 +437,7 @@
// the parameters
arg = method->args;
while (arg != NULL) {
- Type* t = NAMES.Search(arg->type.type.data);
+ const Type* t = NAMES.Search(arg->type.type.data);
Variable* v = new Variable(t, arg->name.data, arg->type.dimension);
int dir = convert_direction(arg->direction.data);
if (dir == OUT_PARAMETER && arg->type.dimension != 0) {
@@ -480,7 +480,7 @@
// the out/inout parameters
arg = method->args;
while (arg != NULL) {
- Type* t = NAMES.Search(arg->type.type.data);
+ const Type* t = NAMES.Search(arg->type.type.data);
Variable* v = new Variable(t, arg->name.data, arg->type.dimension);
if (convert_direction(arg->direction.data) & OUT_PARAMETER) {
generate_read_from_parcel(t, tryStatement->statements,
@@ -522,7 +522,7 @@
Class*
generate_binder_interface_class(const interface_type* iface)
{
- InterfaceType* interfaceType = static_cast<InterfaceType*>(
+ const InterfaceType* interfaceType = static_cast<const InterfaceType*>(
NAMES.Find(iface->package, iface->name.data));
// the interface class