Home | History | Annotate | Download | only in hidl

Lines Matching refs:out

30 void AST::emitJavaReaderWriter(Formatter& out, const std::string& parcelObj,
34 out << arg->type().getJavaType()
41 arg->type().emitJavaReaderWriter(out, parcelObj,
46 void AST::generateJavaTypes(Formatter& out, const std::string& limitToType) const {
60 out << "package " << mPackage.javaPackage() << ";\n\n\n";
62 type->emitJavaTypeDeclarations(out, true /* atTopLevel */);
70 Formatter& out,
74 out << "public static "
78 out << ", boolean retry";
80 out << ") throws android.os.RemoteException ";
81 out.block([&] {
82 out << "return "
88 out << ", retry";
90 out << "));\n";
93 out << "public static "
97 out << "boolean retry";
99 out << ") throws android.os.RemoteException ";
100 out.block([&] {
101 out << "return getService(\"default\"";
103 out << ", retry";
105 out <<");\n";
109 void AST::generateJava(Formatter& out, const std::string& limitToType) const {
113 generateJavaTypes(out, limitToType);
125 out << "package " << mPackage.javaPackage() << ";\n\n";
127 out.setNamespace(mPackage.javaPackage() + ".");
131 out << "public interface " << ifaceName << " extends ";
134 out << superType->fullJavaName();
136 out << "android.os.IHwInterface";
139 out << " {\n";
140 out.indent();
142 out << "public static final String kInterfaceName = \""
148 out << "/* package private */ static "
152 out.indent();
154 out << "if (binder == null) {\n";
155 out.indent();
156 out << "return null;\n";
157 out.unindent();
158 out << "}\n\n";
160 out << "android.os.IHwInterface iface =\n";
161 out.indent();
162 out.indent();
163 out << "binder.queryLocalInterface(kInterfaceName);\n\n";
164 out.unindent();
165 out.unindent();
167 out << "if ((iface != null) && (iface instanceof "
171 out.indent();
172 out << "return (" << ifaceName << ")iface;\n";
173 out.unindent();
174 out << "}\n\n";
176 out << ifaceName << " proxy = new " << ifaceName << ".Proxy(binder);\n\n";
177 out << "try {\n";
178 out.indent();
179 out << "for (String descriptor : proxy.interfaceChain()) {\n";
180 out.indent();
181 out << "if (descriptor.equals(kInterfaceName)) {\n";
182 out.indent();
183 out << "return proxy;\n";
184 out.unindent();
185 out << "}\n";
186 out.unindent();
187 out << "}\n";
188 out.unindent();
189 out << "} catch (android.os.RemoteException e) {\n";
190 out.indent();
191 out.unindent();
192 out << "}\n\n";
194 out << "return null;\n";
196 out.unindent();
197 out << "}\n\n";
199 out << "public static "
202 out.indent();
204 out << "return (iface == null) ? null : "
208 out.unindent();
209 out << "}\n\n";
211 out << "@Override\npublic android.os.IHwBinder asBinder();\n\n";
213 emitGetService(out, ifaceName, iface->fqName().string(), true /* isRetry */);
214 emitGetService(out, ifaceName, iface->fqName().string(), false /* isRetry */);
216 emitJavaTypeDeclarations(out);
227 out << "\n@java.lang.FunctionalInterface\npublic interface " << method->name()
230 out.indent();
232 out << "public void onValues(";
233 method->emitJavaResultSignature(out);
234 out << ");\n";
236 out.unindent();
237 out << "}\n\n";
240 method->emitDocComment(out);
243 out << method->results()[0]->type().getJavaType();
245 out << "void";
248 out << " "
251 method->emitJavaArgSignature(out);
255 out << ", ";
258 out << method->name()
262 out << ")\n";
263 out.indent();
264 out << "throws android.os.RemoteException;\n";
265 out.unindent();
268 out << "\npublic static final class Proxy implements "
272 out.indent();
274 out << "private android.os.IHwBinder mRemote;\n\n";
275 out << "public Proxy(android.os.IHwBinder remote) {\n";
276 out.indent();
277 out << "mRemote = java.util.Objects.requireNonNull(remote);\n";
278 out.unindent();
279 out << "}\n\n";
281 out << "@Override\npublic android.os.IHwBinder asBinder() {\n";
282 out.indent();
283 out << "return mRemote;\n";
284 out.unindent();
285 out << "}\n\n";
288 out << "@Override\npublic String toString() ";
289 out.block([&] {
290 out.sTry([&] {
291 out << "return this.interfaceDescriptor() + \"@Proxy\";\n";
293 out << "/* ignored; handled below. */\n";
295 out << "return \"[class or subclass of \" + "
301 out << "@Override\npublic final boolean equals(java.lang.Object other) ";
302 out.block([&] {
303 out << "return android.os.HidlSupport.interfacesEqual(this, other);\n";
306 out << "@Override\npublic final int hashCode() ";
307 out.block([&] {
308 out << "return this.asBinder().hashCode();\n";
321 out << "// Methods from "
329 out << "@Override\npublic ";
331 out << method->results()[0]->type().getJavaType();
333 out << "void";
336 out << " "
339 method->emitJavaArgSignature(out);
343 out << ", ";
346 out << method->name()
350 out << ")\n";
351 out.indent();
352 out.indent();
353 out << "throws android.os.RemoteException {\n";
354 out.unindent();
357 method->javaImpl(IMPL_PROXY, out);
358 out.unindent();
359 out << "}\n";
362 out << "android.os.HwParcel _hidl_request = new android.os.HwParcel();\n";
363 out << "_hidl_request.writeInterfaceToken("
369 out,
376 out << "\nandroid.os.HwParcel _hidl_reply = new android.os.HwParcel();\n";
378 out.sTry([&] {
379 out << "mRemote.transact("
386 out << Interface::FLAG_ONEWAY << " /* oneway */";
388 out << "0 /* flags */";
391 out << ");\n";
394 out << "_hidl_reply.verifySuccess();\n";
399 out << "_hidl_request.releaseTemporaryStorage();\n";
402 out << "\n";
406 out,
414 out << "_hidl_cb.onValues(";
419 out << ", ";
422 out << "_hidl_out_" << arg->name();
426 out << ");\n";
429 out << "return _hidl_out_" << returnName << ";\n";
433 out << "_hidl_reply.release();\n";
436 out.unindent();
437 out << "}\n\n";
440 out.unindent();
441 out << "}\n";
445 out << "\npublic static abstract class Stub extends android.os.HwBinder "
449 out.indent();
451 out << "@Override\npublic android.os.IHwBinder asBinder() {\n";
452 out.indent();
455 out << "return this;\n";
456 out.unindent();
457 out << "}\n\n";
468 out << "@Override\npublic final "
473 method->emitJavaArgSignature(out);
474 out << ") {\n";
476 out.indent();
477 method->javaImpl(IMPL_INTERFACE, out);
478 out.unindent();
479 out << "\n}\n\n";
482 out << "@Override\n"
484 out.indent();
486 out << "if (kInterfaceName.equals(descriptor)) {\n";
487 out.indent();
488 out << "return this;\n";
489 out.unindent();
490 out << "}\n";
491 out << "return null;\n";
492 out.unindent();
493 out << "}\n\n";
495 out << "public void registerAsService(String serviceName) throws android.os.RemoteException {\n";
496 out.indent();
498 out << "registerService(serviceName);\n";
500 out.unindent();
501 out << "}\n\n";
503 out << "@Override\npublic String toString() ";
504 out.block([&] {
505 out << "return this.interfaceDescriptor() + \"@Stub\";\n";
508 out << "@Override\n"
514 out.indent();
515 out.indent();
516 out << "throws android.os.RemoteException {\n";
517 out.unindent();
519 out << "switch (_hidl_code) {\n";
521 out.indent();
530 out << "case "
536 out.indent();
538 out << "boolean _hidl_is_oneway = (_hidl_flags & " << Interface::FLAG_ONEWAY
540 out << "if (_hidl_is_oneway != " << (method->isOneway() ? "true" : "false") << ") ";
541 out.block([&] {
542 out << "_hidl_reply.writeStatus(" << UNKNOWN_ERROR << ");\n";
543 out << "_hidl_reply.send();\n";
544 out << "break;\n";
548 method->javaImpl(IMPL_STUB, out);
549 out.unindent();
550 out << "break;\n";
551 out << "}\n\n";
555 out << "_hidl_request.enforceInterface("
564 out << "_hidl_reply.writeStatus(android.os.HwParcel.STATUS_SUCCESS);\n";
565 out << "_hidl_reply.send();\n";
566 out << "break;\n";
567 out.unindent();
568 out << "}\n\n";
574 out,
584 out << returnArg->type().getJavaType()
590 out << method->name()
596 out << ", ";
599 out << arg->name();
606 out << ", ";
609 out << "new " << method->name() << "Callback() {\n";
610 out.indent();
612 out << "@Override\n"
614 method->emitJavaResultSignature(out);
615 out << ") {\n";
617 out.indent();
618 out << "_hidl_reply.writeStatus(android.os.HwParcel.STATUS_SUCCESS);\n";
622 out,
627 // no need to add _hidl_out because out vars are are scoped
630 out << "_hidl_reply.send();\n"
633 out.unindent();
634 out.unindent();
637 out << ");\n";
640 out << "_hidl_reply.writeStatus(android.os.HwParcel.STATUS_SUCCESS);\n";
646 out,
653 out << "_hidl_reply.send();\n";
656 out << "break;\n";
657 out.unindent();
658 out << "}\n\n";
661 out.unindent();
662 out << "}\n";
664 out.unindent();
665 out << "}\n";
667 out.unindent();
668 out << "}\n";
670 out.unindent();
671 out << "}\n";
674 void AST::emitJavaTypeDeclarations(Formatter& out) const {
675 mRootScope.emitJavaTypeDeclarations(out, false /* atTopLevel */);