summaryrefslogtreecommitdiffstats
path: root/generate_java_binder.cpp
diff options
context:
space:
mode:
authorCasey Dahlin <sadmac@google.com>2015-09-28 19:20:50 -0700
committerCasey Dahlin <sadmac@google.com>2015-09-29 10:56:47 -0700
commitbc7a50a9bb4b97affc05f872d0cce02e54861e23 (patch)
tree8795483d886baed4498b37a468c99ab816bd3b4c /generate_java_binder.cpp
parentb2116869ba878222d607807be594366b6e9392f7 (diff)
downloadandroid_system_tools_aidl-bc7a50a9bb4b97affc05f872d0cce02e54861e23.tar.gz
android_system_tools_aidl-bc7a50a9bb4b97affc05f872d0cce02e54861e23.tar.bz2
android_system_tools_aidl-bc7a50a9bb4b97affc05f872d0cce02e54861e23.zip
Turn arg_type into a class called AIDLArgument
We also get rid of its linked list property and use std::vector to store lists of arguments in method_type. We still expose most of the same data publicly, but there's going to be a lot of high-touch changes coming with this transition so it's better to break the change set here. Change-Id: I71a3dfe1e0fb9cd9437ec81de681b72137fc02cf Test: unit tests Bug: 24410295 Signed-off-by: Casey Dahlin <sadmac@google.com>
Diffstat (limited to 'generate_java_binder.cpp')
-rw-r--r--generate_java_binder.cpp27
1 files changed, 6 insertions, 21 deletions
diff --git a/generate_java_binder.cpp b/generate_java_binder.cpp
index e033fe8..b5aa0ce 100644
--- a/generate_java_binder.cpp
+++ b/generate_java_binder.cpp
@@ -266,7 +266,6 @@ generate_method(const method_type* method, Class* interface,
StubClass* stubClass, ProxyClass* proxyClass, int index,
JavaTypeNamespace* types)
{
- arg_type* arg;
int i;
bool hasOutParams = false;
@@ -292,12 +291,10 @@ generate_method(const method_type* method, Class* interface,
decl->returnTypeDimension = method->type.dimension;
decl->name = method->name.data;
- arg = method->args;
- while (arg != NULL) {
+ for (const std::unique_ptr<AidlArgument>& arg : *method->args) {
decl->parameters.push_back(new Variable(
types->Find(arg->type.type.data), arg->name.data,
arg->type.dimension));
- arg = arg->next;
}
decl->exceptions.push_back(types->RemoteExceptionType());
@@ -317,8 +314,7 @@ generate_method(const method_type* method, Class* interface,
// args
Variable* cl = NULL;
VariableFactory stubArgs("_arg");
- arg = method->args;
- while (arg != NULL) {
+ for (const std::unique_ptr<AidlArgument>& arg : *method->args) {
const Type* t = types->Find(arg->type.type.data);
Variable* v = stubArgs.Get(t);
v->dimension = arg->type.dimension;
@@ -343,8 +339,6 @@ generate_method(const method_type* method, Class* interface,
}
realCall->arguments.push_back(v);
-
- arg = arg->next;
}
// the real call
@@ -378,8 +372,7 @@ generate_method(const method_type* method, Class* interface,
// out parameters
i = 0;
- arg = method->args;
- while (arg != NULL) {
+ for (const std::unique_ptr<AidlArgument>& arg : *method->args) {
const Type* t = types->Find(arg->type.type.data);
Variable* v = stubArgs.Get(i++);
@@ -389,8 +382,6 @@ generate_method(const method_type* method, Class* interface,
Type::PARCELABLE_WRITE_RETURN_VALUE);
hasOutParams = true;
}
-
- arg = arg->next;
}
// return true
@@ -405,12 +396,10 @@ generate_method(const method_type* method, Class* interface,
proxy->returnTypeDimension = method->type.dimension;
proxy->name = method->name.data;
proxy->statements = new StatementBlock;
- arg = method->args;
- while (arg != NULL) {
+ for (const std::unique_ptr<AidlArgument>& arg : *method->args) {
proxy->parameters.push_back(new Variable(
types->Find(arg->type.type.data), arg->name.data,
arg->type.dimension));
- arg = arg->next;
}
proxy->exceptions.push_back(types->RemoteExceptionType());
proxyClass->elements.push_back(proxy);
@@ -447,8 +436,7 @@ generate_method(const method_type* method, Class* interface,
1, new LiteralExpression("DESCRIPTOR")));
// the parameters
- arg = method->args;
- while (arg != NULL) {
+ for (const std::unique_ptr<AidlArgument>& arg : *method->args) {
const Type* t = types->Find(arg->type.type.data);
Variable* v = new Variable(t, arg->name.data, arg->type.dimension);
int dir = convert_direction(arg->direction.data);
@@ -465,7 +453,6 @@ generate_method(const method_type* method, Class* interface,
else if (dir & IN_PARAMETER) {
generate_write_to_parcel(t, tryStatement->statements, v, _data, 0);
}
- arg = arg->next;
}
// the transact call
@@ -490,15 +477,13 @@ generate_method(const method_type* method, Class* interface,
}
// the out/inout parameters
- arg = method->args;
- while (arg != NULL) {
+ for (const std::unique_ptr<AidlArgument>& arg : *method->args) {
const Type* t = types->Find(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,
v, _reply, &cl);
}
- arg = arg->next;
}
finallyStatement->statements->Add(new MethodCall(_reply, "recycle"));