Home | History | Annotate | Download | only in driver
      1 /*
      2  * Copyright 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 
     17 #include "code_gen/driver/HalSubmoduleCodeGen.h"
     18 
     19 #include <fstream>
     20 #include <iostream>
     21 #include <sstream>
     22 #include <string>
     23 
     24 #include "test/vts/proto/ComponentSpecificationMessage.pb.h"
     25 
     26 #include "VtsCompilerUtils.h"
     27 
     28 using namespace std;
     29 using namespace android;
     30 
     31 namespace android {
     32 namespace vts {
     33 
     34 const char* const HalSubmoduleCodeGen::kInstanceVariableName = "submodule_";
     35 
     36 void HalSubmoduleCodeGen::GenerateClassConstructionFunction(Formatter& out,
     37     const ComponentSpecificationMessage& /*message*/,
     38     const string& fuzzer_extended_class_name) {
     39   out << fuzzer_extended_class_name
     40       << "() : DriverBase(HAL_CONVENTIONAL_SUBMODULE) {}\n";
     41 }
     42 
     43 void HalSubmoduleCodeGen::GenerateAdditionalFuctionDeclarations(Formatter& out,
     44     const ComponentSpecificationMessage& message,
     45     const string& /*fuzzer_extended_class_name*/) {
     46   string component_name = GetComponentName(message);
     47   out << "void SetSubModule(" << component_name << "* submodule) {" << "\n";
     48   out.indent();
     49   out << "submodule_ = submodule;" << "\n";
     50   out.unindent();
     51   out << "}" << "\n" << "\n";
     52 }
     53 
     54 void HalSubmoduleCodeGen::GeneratePrivateMemberDeclarations(Formatter& out,
     55     const ComponentSpecificationMessage& message) {
     56   out << message.original_data_structure_name() << "* submodule_;\n";
     57 }
     58 
     59 }  // namespace vts
     60 }  // namespace android
     61