Andreas Huber | 1aec397 | 2016-08-26 09:26:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 17 | #include "AST.h" |
| 18 | |
| 19 | #include "Coordinator.h" |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 20 | #include "Interface.h" |
| 21 | #include "Method.h" |
| 22 | #include "Scope.h" |
| 23 | |
Iliyan Malchev | a72e0d2 | 2016-09-09 11:03:08 -0700 | [diff] [blame] | 24 | #include <hidl-util/Formatter.h> |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 25 | #include <android-base/logging.h> |
| 26 | |
| 27 | namespace android { |
| 28 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 29 | void AST::emitJavaReaderWriter( |
| 30 | Formatter &out, |
| 31 | const std::string &parcelObj, |
| 32 | const TypedVar *arg, |
Yifan Hong | a47eef3 | 2016-12-12 10:38:54 -0800 | [diff] [blame] | 33 | bool isReader, |
| 34 | bool addPrefixToName) const { |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 35 | if (isReader) { |
Yifan Hong | 4ed1347 | 2016-11-02 10:44:11 -0700 | [diff] [blame] | 36 | out << arg->type().getJavaType() |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 37 | << " " |
Yifan Hong | a47eef3 | 2016-12-12 10:38:54 -0800 | [diff] [blame] | 38 | << (addPrefixToName ? "_hidl_out_" : "") |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 39 | << arg->name() |
| 40 | << " = "; |
| 41 | } |
| 42 | |
Yifan Hong | a47eef3 | 2016-12-12 10:38:54 -0800 | [diff] [blame] | 43 | arg->type().emitJavaReaderWriter(out, parcelObj, |
| 44 | (addPrefixToName ? "_hidl_out_" : "") + arg->name(), |
| 45 | isReader); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 46 | } |
| 47 | |
Andreas Huber | 0fa9e39 | 2016-08-31 09:05:44 -0700 | [diff] [blame] | 48 | status_t AST::generateJavaTypes( |
Andreas Huber | d29724f | 2016-09-14 09:33:13 -0700 | [diff] [blame] | 49 | const std::string &outputPath, const std::string &limitToType) const { |
Andreas Huber | 85eabdb | 2016-08-25 11:24:49 -0700 | [diff] [blame] | 50 | // Splits types.hal up into one java file per declared type. |
| 51 | |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 52 | for (const auto &type : mRootScope->getSubTypes()) { |
| 53 | std::string typeName = type->localName(); |
Andreas Huber | 85eabdb | 2016-08-25 11:24:49 -0700 | [diff] [blame] | 54 | |
| 55 | if (type->isTypeDef()) { |
| 56 | continue; |
| 57 | } |
| 58 | |
Andreas Huber | d29724f | 2016-09-14 09:33:13 -0700 | [diff] [blame] | 59 | if (!limitToType.empty() && typeName != limitToType) { |
Andreas Huber | 0fa9e39 | 2016-08-31 09:05:44 -0700 | [diff] [blame] | 60 | continue; |
| 61 | } |
| 62 | |
Andreas Huber | 85eabdb | 2016-08-25 11:24:49 -0700 | [diff] [blame] | 63 | std::string path = outputPath; |
| 64 | path.append(mCoordinator->convertPackageRootToPath(mPackage)); |
Yifan Hong | 97288ac | 2016-12-12 16:03:51 -0800 | [diff] [blame] | 65 | path.append(mCoordinator->getPackagePath(mPackage, true /* relative */, |
| 66 | true /* sanitized */)); |
Andreas Huber | 85eabdb | 2016-08-25 11:24:49 -0700 | [diff] [blame] | 67 | path.append(typeName); |
| 68 | path.append(".java"); |
| 69 | |
Steven Moreland | f7fa068 | 2017-05-11 16:14:55 -0700 | [diff] [blame] | 70 | CHECK(Coordinator::MakeParentHierarchy(path)) << path; |
Andreas Huber | 85eabdb | 2016-08-25 11:24:49 -0700 | [diff] [blame] | 71 | FILE *file = fopen(path.c_str(), "w"); |
| 72 | |
| 73 | if (file == NULL) { |
| 74 | return -errno; |
| 75 | } |
| 76 | |
| 77 | Formatter out(file); |
| 78 | |
| 79 | std::vector<std::string> packageComponents; |
| 80 | getPackageAndVersionComponents( |
| 81 | &packageComponents, true /* cpp_compatible */); |
| 82 | |
| 83 | out << "package " << mPackage.javaPackage() << ";\n\n"; |
| 84 | |
Iliyan Malchev | 800273d | 2016-09-02 15:25:07 -0700 | [diff] [blame] | 85 | out << "\n"; |
| 86 | |
Andreas Huber | 85eabdb | 2016-08-25 11:24:49 -0700 | [diff] [blame] | 87 | status_t err = |
| 88 | type->emitJavaTypeDeclarations(out, true /* atTopLevel */); |
| 89 | |
| 90 | if (err != OK) { |
| 91 | return err; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | return OK; |
| 96 | } |
| 97 | |
Andreas Huber | 0fa9e39 | 2016-08-31 09:05:44 -0700 | [diff] [blame] | 98 | status_t AST::generateJava( |
Andreas Huber | d29724f | 2016-09-14 09:33:13 -0700 | [diff] [blame] | 99 | const std::string &outputPath, const std::string &limitToType) const { |
Andreas Huber | 0fa9e39 | 2016-08-31 09:05:44 -0700 | [diff] [blame] | 100 | if (!isJavaCompatible()) { |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 101 | fprintf(stderr, |
| 102 | "ERROR: This interface is not Java compatible. The Java backend" |
Andreas Huber | f03332a | 2016-09-22 15:35:43 -0700 | [diff] [blame] | 103 | " does NOT support union types nor native handles. " |
| 104 | "In addition, vectors of arrays are limited to at most " |
Andreas Huber | 86a112b | 2016-10-19 14:25:16 -0700 | [diff] [blame] | 105 | "one-dimensional arrays and vectors of {vectors,interfaces} are" |
| 106 | " not supported.\n"); |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 107 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 108 | return UNKNOWN_ERROR; |
| 109 | } |
| 110 | |
Steven Moreland | 19f11b5 | 2017-05-12 18:22:21 -0700 | [diff] [blame] | 111 | if (!AST::isInterface()) { |
Andreas Huber | 0fa9e39 | 2016-08-31 09:05:44 -0700 | [diff] [blame] | 112 | return generateJavaTypes(outputPath, limitToType); |
| 113 | } |
| 114 | |
| 115 | const Interface *iface = mRootScope->getInterface(); |
Steven Moreland | 19f11b5 | 2017-05-12 18:22:21 -0700 | [diff] [blame] | 116 | std::string ifaceName = iface->localName(); |
Andreas Huber | 0fa9e39 | 2016-08-31 09:05:44 -0700 | [diff] [blame] | 117 | |
Jayant Chowdhary | 3f32c1f | 2016-09-15 16:53:56 -0700 | [diff] [blame] | 118 | const std::string baseName = iface->getBaseName(); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 119 | |
| 120 | std::string path = outputPath; |
| 121 | path.append(mCoordinator->convertPackageRootToPath(mPackage)); |
Yifan Hong | 97288ac | 2016-12-12 16:03:51 -0800 | [diff] [blame] | 122 | path.append(mCoordinator->getPackagePath(mPackage, true /* relative */, |
| 123 | true /* sanitized */)); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 124 | path.append(ifaceName); |
| 125 | path.append(".java"); |
| 126 | |
| 127 | CHECK(Coordinator::MakeParentHierarchy(path)); |
| 128 | FILE *file = fopen(path.c_str(), "w"); |
| 129 | |
| 130 | if (file == NULL) { |
| 131 | return -errno; |
| 132 | } |
| 133 | |
| 134 | Formatter out(file); |
| 135 | |
| 136 | std::vector<std::string> packageComponents; |
| 137 | getPackageAndVersionComponents( |
| 138 | &packageComponents, true /* cpp_compatible */); |
| 139 | |
| 140 | out << "package " << mPackage.javaPackage() << ";\n\n"; |
| 141 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 142 | out.setNamespace(mPackage.javaPackage() + "."); |
| 143 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 144 | const Interface *superType = iface->superType(); |
| 145 | |
| 146 | out << "public interface " << ifaceName << " extends "; |
| 147 | |
| 148 | if (superType != NULL) { |
| 149 | out << superType->fullJavaName(); |
| 150 | } else { |
Yifan Hong | 1af7353 | 2016-11-09 14:32:58 -0800 | [diff] [blame] | 151 | out << "android.os.IHwInterface"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | out << " {\n"; |
| 155 | out.indent(); |
| 156 | |
| 157 | out << "public static final String kInterfaceName = \"" |
| 158 | << mPackage.string() |
| 159 | << "::" |
| 160 | << ifaceName |
| 161 | << "\";\n\n"; |
| 162 | |
Andreas Huber | a2abe98 | 2017-04-04 14:42:09 -0700 | [diff] [blame] | 163 | out << "/* package private */ static " |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 164 | << ifaceName |
Yifan Hong | 1af7353 | 2016-11-09 14:32:58 -0800 | [diff] [blame] | 165 | << " asInterface(android.os.IHwBinder binder) {\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 166 | |
| 167 | out.indent(); |
| 168 | |
| 169 | out << "if (binder == null) {\n"; |
| 170 | out.indent(); |
| 171 | out << "return null;\n"; |
| 172 | out.unindent(); |
| 173 | out << "}\n\n"; |
| 174 | |
Yifan Hong | 1af7353 | 2016-11-09 14:32:58 -0800 | [diff] [blame] | 175 | out << "android.os.IHwInterface iface =\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 176 | out.indent(); |
| 177 | out.indent(); |
| 178 | out << "binder.queryLocalInterface(kInterfaceName);\n\n"; |
| 179 | out.unindent(); |
| 180 | out.unindent(); |
| 181 | |
| 182 | out << "if ((iface != null) && (iface instanceof " |
| 183 | << ifaceName |
| 184 | << ")) {\n"; |
| 185 | |
| 186 | out.indent(); |
| 187 | out << "return (" << ifaceName << ")iface;\n"; |
| 188 | out.unindent(); |
| 189 | out << "}\n\n"; |
| 190 | |
Andreas Huber | a2abe98 | 2017-04-04 14:42:09 -0700 | [diff] [blame] | 191 | out << ifaceName << " proxy = new " << ifaceName << ".Proxy(binder);\n\n"; |
| 192 | out << "try {\n"; |
| 193 | out.indent(); |
| 194 | out << "for (String descriptor : proxy.interfaceChain()) {\n"; |
| 195 | out.indent(); |
| 196 | out << "if (descriptor.equals(kInterfaceName)) {\n"; |
| 197 | out.indent(); |
| 198 | out << "return proxy;\n"; |
| 199 | out.unindent(); |
| 200 | out << "}\n"; |
| 201 | out.unindent(); |
| 202 | out << "}\n"; |
| 203 | out.unindent(); |
| 204 | out << "} catch (android.os.RemoteException e) {\n"; |
| 205 | out.indent(); |
| 206 | out.unindent(); |
| 207 | out << "}\n\n"; |
| 208 | |
| 209 | out << "return null;\n"; |
| 210 | |
| 211 | out.unindent(); |
| 212 | out << "}\n\n"; |
| 213 | |
| 214 | out << "public static " |
| 215 | << ifaceName |
| 216 | << " castFrom(android.os.IHwInterface iface) {\n"; |
| 217 | out.indent(); |
| 218 | |
| 219 | out << "return (iface == null) ? null : " |
| 220 | << ifaceName |
| 221 | << ".asInterface(iface.asBinder());\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 222 | |
| 223 | out.unindent(); |
| 224 | out << "}\n\n"; |
| 225 | |
Yifan Hong | 084d11f | 2016-12-21 15:33:43 -0800 | [diff] [blame] | 226 | out << "@Override\npublic android.os.IHwBinder asBinder();\n\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 227 | |
Andreas Huber | 2bb6e1e | 2016-10-25 13:26:43 -0700 | [diff] [blame] | 228 | out << "public static " |
| 229 | << ifaceName |
Yifan Hong | 320a349 | 2017-03-27 10:33:09 -0700 | [diff] [blame] | 230 | << " getService(String serviceName) throws android.os.RemoteException {\n"; |
Andreas Huber | 2bb6e1e | 2016-10-25 13:26:43 -0700 | [diff] [blame] | 231 | |
| 232 | out.indent(); |
| 233 | |
| 234 | out << "return " |
| 235 | << ifaceName |
Yifan Hong | 1af7353 | 2016-11-09 14:32:58 -0800 | [diff] [blame] | 236 | << ".asInterface(android.os.HwBinder.getService(\"" |
Steven Moreland | 7e367bf | 2016-11-04 11:31:41 -0700 | [diff] [blame] | 237 | << iface->fqName().string() |
| 238 | << "\",serviceName));\n"; |
Andreas Huber | 2bb6e1e | 2016-10-25 13:26:43 -0700 | [diff] [blame] | 239 | |
| 240 | out.unindent(); |
| 241 | |
| 242 | out << "}\n\n"; |
| 243 | |
Chris Phoenix | db0d634 | 2017-01-11 16:10:00 -0800 | [diff] [blame] | 244 | out << "public static " |
| 245 | << ifaceName |
Yifan Hong | 320a349 | 2017-03-27 10:33:09 -0700 | [diff] [blame] | 246 | << " getService() throws android.os.RemoteException {\n"; |
Chris Phoenix | db0d634 | 2017-01-11 16:10:00 -0800 | [diff] [blame] | 247 | |
| 248 | out.indent(); |
| 249 | |
| 250 | out << "return " |
| 251 | << ifaceName |
| 252 | << ".asInterface(android.os.HwBinder.getService(\"" |
| 253 | << iface->fqName().string() |
| 254 | << "\",\"default\"));\n"; |
| 255 | |
| 256 | out.unindent(); |
| 257 | |
| 258 | out << "}\n\n"; |
| 259 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 260 | status_t err = emitJavaTypeDeclarations(out); |
| 261 | |
| 262 | if (err != OK) { |
| 263 | return err; |
| 264 | } |
| 265 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 266 | for (const auto &method : iface->methods()) { |
Andreas Huber | 37065d6 | 2017-02-07 14:36:54 -0800 | [diff] [blame] | 267 | if (method->isHiddenFromJava()) { |
| 268 | continue; |
| 269 | } |
| 270 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 271 | const bool returnsValue = !method->results().empty(); |
| 272 | const bool needsCallback = method->results().size() > 1; |
| 273 | |
| 274 | if (needsCallback) { |
Yifan Hong | 601cfca | 2017-05-24 12:20:17 -0700 | [diff] [blame] | 275 | out << "\n@java.lang.FunctionalInterface\npublic interface " << method->name() |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 276 | << "Callback {\n"; |
| 277 | |
| 278 | out.indent(); |
| 279 | |
Yifan Hong | 932464e | 2017-03-30 15:40:22 -0700 | [diff] [blame] | 280 | out << "public void onValues("; |
| 281 | method->emitJavaResultSignature(out); |
| 282 | out << ");\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 283 | |
| 284 | out.unindent(); |
| 285 | out << "}\n\n"; |
| 286 | } |
| 287 | |
| 288 | if (returnsValue && !needsCallback) { |
Yifan Hong | 4ed1347 | 2016-11-02 10:44:11 -0700 | [diff] [blame] | 289 | out << method->results()[0]->type().getJavaType(); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 290 | } else { |
| 291 | out << "void"; |
| 292 | } |
| 293 | |
| 294 | out << " " |
| 295 | << method->name() |
Yifan Hong | 932464e | 2017-03-30 15:40:22 -0700 | [diff] [blame] | 296 | << "("; |
| 297 | method->emitJavaArgSignature(out); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 298 | |
| 299 | if (needsCallback) { |
| 300 | if (!method->args().empty()) { |
| 301 | out << ", "; |
| 302 | } |
| 303 | |
| 304 | out << method->name() |
Steven Moreland | 4ddd833 | 2017-04-27 19:27:18 -0700 | [diff] [blame] | 305 | << "Callback _hidl_cb"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Steven Moreland | dad1b30 | 2016-12-20 15:56:00 -0800 | [diff] [blame] | 308 | out << ")\n"; |
| 309 | out.indent(); |
Yifan Hong | 320a349 | 2017-03-27 10:33:09 -0700 | [diff] [blame] | 310 | out << "throws android.os.RemoteException;\n"; |
Steven Moreland | dad1b30 | 2016-12-20 15:56:00 -0800 | [diff] [blame] | 311 | out.unindent(); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | out << "\npublic static final class Proxy implements " |
| 315 | << ifaceName |
| 316 | << " {\n"; |
| 317 | |
| 318 | out.indent(); |
| 319 | |
Yifan Hong | 1af7353 | 2016-11-09 14:32:58 -0800 | [diff] [blame] | 320 | out << "private android.os.IHwBinder mRemote;\n\n"; |
| 321 | out << "public Proxy(android.os.IHwBinder remote) {\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 322 | out.indent(); |
Yifan Hong | 729e796 | 2016-12-21 16:04:27 -0800 | [diff] [blame] | 323 | out << "mRemote = java.util.Objects.requireNonNull(remote);\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 324 | out.unindent(); |
| 325 | out << "}\n\n"; |
| 326 | |
Yifan Hong | 084d11f | 2016-12-21 15:33:43 -0800 | [diff] [blame] | 327 | out << "@Override\npublic android.os.IHwBinder asBinder() {\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 328 | out.indent(); |
| 329 | out << "return mRemote;\n"; |
| 330 | out.unindent(); |
| 331 | out << "}\n\n"; |
| 332 | |
Yifan Hong | e45b530 | 2017-02-22 10:49:07 -0800 | [diff] [blame] | 333 | |
| 334 | out << "@Override\npublic String toString() "; |
| 335 | out.block([&] { |
| 336 | out.sTry([&] { |
| 337 | out << "return this.interfaceDescriptor() + \"@Proxy\";\n"; |
Yifan Hong | 320a349 | 2017-03-27 10:33:09 -0700 | [diff] [blame] | 338 | }).sCatch("android.os.RemoteException ex", [&] { |
Yifan Hong | e45b530 | 2017-02-22 10:49:07 -0800 | [diff] [blame] | 339 | out << "/* ignored; handled below. */\n"; |
| 340 | }).endl(); |
| 341 | out << "return \"[class or subclass of \" + " |
| 342 | << ifaceName << ".kInterfaceName + \"]@Proxy\";\n"; |
| 343 | }).endl().endl(); |
| 344 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 345 | const Interface *prevInterface = nullptr; |
| 346 | for (const auto &tuple : iface->allMethodsFromRoot()) { |
| 347 | const Method *method = tuple.method(); |
Andreas Huber | 37065d6 | 2017-02-07 14:36:54 -0800 | [diff] [blame] | 348 | |
| 349 | if (method->isHiddenFromJava()) { |
| 350 | continue; |
| 351 | } |
| 352 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 353 | const Interface *superInterface = tuple.interface(); |
| 354 | if (prevInterface != superInterface) { |
| 355 | out << "// Methods from " |
| 356 | << superInterface->fullName() |
| 357 | << " follow.\n"; |
| 358 | prevInterface = superInterface; |
| 359 | } |
| 360 | const bool returnsValue = !method->results().empty(); |
| 361 | const bool needsCallback = method->results().size() > 1; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 362 | |
Yifan Hong | 084d11f | 2016-12-21 15:33:43 -0800 | [diff] [blame] | 363 | out << "@Override\npublic "; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 364 | if (returnsValue && !needsCallback) { |
Yifan Hong | 4ed1347 | 2016-11-02 10:44:11 -0700 | [diff] [blame] | 365 | out << method->results()[0]->type().getJavaType(); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 366 | } else { |
| 367 | out << "void"; |
| 368 | } |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 369 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 370 | out << " " |
| 371 | << method->name() |
Yifan Hong | 932464e | 2017-03-30 15:40:22 -0700 | [diff] [blame] | 372 | << "("; |
| 373 | method->emitJavaArgSignature(out); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 374 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 375 | if (needsCallback) { |
| 376 | if (!method->args().empty()) { |
| 377 | out << ", "; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 378 | } |
| 379 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 380 | out << method->name() |
Steven Moreland | 4ddd833 | 2017-04-27 19:27:18 -0700 | [diff] [blame] | 381 | << "Callback _hidl_cb"; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 382 | } |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 383 | |
Steven Moreland | dad1b30 | 2016-12-20 15:56:00 -0800 | [diff] [blame] | 384 | out << ")\n"; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 385 | out.indent(); |
Steven Moreland | dad1b30 | 2016-12-20 15:56:00 -0800 | [diff] [blame] | 386 | out.indent(); |
Yifan Hong | 320a349 | 2017-03-27 10:33:09 -0700 | [diff] [blame] | 387 | out << "throws android.os.RemoteException {\n"; |
Steven Moreland | dad1b30 | 2016-12-20 15:56:00 -0800 | [diff] [blame] | 388 | out.unindent(); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 389 | |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 390 | if (method->isHidlReserved() && method->overridesJavaImpl(IMPL_PROXY)) { |
| 391 | method->javaImpl(IMPL_PROXY, out); |
| 392 | out.unindent(); |
| 393 | out << "}\n"; |
| 394 | continue; |
| 395 | } |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 396 | out << "android.os.HwParcel _hidl_request = new android.os.HwParcel();\n"; |
| 397 | out << "_hidl_request.writeInterfaceToken(" |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 398 | << superInterface->fullJavaName() |
| 399 | << ".kInterfaceName);\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 400 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 401 | for (const auto &arg : method->args()) { |
| 402 | emitJavaReaderWriter( |
| 403 | out, |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 404 | "_hidl_request", |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 405 | arg, |
Yifan Hong | a47eef3 | 2016-12-12 10:38:54 -0800 | [diff] [blame] | 406 | false /* isReader */, |
| 407 | false /* addPrefixToName */); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 408 | } |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 409 | |
Martijn Coenen | 4de083b | 2017-03-16 18:49:43 +0100 | [diff] [blame] | 410 | out << "\nandroid.os.HwParcel _hidl_reply = new android.os.HwParcel();\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 411 | |
Martijn Coenen | 4de083b | 2017-03-16 18:49:43 +0100 | [diff] [blame] | 412 | out.sTry([&] { |
| 413 | out << "mRemote.transact(" |
| 414 | << method->getSerialId() |
| 415 | << " /* " |
| 416 | << method->name() |
| 417 | << " */, _hidl_request, _hidl_reply, "; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 418 | |
Martijn Coenen | 4de083b | 2017-03-16 18:49:43 +0100 | [diff] [blame] | 419 | if (method->isOneway()) { |
| 420 | out << "android.os.IHwBinder.FLAG_ONEWAY"; |
| 421 | } else { |
| 422 | out << "0 /* flags */"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 423 | } |
| 424 | |
Martijn Coenen | 4de083b | 2017-03-16 18:49:43 +0100 | [diff] [blame] | 425 | out << ");\n"; |
Andreas Huber | 8b5da22 | 2016-08-18 14:28:18 -0700 | [diff] [blame] | 426 | |
Martijn Coenen | 4de083b | 2017-03-16 18:49:43 +0100 | [diff] [blame] | 427 | if (!method->isOneway()) { |
| 428 | out << "_hidl_reply.verifySuccess();\n"; |
| 429 | } else { |
| 430 | CHECK(!returnsValue); |
| 431 | } |
| 432 | |
| 433 | out << "_hidl_request.releaseTemporaryStorage();\n"; |
| 434 | |
| 435 | if (returnsValue) { |
| 436 | out << "\n"; |
| 437 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 438 | for (const auto &arg : method->results()) { |
Martijn Coenen | 4de083b | 2017-03-16 18:49:43 +0100 | [diff] [blame] | 439 | emitJavaReaderWriter( |
| 440 | out, |
| 441 | "_hidl_reply", |
| 442 | arg, |
| 443 | true /* isReader */, |
| 444 | true /* addPrefixToName */); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 445 | } |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 446 | |
Martijn Coenen | 4de083b | 2017-03-16 18:49:43 +0100 | [diff] [blame] | 447 | if (needsCallback) { |
Steven Moreland | 4ddd833 | 2017-04-27 19:27:18 -0700 | [diff] [blame] | 448 | out << "_hidl_cb.onValues("; |
Martijn Coenen | 4de083b | 2017-03-16 18:49:43 +0100 | [diff] [blame] | 449 | |
| 450 | bool firstField = true; |
| 451 | for (const auto &arg : method->results()) { |
| 452 | if (!firstField) { |
| 453 | out << ", "; |
| 454 | } |
| 455 | |
| 456 | out << "_hidl_out_" << arg->name(); |
| 457 | firstField = false; |
| 458 | } |
| 459 | |
| 460 | out << ");\n"; |
| 461 | } else { |
| 462 | const std::string returnName = method->results()[0]->name(); |
| 463 | out << "return _hidl_out_" << returnName << ";\n"; |
| 464 | } |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 465 | } |
Martijn Coenen | 4de083b | 2017-03-16 18:49:43 +0100 | [diff] [blame] | 466 | }).sFinally([&] { |
| 467 | out << "_hidl_reply.release();\n"; |
| 468 | }).endl(); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 469 | |
| 470 | out.unindent(); |
| 471 | out << "}\n\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | out.unindent(); |
| 475 | out << "}\n"; |
| 476 | |
| 477 | //////////////////////////////////////////////////////////////////////////// |
| 478 | |
Yifan Hong | 1af7353 | 2016-11-09 14:32:58 -0800 | [diff] [blame] | 479 | out << "\npublic static abstract class Stub extends android.os.HwBinder " |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 480 | << "implements " |
| 481 | << ifaceName << " {\n"; |
| 482 | |
| 483 | out.indent(); |
| 484 | |
Yifan Hong | 084d11f | 2016-12-21 15:33:43 -0800 | [diff] [blame] | 485 | out << "@Override\npublic android.os.IHwBinder asBinder() {\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 486 | out.indent(); |
| 487 | out << "return this;\n"; |
| 488 | out.unindent(); |
| 489 | out << "}\n\n"; |
| 490 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 491 | for (Method *method : iface->hidlReservedMethods()) { |
Andreas Huber | 37065d6 | 2017-02-07 14:36:54 -0800 | [diff] [blame] | 492 | if (method->isHiddenFromJava()) { |
| 493 | continue; |
| 494 | } |
| 495 | |
Martijn Coenen | af712c0 | 2016-11-16 15:26:27 +0100 | [diff] [blame] | 496 | // b/32383557 this is a hack. We need to change this if we have more reserved methods. |
| 497 | CHECK_LE(method->results().size(), 1u); |
| 498 | std::string resultType = method->results().size() == 0 ? "void" : |
| 499 | method->results()[0]->type().getJavaType(); |
Yifan Hong | 084d11f | 2016-12-21 15:33:43 -0800 | [diff] [blame] | 500 | out << "@Override\npublic final " |
Martijn Coenen | af712c0 | 2016-11-16 15:26:27 +0100 | [diff] [blame] | 501 | << resultType |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 502 | << " " |
| 503 | << method->name() |
Yifan Hong | 932464e | 2017-03-30 15:40:22 -0700 | [diff] [blame] | 504 | << "("; |
| 505 | method->emitJavaArgSignature(out); |
| 506 | out << ") {\n"; |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 507 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 508 | out.indent(); |
Steven Moreland | 937408a | 2017-03-20 09:54:18 -0700 | [diff] [blame] | 509 | method->javaImpl(IMPL_INTERFACE, out); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 510 | out.unindent(); |
| 511 | out << "\n}\n\n"; |
| 512 | } |
| 513 | |
Yifan Hong | 084d11f | 2016-12-21 15:33:43 -0800 | [diff] [blame] | 514 | out << "@Override\n" |
| 515 | << "public android.os.IHwInterface queryLocalInterface(String descriptor) {\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 516 | out.indent(); |
| 517 | // XXX what about potential superClasses? |
| 518 | out << "if (kInterfaceName.equals(descriptor)) {\n"; |
| 519 | out.indent(); |
| 520 | out << "return this;\n"; |
| 521 | out.unindent(); |
| 522 | out << "}\n"; |
| 523 | out << "return null;\n"; |
| 524 | out.unindent(); |
| 525 | out << "}\n\n"; |
| 526 | |
Yifan Hong | 320a349 | 2017-03-27 10:33:09 -0700 | [diff] [blame] | 527 | out << "public void registerAsService(String serviceName) throws android.os.RemoteException {\n"; |
Andreas Huber | 2bb6e1e | 2016-10-25 13:26:43 -0700 | [diff] [blame] | 528 | out.indent(); |
| 529 | |
Martijn Coenen | bc9f5c9 | 2017-03-06 13:04:05 +0100 | [diff] [blame] | 530 | out << "registerService(serviceName);\n"; |
Andreas Huber | 2bb6e1e | 2016-10-25 13:26:43 -0700 | [diff] [blame] | 531 | |
| 532 | out.unindent(); |
| 533 | out << "}\n\n"; |
| 534 | |
Yifan Hong | e45b530 | 2017-02-22 10:49:07 -0800 | [diff] [blame] | 535 | out << "@Override\npublic String toString() "; |
| 536 | out.block([&] { |
| 537 | out << "return this.interfaceDescriptor() + \"@Stub\";\n"; |
| 538 | }).endl().endl(); |
| 539 | |
Yifan Hong | 084d11f | 2016-12-21 15:33:43 -0800 | [diff] [blame] | 540 | out << "@Override\n" |
| 541 | << "public void onTransact(" |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 542 | << "int _hidl_code, " |
| 543 | << "android.os.HwParcel _hidl_request, " |
| 544 | << "final android.os.HwParcel _hidl_reply, " |
Steven Moreland | dad1b30 | 2016-12-20 15:56:00 -0800 | [diff] [blame] | 545 | << "int _hidl_flags)\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 546 | out.indent(); |
Steven Moreland | dad1b30 | 2016-12-20 15:56:00 -0800 | [diff] [blame] | 547 | out.indent(); |
Yifan Hong | 320a349 | 2017-03-27 10:33:09 -0700 | [diff] [blame] | 548 | out << "throws android.os.RemoteException {\n"; |
Steven Moreland | dad1b30 | 2016-12-20 15:56:00 -0800 | [diff] [blame] | 549 | out.unindent(); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 550 | |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 551 | out << "switch (_hidl_code) {\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 552 | |
| 553 | out.indent(); |
| 554 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 555 | for (const auto &tuple : iface->allMethodsFromRoot()) { |
| 556 | const Method *method = tuple.method(); |
Andreas Huber | 37065d6 | 2017-02-07 14:36:54 -0800 | [diff] [blame] | 557 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 558 | const Interface *superInterface = tuple.interface(); |
| 559 | const bool returnsValue = !method->results().empty(); |
| 560 | const bool needsCallback = method->results().size() > 1; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 561 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 562 | out << "case " |
| 563 | << method->getSerialId() |
| 564 | << " /* " |
| 565 | << method->name() |
| 566 | << " */:\n{\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 567 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 568 | out.indent(); |
Andreas Huber | 37065d6 | 2017-02-07 14:36:54 -0800 | [diff] [blame] | 569 | |
Martijn Coenen | 115d428 | 2016-12-19 05:14:04 +0100 | [diff] [blame] | 570 | if (method->isHidlReserved() && method->overridesJavaImpl(IMPL_STUB)) { |
| 571 | method->javaImpl(IMPL_STUB, out); |
| 572 | out.unindent(); |
| 573 | out << "break;\n"; |
| 574 | out << "}\n\n"; |
| 575 | continue; |
| 576 | } |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 577 | |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 578 | out << "_hidl_request.enforceInterface(" |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 579 | << superInterface->fullJavaName() |
| 580 | << ".kInterfaceName);\n\n"; |
| 581 | |
Andreas Huber | 37065d6 | 2017-02-07 14:36:54 -0800 | [diff] [blame] | 582 | if (method->isHiddenFromJava()) { |
| 583 | // This is a method hidden from the Java side of things, it must not |
| 584 | // return any value and will simply signal success. |
| 585 | CHECK(!returnsValue); |
| 586 | |
| 587 | out << "_hidl_reply.writeStatus(android.os.HwParcel.STATUS_SUCCESS);\n"; |
| 588 | out << "_hidl_reply.send();\n"; |
| 589 | out << "break;\n"; |
| 590 | out.unindent(); |
| 591 | out << "}\n\n"; |
| 592 | continue; |
| 593 | } |
| 594 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 595 | for (const auto &arg : method->args()) { |
| 596 | emitJavaReaderWriter( |
| 597 | out, |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 598 | "_hidl_request", |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 599 | arg, |
Yifan Hong | a47eef3 | 2016-12-12 10:38:54 -0800 | [diff] [blame] | 600 | true /* isReader */, |
| 601 | false /* addPrefixToName */); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | if (!needsCallback && returnsValue) { |
| 605 | const TypedVar *returnArg = method->results()[0]; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 606 | |
Yifan Hong | 4ed1347 | 2016-11-02 10:44:11 -0700 | [diff] [blame] | 607 | out << returnArg->type().getJavaType() |
Yifan Hong | a47eef3 | 2016-12-12 10:38:54 -0800 | [diff] [blame] | 608 | << " _hidl_out_" |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 609 | << returnArg->name() |
| 610 | << " = "; |
| 611 | } |
| 612 | |
| 613 | out << method->name() |
| 614 | << "("; |
| 615 | |
| 616 | bool firstField = true; |
| 617 | for (const auto &arg : method->args()) { |
| 618 | if (!firstField) { |
| 619 | out << ", "; |
| 620 | } |
| 621 | |
| 622 | out << arg->name(); |
| 623 | |
| 624 | firstField = false; |
| 625 | } |
| 626 | |
| 627 | if (needsCallback) { |
| 628 | if (!firstField) { |
| 629 | out << ", "; |
| 630 | } |
| 631 | |
| 632 | out << "new " << method->name() << "Callback() {\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 633 | out.indent(); |
| 634 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 635 | out << "@Override\n" |
Yifan Hong | 932464e | 2017-03-30 15:40:22 -0700 | [diff] [blame] | 636 | << "public void onValues("; |
| 637 | method->emitJavaResultSignature(out); |
| 638 | out << ") {\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 639 | |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 640 | out.indent(); |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 641 | out << "_hidl_reply.writeStatus(android.os.HwParcel.STATUS_SUCCESS);\n"; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 642 | |
| 643 | for (const auto &arg : method->results()) { |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 644 | emitJavaReaderWriter( |
| 645 | out, |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 646 | "_hidl_reply", |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 647 | arg, |
Yifan Hong | a47eef3 | 2016-12-12 10:38:54 -0800 | [diff] [blame] | 648 | false /* isReader */, |
| 649 | false /* addPrefixToName */); |
| 650 | // no need to add _hidl_out because out vars are are scoped |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 651 | } |
| 652 | |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 653 | out << "_hidl_reply.send();\n" |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 654 | << "}}"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 655 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 656 | out.unindent(); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 657 | out.unindent(); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 658 | } |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 659 | |
| 660 | out << ");\n"; |
| 661 | |
Martijn Coenen | 0bb0d41 | 2017-02-08 10:21:30 +0100 | [diff] [blame] | 662 | if (!needsCallback && !method->isOneway()) { |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 663 | out << "_hidl_reply.writeStatus(android.os.HwParcel.STATUS_SUCCESS);\n"; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 664 | |
| 665 | if (returnsValue) { |
| 666 | const TypedVar *returnArg = method->results()[0]; |
| 667 | |
| 668 | emitJavaReaderWriter( |
| 669 | out, |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 670 | "_hidl_reply", |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 671 | returnArg, |
Yifan Hong | a47eef3 | 2016-12-12 10:38:54 -0800 | [diff] [blame] | 672 | false /* isReader */, |
| 673 | true /* addPrefixToName */); |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 674 | } |
| 675 | |
Steven Moreland | 4b39bc1 | 2016-11-16 10:42:24 -0800 | [diff] [blame] | 676 | out << "_hidl_reply.send();\n"; |
Yifan Hong | 10fe0b5 | 2016-10-19 14:20:17 -0700 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | out << "break;\n"; |
| 680 | out.unindent(); |
| 681 | out << "}\n\n"; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | out.unindent(); |
| 685 | out << "}\n"; |
| 686 | |
| 687 | out.unindent(); |
| 688 | out << "}\n"; |
| 689 | |
| 690 | out.unindent(); |
| 691 | out << "}\n"; |
| 692 | |
| 693 | out.unindent(); |
| 694 | out << "}\n"; |
| 695 | |
| 696 | return OK; |
| 697 | } |
| 698 | |
| 699 | status_t AST::emitJavaTypeDeclarations(Formatter &out) const { |
Andreas Huber | 85eabdb | 2016-08-25 11:24:49 -0700 | [diff] [blame] | 700 | return mRootScope->emitJavaTypeDeclarations(out, false /* atTopLevel */); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | } // namespace android |