Home | History | Annotate | Download | only in driver

Lines Matching refs:out

36     Formatter& out, const ComponentSpecificationMessage& message,
48 out << "static string callback_socket_name_;" << "\n";
51 out << "\n";
52 out << "class " << name << " : public DriverCallbackBase {"
54 out << " public:" << "\n";
55 out.indent();
56 out << name << "(const string& callback_socket_name) {" << "\n";
57 out.indent();
58 out << "callback_socket_name_ = callback_socket_name;" << "\n";
59 out.unindent();
60 out << "}" << "\n";
67 out << "\n";
68 out << "static ";
73 out << "void" << "\n";
75 out << func_pt_spec.return_type().predefined_type();
82 out << " " << callback_name << "(";
87 out << ", ";
90 out << "const ";
95 out << definition.aggregate_value(
100 out << "char* ";
102 out << "unsigned char* ";
104 out << "bool ";
114 out << arg.scalar_type() << " ";
116 out << "void*";
123 out << arg.predefined_type() << " ";
128 out << "arg" << primitive_type_index;
131 out << ") {" << "\n";
132 out.indent();
134 out << " const char fmt[] = \""
137 out << " va_list argp;" << "\n";
138 out << " const char* p;" << "\n";
139 out << " int i;" << "\n";
140 out << " char* s;" << "\n";
141 out << " char fmtbuf[256];" << "\n";
142 out << "\n";
143 out << " va_start(argp, fmt);" << "\n";
144 out << "\n";
145 out << " for (p = fmt; *p != '\\0'; p++) {" << "\n";
146 out << " if (*p != '%') {" << "\n";
147 out << " putchar(*p);" << "\n";
148 out << " continue;" << "\n";
149 out << " }" << "\n";
150 out << " switch (*++p) {" << "\n";
151 out << " case 'c':" << "\n";
152 out << " i = va_arg(argp, int);" << "\n";
153 out << " putchar(i);" << "\n";
154 out << " break;" << "\n";
155 out << " case 'd':" << "\n";
156 out << " i = va_arg(argp, int);" << "\n";
157 out << " s = itoa(i, fmtbuf, 10);" << "\n";
158 out << " fputs(s, stdout);" << "\n";
159 out << " break;" << "\n";
160 out << " case 's':" << "\n";
161 out << " s = va_arg(argp, char *);" << "\n";
162 out << " fputs(s, stdout);" << "\n";
163 out << " break;" << "\n";
164 // out << " case 'p':
165 out << " case '%':" << "\n";
166 out << " putchar('%');" << "\n";
167 out << " break;" << "\n";
168 out << " }" << "\n";
169 out << " }" << "\n";
170 out << " va_end(argp);" << "\n";
173 out << "AndroidSystemCallbackRequestMessage callback_message;"
175 out << "callback_message.set_id(GetCallbackID(\"" << callback_name
180 out << "VariableSpecificationMessage* var_msg" << primitive_type_index
183 out << "var_msg" << primitive_type_index << "->set_type("
185 out << "var_msg" << primitive_type_index << "->set_scalar_type(\""
187 out << "var_msg" << primitive_type_index << "->mutable_scalar_value()";
189 out << "->set_" << arg.scalar_type() << "("
192 out << "->set_" << arg.scalar_type() << "("
195 out << "->set_" << arg.scalar_type() << "("
198 out << "->set_" << arg.scalar_type() << "("
201 out << "->set_" << arg.scalar_type() << "("
204 out << "->set_" << arg.scalar_type() << "("
207 out << "->set_" << arg.scalar_type() << "("
210 out << "->set_uint32_t("
213 out << "->set_" << arg.scalar_type() << "("
216 out << "->set_" << arg.scalar_type() << "("
220 out << "->set_" << arg.scalar_type() << "("
224 out << "->set_" << arg.scalar_type() << "("
228 out << "->set_" << arg.scalar_type() << "("
236 out << "var_msg" << primitive_type_index << "->set_type("
245 out << "RpcCallToAgent(callback_message, callback_socket_name_);"
249 out << "return NULL;";
251 out.unindent();
252 out << "}" << "\n";
253 out << "\n";
257 out << "\n";
258 out.unindent();
259 out << " private:" << "\n";
260 out << "};" << "\n";
261 out << "\n";
266 Formatter& out, const ComponentSpecificationMessage& message,
269 GenerateCppBodyFuzzFunction(out, sub_struct, fuzzer_extended_class_name,
274 out << "bool " << fuzzer_extended_class_name << "::Fuzz(" << "\n";
275 out << " FunctionSpecificationMessage* func_msg," << "\n";
276 out << " void** result, const string& callback_socket_name) {" << "\n";
277 out.indent();
278 out << "const char* func_name = func_msg->name().c_str();" << "\n";
279 out << "LOG(INFO) << \" '\" << func_name << \"'\";"
284 out << "if (func_msg->parent_path().length() > 0) {" << "\n";
285 out.indent();
287 GenerateSubStructFuzzFunctionCall(out, sub_struct, "");
289 out.unindent();
290 out << "}" << "\n";
293 out << message.original_data_structure_name()
295 out << "reinterpret_cast<" << message.original_data_structure_name()
298 out << "if (local_device == NULL) {" << "\n";
299 out.indent();
300 out << "LOG(INFO) << \"use hmi \" << (uint64_t)hmi_;"
302 out << "local_device = reinterpret_cast<"
304 out.unindent();
305 out << "}" << "\n";
306 out << "if (local_device == NULL) {" << "\n";
307 out.indent();
308 out << "LOG(ERROR) << \"both device_ and hmi_ are NULL.\";\n";
309 out << "return false;" << "\n";
310 out.unindent();
311 out << "}" << "\n";
314 out << "if (!strcmp(func_name, \"" << api.name() << "\")) {" << "\n";
315 out.indent();
316 out << "LOG(INFO) << \"match\" <<;\n";
325 out << name << "* arg" << arg_count << "callback = new ";
326 out << name << "(callback_socket_name);" << "\n";
327 out << "arg" << arg_count << "callback->Register(func_msg->arg("
330 out << GetCppVariableType(arg) << " ";
331 out << "arg" << arg_count << " = (" << GetCppVariableType(arg)
348 out << "arg" << arg_count << "->"
354 out << "arg" << arg_count << " = arg" << arg_count
368 out << GetCppVariableType(arg) << " ";
369 out << "arg" << arg_count << " = ";
374 out << "reinterpret_cast<" << GetCppVariableType(arg) << ">("
382 out << "(" << msg << ".type() == TYPE_SCALAR)? ";
389 out << "reinterpret_cast<" << GetCppVariableType(arg) << ">";
391 out << "(" << msg << ".scalar_value()";
404 out << "." << arg.scalar_type() << "() ";
409 out << ".pointer() ";
415 out << ") : ";
420 out << "( (" << msg << ".type() == TYPE_PREDEFINED || " << msg
423 out << GetCppInstanceType(arg, msg);
424 out << " : " << GetCppInstanceType(arg) << " )";
428 out << ";" << "\n";
430 out << "LOG(INFO) << \"arg" << arg_count << " = \" << arg" << arg_count
436 GenerateCodeToStartMeasurement(out);
437 out << "LOG(INFO) << \"hit2.\" << device_;\n";
440 out << "if (reinterpret_cast<"
443 out.indent();
444 out << "LOG(ERROR) << \"api not set.\";\n";
447 out << "return false;" << "\n";
448 out.unindent();
449 out << "}" << "\n";
451 out << "LOG(INFO) << \"Call an API.\";\n";
452 out << "LOG(INFO) << \"local_device = \" << local_device;\n";
455 out << "*result = NULL;" << "\n";
457 out << "*result = const_cast<void*>(reinterpret_cast<const void*>(";
459 out << "local_device->" << api.name() << "(";
460 if (arg_count > 0) out << "\n";
463 out << "arg" << index;
465 out << "," << "\n";
470 out << "))";
472 out << ");" << "\n";
473 GenerateCodeToStopMeasurement(out);
474 out << "LOG(INFO) << \"called\";\n";
481 out << GetConversionToProtobufFunctionName(arg) << "(arg"
488 out << "return true;" << "\n";
489 out.unindent();
490 out << "}" << "\n";
493 out << "LOG(ERROR) << \"func not found\";\n";
494 out << "return false;" << "\n";
495 out.unindent();
496 out << "}" << "\n";
500 Formatter& out, const StructSpecificationMessage& message,
505 out, sub_struct, fuzzer_extended_class_name,
514 out << "bool " << fuzzer_extended_class_name << "::Fuzz_"
516 out << "FunctionSpecificationMessage* func_msg," << "\n";
517 out << "void** result, const string& callback_socket_name) {" << "\n";
518 out.indent();
519 out << "const char* func_name = func_msg->name().c_str();" << "\n";
520 out << "LOG(INFO) << func_name;\n";
530 out << "if (!strcmp(func_name, \"" << api.name() << "\")) {" << "\n";
531 out.indent();
533 out << original_data_structure_name << "* local_device = ";
534 out << "reinterpret_cast<" << original_data_structure_name << "*>("
537 out << "if (local_device == NULL) {" << "\n";
538 out.indent();
539 out << "LOG(INFO) << \"use hmi\";\n";
540 out << "local_device = reinterpret_cast<"
542 out.unindent();
543 out << "}" << "\n";
544 out << "if (local_device == NULL) {" << "\n";
545 out.indent();
546 out << "LOG(ERROR) << \"both device_ and hmi_ are NULL.\";\n";
547 out << "return false;" << "\n";
548 out.unindent();
549 out << "}" << "\n";
554 out << GetCppVariableType(arg) << " ";
555 out << "arg" << arg_count << " = ";
560 out << "reinterpret_cast<" << GetCppVariableType(arg) << ">("
568 out << "(" << msg << ".type() == TYPE_SCALAR && " << msg
575 out << ".has_pointer())? ";
576 out << "reinterpret_cast<" << GetCppVariableType(arg) << ">";
578 out << ".has_" << arg.scalar_type() << "())? ";
580 out << "(" << msg << ".scalar_value()";
591 out << "." << arg.scalar_type() << "() ";
597 out << ".pointer() ";
603 out << ") : ";
608 out << "hmi_;" << "\n";
610 out << "((hmi_) ? const_cast<char*>(hmi_->name) : NULL)" << "\n";
612 out << "(struct hw_device_t**) &device_" << "\n";
619 out << "( (" << msg << ".type() == TYPE_PREDEFINED || " << msg
622 out << GetCppInstanceType(arg, msg);
623 out << " : " << GetCppInstanceType(arg) << " )";
628 out << ";" << "\n";
629 out << "LOG(INFO) << \"arg" << arg_count << " = \" << arg" << arg_count
635 GenerateCodeToStartMeasurement(out);
636 out << "LOG(INFO) << \"hit2.\" << device_;\n";
638 out << "if (reinterpret_cast<" << original_data_structure_name
641 out << ") {" << "\n";
642 out.indent();
643 out << "LOG(ERROR) << \"api not set.\";\n";
646 out << "return false;" << "\n";
647 out.unindent();
648 out << "}" << "\n";
650 out << "LOG(INFO) << \"Call an API.\";\n";
652 out << "*result = NULL;" << "\n";
654 out << "*result = const_cast<void*>(reinterpret_cast<const void*>(";
656 out << "local_device" << parent_path << message.name() << "->"
658 if (arg_count > 0) out << "\n";
661 out << "arg" << index;
663 out << "," << "\n";
667 out << "))";
669 out << ");" << "\n";
670 GenerateCodeToStopMeasurement(out);
671 out << "LOG(INFO) << \"called\";\n";
678 out << GetConversionToProtobufFunctionName(arg) << "(arg"
685 out << "return true;" << "\n";
686 out.unindent();
687 out << "}" << "\n";
690 out << "return false;" << "\n";
691 out.unindent();
692 out << "}" << "\n";
696 Formatter& out, const ComponentSpecificationMessage& message,
700 out, sub_struct, fuzzer_extended_class_name,
705 out << "bool " << fuzzer_extended_class_name << "::GetAttribute(" << "\n";
706 out << " FunctionSpecificationMessage* func_msg," << "\n";
707 out << " void** result) {" << "\n";
708 out.indent();
709 out << "const char* func_name = func_msg->name().c_str();" << "\n";
710 out << "LOG(INFO) << \" '\" << func_name << \"'\";\n";
714 out << " if (func_msg->parent_path().length() > 0) {" << "\n";
715 out.indent();
717 GenerateSubStructGetAttributeFunctionCall(out, sub_struct, "");
719 out.unindent();
720 out << "}" << "\n";
723 out << message.original_data_structure_name()
725 out << "reinterpret_cast<" << message.original_data_structure_name()
728 out << "if (local_device == NULL) {" << "\n";
729 out.indent();
730 out << "LOG(INFO) << \"use hmi \" << (uint64_t)hmi_;\n";
731 out << "local_device = reinterpret_cast<"
733 out.unindent();
734 out << "}" << "\n";
735 out << "if (local_device == NULL) {" << "\n";
736 out.indent();
737 out << "LOG(ERROR) << \"both device_ and hmi_ are NULL.\";\n";
738 out << "return false;" << "\n";
739 out.unindent();
740 out << "}" << "\n";
745 out << "if (!strcmp(func_name, \"" << attribute.name() << "\")) {" << "\n";
746 out.indent();
747 out << "LOG(INFO) << \"match\";\n";
750 out << "LOG(INFO) << \"hit2.\" << device_ ;\n";
752 out << "LOG(INFO) << \"ok. let's read attribute.\";\n";
753 out << "*result = const_cast<void*>(reinterpret_cast<const void*>(";
754 out << "local_device->" << attribute.name();
755 out << "));" << "\n";
757 out << "LOG(INFO) << \"got\";\n";
759 out << "return true;" << "\n";
760 out.unindent();
761 out << "}" << "\n";
765 out << "LOG(ERROR) << \"attribute not found\";\n";
766 out << "return false;" << "\n";
767 out.unindent();
768 out << "}" << "\n";
772 Formatter& out, const StructSpecificationMessage& message,
777 out, sub_struct, fuzzer_extended_class_name,
786 out << "bool " << fuzzer_extended_class_name << "::GetAttribute_"
788 out << " FunctionSpecificationMessage* func_msg," << "\n";
789 out << " void** result) {" << "\n";
790 out.indent();
791 out << "const char* func_name = func_msg->name().c_str();" << "\n";
792 out << "LOG(INFO) << func_name;\n";
794 out << original_data_structure_name
796 out << "reinterpret_cast<" << original_data_structure_name
799 out << "if (local_device == NULL) {" << "\n";
800 out.indent();
801 out << " LOG(INFO) << \"use hmi \" << (uint64_t)hmi_;\n";
802 out << " local_device = reinterpret_cast<"
804 out.unindent();
805 out << "}" << "\n";
806 out << "if (local_device == NULL) {" << "\n";
807 out.indent();
808 out << "LOG(ERROR) << \"both device_ and hmi_ are NULL.\";\n";
809 out << "return false;" << "\n";
810 out.unindent();
811 out << "}" << "\n";
816 out << "if (!strcmp(func_name, \"" << attribute.name() << "\")) {" << "\n";
817 out.indent();
818 out << "LOG(INFO) << \"match\";\n";
821 out << "LOG(INFO) << \"hit2.\" << device_;\n";
823 out << "LOG(INFO) << \"ok. let's read attribute.\";\n";
824 out << "*result = const_cast<void*>(reinterpret_cast<const void*>(";
825 out << "local_device" << parent_path << message.name() << ".";
827 out
828 out << "));" << "\n";
830 out << "LOG(INFO) << \"got\";\n";
832 out << "return true;" << "\n";
833 out.unindent();
834 out << "}" << "\n";
838 out << "LOG(ERROR) << \"attribute not found\";\n";
839 out << "return false;" << "\n";
840 out.unindent();
841 out << "}" << "\n";
844 void HalCodeGen::GenerateClassConstructionFunction(Formatter& out,
847 out << fuzzer_extended_class_name << "() : DriverBase(HAL_CONVENTIONAL) {}\n";
851 Formatter& out, const StructSpecificationMessage& message,
863 out << "if (func_msg->parent_path() == \"" << current_path << "\") {"
865 out.indent();
866 out << "return Fuzz__" << current_path_printable
868 out.unindent();
869 out << "}" << "\n";
872 GenerateSubStructFuzzFunctionCall(out, sub_struct, current_path);
877 Formatter& out, const StructSpecificationMessage& message,
889 out << "if (func_msg->parent_path() == \"" << current_path << "\") {"
891 out.indent();
892 out << " return GetAttribute__" << current_path_printable
894 out.unindent();
895 out << "}" << "\n";
898 GenerateSubStructGetAttributeFunctionCall(out, sub_struct, current_path);