2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include "EntryPoint.h"
24 class ApiGen : public std::vector<EntryPoint> {
27 typedef std::vector<std::string> StringVec;
28 typedef enum { CLIENT_SIDE, SERVER_SIDE, WRAPPER_SIDE } SideType;
30 ApiGen(const std::string & basename) :
32 m_maxEntryPointsParams(0),
36 int readSpec(const std::string & filename);
37 int readAttributes(const std::string & attribFilename);
38 size_t maxEntryPointsParams() { return m_maxEntryPointsParams; }
39 void updateMaxEntryPointsParams(size_t val) {
40 if (m_maxEntryPointsParams == 0 || val > m_maxEntryPointsParams) m_maxEntryPointsParams = val;
42 int baseOpcode() { return m_baseOpcode; }
43 void setBaseOpcode(int base) { m_baseOpcode = base; }
45 const char *sideString(SideType side) {
63 StringVec & clientContextHeaders() { return m_clientContextHeaders; }
64 StringVec & encoderHeaders() { return m_encoderHeaders; }
65 StringVec & serverContextHeaders() { return m_serverContextHeaders; }
66 StringVec & decoderHeaders() { return m_decoderHeaders; }
68 EntryPoint * findEntryByName(const std::string & name);
69 int genOpcodes(const std::string &filename);
70 int genAttributesTemplate(const std::string &filename);
71 int genProcTypes(const std::string &filename, SideType side);
72 int genFuncTable(const std::string &filename, SideType side);
74 int genContext(const std::string &filename, SideType side);
75 int genContextImpl(const std::string &filename, SideType side);
77 int genEntryPoints(const std::string &filename, SideType side);
79 int genEncoderHeader(const std::string &filename);
80 int genEncoderImpl(const std::string &filename);
82 int genDecoderHeader(const std::string &filename);
83 int genDecoderImpl(const std::string &filename);
86 virtual void printHeader(FILE *fp) const;
87 std::string m_basename;
88 StringVec m_clientContextHeaders;
89 StringVec m_encoderHeaders;
90 StringVec m_serverContextHeaders;
91 StringVec m_decoderHeaders;
92 size_t m_maxEntryPointsParams; // record the maximum number of parameters in the entry points;
94 int setGlobalAttribute(const std::string & line, size_t lc);