From 4742c0cd30b6e76361cc72182339f0a30efceee2 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Wed, 14 Sep 2011 21:12:28 -0700 Subject: Generate fallthrough for unhandled actions in RPC methods. Change-Id: I2913b20577dd47e000aa6b7403352ee492e6191a --- tools/aidl/generate_java_rpc.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tools/aidl/generate_java_rpc.cpp') diff --git a/tools/aidl/generate_java_rpc.cpp b/tools/aidl/generate_java_rpc.cpp index 456a950e20d0..69e9c3df4cec 100644 --- a/tools/aidl/generate_java_rpc.cpp +++ b/tools/aidl/generate_java_rpc.cpp @@ -94,6 +94,7 @@ public: bool needed; Method* processMethod; Variable* actionParam; + Variable* requestParam; Variable* errorParam; Variable* requestData; Variable* resultData; @@ -159,15 +160,15 @@ ServiceBaseClass::generate_process() this->actionParam = new Variable(STRING_TYPE, "action"); this->processMethod->parameters.push_back(this->actionParam); - Variable* requestParam = new Variable(BYTE_TYPE, "requestParam", 1); - this->processMethod->parameters.push_back(requestParam); + this->requestParam = new Variable(BYTE_TYPE, "requestParam", 1); + this->processMethod->parameters.push_back(this->requestParam); this->errorParam = new Variable(RPC_ERROR_TYPE, "errorParam", 0); this->processMethod->parameters.push_back(this->errorParam); this->requestData = new Variable(RPC_DATA_TYPE, "request"); this->processMethod->statements->Add(new VariableDeclaration(requestData, - new NewExpression(RPC_DATA_TYPE, 1, requestParam))); + new NewExpression(RPC_DATA_TYPE, 1, this->requestParam))); this->resultData = new Variable(RPC_DATA_TYPE, "resultData"); this->processMethod->statements->Add(new VariableDeclaration(this->resultData, @@ -193,6 +194,12 @@ ServiceBaseClass::AddMethod(const string& methodName, StatementBlock** statement void ServiceBaseClass::DoneWithMethods() { + IfStatement* fallthrough = new IfStatement(); + fallthrough->statements = new StatementBlock; + fallthrough->statements->Add(new ReturnStatement( + new MethodCall(SUPER_VALUE, "process", 3, this->actionParam, this->requestParam, + this->errorParam))); + this->dispatchIfStatement->elseif = fallthrough; IfStatement* s = new IfStatement; s->statements = new StatementBlock; this->processMethod->statements->Add(s); -- cgit v1.2.3