1c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* 2c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * Copyright (C) 2015 The Android Open Source Project 3c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * 4c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * Licensed under the Apache License, Version 2.0 (the "License"); 5c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * you may not use this file except in compliance with the License. 6c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * You may obtain a copy of the License at 7c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * 8c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * http://www.apache.org/licenses/LICENSE-2.0 9c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * 10c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * Unless required by applicable law or agreed to in writing, software 11c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * distributed under the License is distributed on an "AS IS" BASIS, 12c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * See the License for the specific language governing permissions and 14c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * limitations under the License. 15c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 16c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 17c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet#ifndef ANDROID_RS_API_GENERATOR_SPECIFICATION_H 18c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet#define ANDROID_RS_API_GENERATOR_SPECIFICATION_H 19c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 20c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet// See Generator.cpp for documentation of the .spec file format. 21c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 2212398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni#include <climits> 23c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet#include <fstream> 24c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet#include <list> 25c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet#include <map> 26c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet#include <string> 27c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet#include <vector> 28c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 29c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass Constant; 30c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass ConstantSpecification; 31c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass Function; 32c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass FunctionPermutation; 33c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass FunctionSpecification; 34c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass SpecFile; 35c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass Specification; 36c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass Scanner; 37c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass SystemSpecification; 38c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass Type; 39c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass TypeSpecification; 40c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 41c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletenum NumberKind { SIGNED_INTEGER, UNSIGNED_INTEGER, FLOATING_POINT }; 42c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 43c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet// Table of type equivalences. 44c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletstruct NumericalType { 45c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const char* specType; // Name found in the .spec file 46c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const char* rsDataType; // RS data type 47c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const char* cType; // Type in a C file 48c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const char* javaType; // Type in a Java file 49c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet NumberKind kind; 50c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* For integers, number of bits of the number, excluding the sign bit. 51c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * For floats, number of implied bits of the mantissa. 52c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 53c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int significantBits; 54c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // For floats, number of bits of the exponent. 0 for integer types. 55c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int exponentBits; 56c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 57c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 58c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* Corresponds to one parameter line in a .spec file. These will be parsed when 59c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * we instantiate the FunctionPermutation(s) that correspond to one FunctionSpecification. 60c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 61c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletstruct ParameterEntry { 62c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string type; 63c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string name; 64c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* Optional information on how to generate test values for this parameter. Can be: 65c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * - range(low, high): Generates values between these two limits only. 66c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * - above(other_parameter): The values must be greater than those of the named parameter. 67c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * Used for clamp. 68c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * - compatible(type): The values must also be fully representable in the specified type. 69c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * - conditional: Don't verify this value the function return NaN. 70c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 71c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string testOption; 72c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string documentation; 73c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int lineNumber; 74c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 75c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 76c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* Information about a parameter to a function. The values of all the fields should only be set by 77c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * parseParameterDefinition. 78c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 79c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletstruct ParameterDefinition { 80c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string rsType; // The Renderscript type, e.g. "uint3" 81c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string rsBaseType; // As above but without the number, e.g. "uint" 82c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string javaBaseType; // The type we need to declare in Java, e.g. "unsigned int" 83c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string specType; // The type found in the spec, e.g. "f16" 84c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet bool isFloatType; // True if it's a floating point value 85c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* The number of entries in the vector. It should be either "1", "2", "3", or "4". It's also 86c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * "1" for scalars. 87c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 88c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mVectorSize; 89c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* The space the vector takes in an array. It's the same as the vector size, except for size 90c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * "3", where the width is "4". 91c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 92c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string vectorWidth; 93c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 94c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string specName; // e.g. x, as found in the spec file 95c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string variableName; // e.g. inX, used both in .rs and .java 96c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string rsAllocName; // e.g. gAllocInX 97c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string javaAllocName; // e.g. inX 98c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string javaArrayName; // e.g. arrayInX 993b2be14b4f4e1932f4e67c12d691ca85e937d936Pirama Arumuga Nainar std::string doubleVariableName; // e.g. inXDouble, used in .java for storing Float16 parameters 1003b2be14b4f4e1932f4e67c12d691ca85e937d936Pirama Arumuga Nainar // in double. 101c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 102c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // If non empty, the mininum and maximum values to be used when generating the test data. 103c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string minValue; 104c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string maxValue; 105c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* If non empty, contains the name of another parameter that should be smaller or equal to this 106c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * parameter, i.e. value(smallerParameter) <= value(this). This is used when testing clamp. 107c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 108c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string smallerParameter; 109c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 110c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet bool isOutParameter; // True if this parameter returns data from the script. 111c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet bool undefinedIfOutIsNan; // If true, we don't validate if 'out' is NaN. 112c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 113c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int typeIndex; // Index in the TYPES array. Negative if not found in the array. 114c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int compatibleTypeIndex; // Index in TYPES for which the test data must also fit. 115c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 116c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* Fill this object from the type, name, and testOption. 117c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * isReturn is true if we're processing the "return:" 118c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 119c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void parseParameterDefinition(const std::string& type, const std::string& name, 120c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::string& testOption, int lineNumber, bool isReturn, 121c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet Scanner* scanner); 1223b2be14b4f4e1932f4e67c12d691ca85e937d936Pirama Arumuga Nainar 1233b2be14b4f4e1932f4e67c12d691ca85e937d936Pirama Arumuga Nainar bool isFloat16Parameter() const { return specType.compare("f16") == 0; } 124c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 125c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 126c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletstruct VersionInfo { 127c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* The range of versions a specification applies to. Zero if there's no restriction, 128c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * so an API that became available at 12 and is still valid would have min:12 max:0. 129c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * If non zero, both versions should be at least 9, the API level that introduced 130c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * RenderScript. 131c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 13212398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni unsigned int minVersion; 13312398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni unsigned int maxVersion; 134c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Either 0, 32 or 64. If 0, this definition is valid for both 32 and 64 bits. 135c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int intSize; 136c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 137c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet VersionInfo() : minVersion(0), maxVersion(0), intSize(0) {} 1382217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet /* Scan the version info from the spec file. maxApiLevel specifies the maximum level 1392217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet * we are interested in. This may alter maxVersion. This method returns false if the 1402217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet * minVersion is greater than the maxApiLevel. 1412217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet */ 14212398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni bool scan(Scanner* scanner, unsigned int maxApiLevel); 14336090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet /* Return true if the target can be found whitin the range. */ 14436090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet bool includesVersion(int target) const { 14536090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet return (minVersion == 0 || target >= minVersion) && 14636090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet (maxVersion == 0 || target <= maxVersion); 14736090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet } 14812398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni 14912398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni static constexpr unsigned int kUnreleasedVersion = UINT_MAX; 150c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 151c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 152c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet// We have three type of definitions 153c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass Definition { 154c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprotected: 155c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mName; 15636e2be56cd398bf4a318114bbc9fa3f4573c158fJean-Luc Brouillet /* If greater than 0, this definition is deprecated. It's the API level at which 15736e2be56cd398bf4a318114bbc9fa3f4573c158fJean-Luc Brouillet * we added the deprecation warning. 15836e2be56cd398bf4a318114bbc9fa3f4573c158fJean-Luc Brouillet */ 15936e2be56cd398bf4a318114bbc9fa3f4573c158fJean-Luc Brouillet int mDeprecatedApiLevel; 1604a73004df5231d188c41267fee17c566ae7c3631Jean-Luc Brouillet std::string mDeprecatedMessage; // Optional specific warning if the API is deprecated 161c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet bool mHidden; // True if it should not be documented 162c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mSummary; // A one-line description 163c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string> mDescription; // The comments to be included in the header 164c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mUrl; // The URL of the detailed documentation 16567923a9e829d89522bb5338a6d635d807a7ee59bJean-Luc Brouillet int mFinalVersion; // API level at which this API was removed, 0 if API is still valid 166c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 167c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 1687c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Definition(const std::string& name); 169c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 170c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getName() const { return mName; } 17136e2be56cd398bf4a318114bbc9fa3f4573c158fJean-Luc Brouillet bool deprecated() const { return mDeprecatedApiLevel > 0; } 17236e2be56cd398bf4a318114bbc9fa3f4573c158fJean-Luc Brouillet int getDeprecatedApiLevel() const { return mDeprecatedApiLevel; } 1734a73004df5231d188c41267fee17c566ae7c3631Jean-Luc Brouillet std::string getDeprecatedMessage() const { return mDeprecatedMessage; } 174c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet bool hidden() const { return mHidden; } 175c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getSummary() const { return mSummary; } 176c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<std::string>& getDescription() const { return mDescription; } 177c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getUrl() const { return mUrl; } 17867923a9e829d89522bb5338a6d635d807a7ee59bJean-Luc Brouillet int getFinalVersion() const { return mFinalVersion; } 179c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 1807c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet void scanDocumentationTags(Scanner* scanner, bool firstOccurence, const SpecFile* specFile); 18167923a9e829d89522bb5338a6d635d807a7ee59bJean-Luc Brouillet // Keep track of the final version of this API, if any. 18267923a9e829d89522bb5338a6d635d807a7ee59bJean-Luc Brouillet void updateFinalVersion(const VersionInfo& info); 183c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 184c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 185c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* Represents a constant, like M_PI. This is a grouping of the version specific specifications. 186c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * We'll only have one instance of Constant for each name. 187c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 188c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass Constant : public Definition { 189c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprivate: 190c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<ConstantSpecification*> mSpecifications; // Owned 191c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 192c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 1937c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Constant(const std::string& name) : Definition(name) {} 194c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet ~Constant(); 195c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 196c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<ConstantSpecification*> getSpecifications() const { return mSpecifications; } 197c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // This method should only be called by the scanning code. 198c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void addSpecification(ConstantSpecification* spec) { mSpecifications.push_back(spec); } 199c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 200c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 201c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* Represents a type, like "float4". This is a grouping of the version specific specifications. 202c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * We'll only have one instance of Type for each name. 203c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 204c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass Type : public Definition { 205c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprivate: 206c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<TypeSpecification*> mSpecifications; // Owned 207c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 208c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 2097c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Type(const std::string& name) : Definition(name) {} 210c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet ~Type(); 211c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 212c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<TypeSpecification*> getSpecifications() const { return mSpecifications; } 213c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // This method should only be called by the scanning code. 214c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void addSpecification(TypeSpecification* spec) { mSpecifications.push_back(spec); } 215c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 216c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 217c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* Represents a function, like "clamp". Even though the spec file contains many entries for clamp, 218c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * we'll only have one clamp instance. 219c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 220c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass Function : public Definition { 221c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprivate: 222c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // mName in the base class contains the lower case name, e.g. native_log 223c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mCapitalizedName; // The capitalized name, e.g. NativeLog 224c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 225c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // The unique parameters between all the specifications. NOT OWNED. 226c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<ParameterEntry*> mParameters; 227c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mReturnDocumentation; 228c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 229c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<FunctionSpecification*> mSpecifications; // Owned 230c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 231c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 2327c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Function(const std::string& name); 233c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet ~Function(); 234c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 235c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getCapitalizedName() const { return mCapitalizedName; } 236c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<ParameterEntry*>& getParameters() const { return mParameters; } 237c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getReturnDocumentation() const { return mReturnDocumentation; } 238c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<FunctionSpecification*> getSpecifications() const { return mSpecifications; } 239c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 240c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet bool someParametersAreDocumented() const; 241c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 242c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // The following methods should only be called by the scanning code. 243c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void addParameter(ParameterEntry* entry, Scanner* scanner); 244c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void addReturn(ParameterEntry* entry, Scanner* scanner); 245c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void addSpecification(FunctionSpecification* spec) { mSpecifications.push_back(spec); } 246c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 247c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 248c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* Base class for TypeSpecification, ConstantSpecification, and FunctionSpecification. 249c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * A specification can be specific to a range of RenderScript version or 32bits vs 64 bits. 250c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * This base class contains code to parse and store this version information. 251c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 252c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass Specification { 253c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprotected: 254c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet VersionInfo mVersionInfo; 255c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void scanVersionInfo(Scanner* scanner); 256c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 257c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 258c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet VersionInfo getVersionInfo() const { return mVersionInfo; } 259c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 260c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 261c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* Defines one of the many variations of a constant. There's a one to one correspondance between 262c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * ConstantSpecification objects and entries in the spec file. 263c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 264c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass ConstantSpecification : public Specification { 265c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprivate: 2667c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Constant* mConstant; // Not owned 2677c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet 268c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mValue; // E.g. "3.1415" 269c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 2707c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet ConstantSpecification(Constant* constant) : mConstant(constant) {} 2717c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet 2727c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Constant* getConstant() const { return mConstant; } 273c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getValue() const { return mValue; } 274c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 275c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Parse a constant specification and add it to specFile. 27612398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni static void scanConstantSpecification(Scanner* scanner, SpecFile* specFile, unsigned int maxApiLevel); 277c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 278c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 279c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletenum TypeKind { 280c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet SIMPLE, 281ca51c78b9e3097ee31dd24cdc5982f550ee563d1Stephen Hines RS_OBJECT, 282c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet STRUCT, 283c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet ENUM, 284c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 285c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 286c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* Defines one of the many variations of a type. There's a one to one correspondance between 287c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * TypeSpecification objects and entries in the spec file. 288c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 289c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass TypeSpecification : public Specification { 290c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprivate: 2917c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Type* mType; // Not owned 2927c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet 293c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet TypeKind mKind; // The kind of type specification 294c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 295c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // If mKind is SIMPLE: 296c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mSimpleType; // The definition of the type 297c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 298c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // If mKind is STRUCT: 299c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mStructName; // The name found after the struct keyword 300c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string> mFields; // One entry per struct field 301c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string> mFieldComments; // One entry per struct field 30236e2be56cd398bf4a318114bbc9fa3f4573c158fJean-Luc Brouillet std::string mAttribute; // Some structures may have attributes 303c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 304c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // If mKind is ENUM: 305c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mEnumName; // The name found after the enum keyword 306c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string> mValues; // One entry per enum value 307c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string> mValueComments; // One entry per enum value 308c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 3097c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet TypeSpecification(Type* type) : mType(type) {} 3107c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet 3117c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Type* getType() const { return mType; } 312c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet TypeKind getKind() const { return mKind; } 313c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getSimpleType() const { return mSimpleType; } 314c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getStructName() const { return mStructName; } 315c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<std::string>& getFields() const { return mFields; } 316c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<std::string>& getFieldComments() const { return mFieldComments; } 31736e2be56cd398bf4a318114bbc9fa3f4573c158fJean-Luc Brouillet std::string getAttribute() const { return mAttribute; } 318c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getEnumName() const { return mEnumName; } 319c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<std::string>& getValues() const { return mValues; } 320c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<std::string>& getValueComments() const { return mValueComments; } 321c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 322c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Parse a type specification and add it to specFile. 32312398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni static void scanTypeSpecification(Scanner* scanner, SpecFile* specFile, unsigned int maxApiLevel); 324c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 325c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 326c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet// Maximum number of placeholders (like #1, #2) in function specifications. 327c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletconst int MAX_REPLACEABLES = 4; 328c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 329c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* Defines one of the many variations of the function. There's a one to one correspondance between 330c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * FunctionSpecification objects and entries in the spec file. Some of the strings that are parts 331c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * of a FunctionSpecification can include placeholders, which are "#1", "#2", "#3", and "#4". We'll 332c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * replace these by values before generating the files. 333c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 334c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass FunctionSpecification : public Specification { 335c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprivate: 3367c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Function* mFunction; // Not owned 3377c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet 338c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* How to test. One of: 339c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * "scalar": Generate test code that checks entries of each vector indepently. E.g. for 340c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * sin(float3), the test code will call the CoreMathVerfier.computeSin 3 times. 341c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * "limited": Like "scalar" but we don't generate extreme values. This is not currently 342c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * enabled as we were generating to many errors. 343c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * "custom": Like "scalar" but instead of calling CoreMathVerifier.computeXXX() to compute 344c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * the expected value, we call instead CoreMathVerifier.verifyXXX(). This method 345c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * returns a string that contains the error message, null if there's no error. 346c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * "vector": Generate test code that calls the CoreMathVerifier only once for each vector. 347c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * This is useful for APIs like dot() or length(). 348c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * "noverify": Generate test code that calls the API but don't verify the returned value. 349c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * This can discover unresolved references. 35066fea24fb5f3a02b744a9c71ae0fc22c03c4fc6eJean-Luc Brouillet * "": Don't test. This is the default. 351c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 352c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mTest; 35312398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni bool mInternal; // Internal. Not visible to users. (Default: false) 35412398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni bool mIntrinsic; // Compiler intrinsic that is lowered to an internal API. 35512398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni // (Default: false) 356c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mAttribute; // Function attributes. 357c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mPrecisionLimit; // Maximum precision required when checking output of this 358c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // function. 359c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 360c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // The vectors of values with which we'll replace #1, #2, ... 361c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::vector<std::string> > mReplaceables; 362c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 36343d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar // i-th entry is true if each entry in mReplaceables[i] has an equivalent 36443d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar // RS numerical type (i.e. present in TYPES global) 36543d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar std::vector<bool> mIsRSTAllowed; 36643d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar 367c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* The collection of permutations for this specification, i.e. this class instantianted 368c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * for specific values of #1, #2, etc. Owned. 369c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 370c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<FunctionPermutation*> mPermutations; 371c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 372c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // The following fields may contain placeholders that will be replaced using the mReplaceables. 373c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 374c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* As of this writing, convert_... is the only function with #1 in its name. 375c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * The related Function object contains the name of the function without #n, e.g. convert. 376c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * This is the name with the #, e.g. convert_#1_#2 377c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 378c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mUnexpandedName; 3792217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet ParameterEntry* mReturn; // The return type. The name should be empty. Owned. 380c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<ParameterEntry*> mParameters; // The parameters. Owned. 381c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string> mInline; // The inline code to be included in the header 382c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 38343d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar /* Substitute the placeholders in the strings (e.g. #1, #2, ...) by the 38443d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar * corresponding entries in mReplaceables. Substitute placeholders for RS 38543d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar * types (#RST_1, #RST_2, ...) by the RS Data type strings (UNSIGNED_8, 38643d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar * FLOAT_32 etc.) of the corresponding types in mReplaceables. 38743d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar * indexOfReplaceable1 selects with value to use for #1, same for 2, 3, and 38843d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar * 4. 389c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 390c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string expandString(std::string s, int indexOfReplaceable[MAX_REPLACEABLES]) const; 391c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void expandStringVector(const std::vector<std::string>& in, 392c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int replacementIndexes[MAX_REPLACEABLES], 393c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string>* out) const; 394c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 39543d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar // Helper function used by expandString to perform #RST_* substitution 39643d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar std::string expandRSTypeInString(const std::string &s, 39743d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar const std::string &pattern, 39843d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar const std::string &cTypeStr) const; 39943d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar 400c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Fill the mPermutations field. 401c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void createPermutations(Function* function, Scanner* scanner); 402c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 403c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 40412398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni FunctionSpecification(Function* function) : mFunction(function), mInternal(false), 40512398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni mIntrinsic(false), mReturn(nullptr) {} 406c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet ~FunctionSpecification(); 407c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 40867923a9e829d89522bb5338a6d635d807a7ee59bJean-Luc Brouillet Function* getFunction() const { return mFunction; } 40912398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni bool isInternal() const { return mInternal; } 41012398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni bool isIntrinsic() const { return mIntrinsic; } 411c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getAttribute() const { return mAttribute; } 412c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getTest() const { return mTest; } 413c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getPrecisionLimit() const { return mPrecisionLimit; } 414c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 415c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<FunctionPermutation*>& getPermutations() const { return mPermutations; } 416c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 417c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getName(int replacementIndexes[MAX_REPLACEABLES]) const; 418c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void getReturn(int replacementIndexes[MAX_REPLACEABLES], std::string* retType, 419c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int* lineNumber) const; 420c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet size_t getNumberOfParams() const { return mParameters.size(); } 421c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void getParam(size_t index, int replacementIndexes[MAX_REPLACEABLES], std::string* type, 422c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string* name, std::string* testOption, int* lineNumber) const; 423c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void getInlines(int replacementIndexes[MAX_REPLACEABLES], 424c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string>* inlines) const; 425c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 426c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Parse the "test:" line. 427c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet void parseTest(Scanner* scanner); 428c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 429c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Return true if we need to generate tests for this function. 43012398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni bool hasTests(unsigned int versionOfTestFiles) const; 431c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 43236090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet bool hasInline() const { return mInline.size() > 0; } 43336090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet 43436090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet /* Return true if this function can be overloaded. This is added by default to all 43536090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet * specifications, so except for the very few exceptions that start the attributes 43636090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet * with an '=' to avoid this, we'll return true. 43736090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet */ 43836090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet bool isOverloadable() const { 43936090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet return mAttribute.empty() || mAttribute[0] != '='; 44036090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet } 44136090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet 44243d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar /* Check if RST_i is present in 's' and report an error if 'allow' is false 44343d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar * or the i-th replacement list is not a valid candidate for RST_i 44443d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar * replacement 44543d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar */ 44643d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar void checkRSTPatternValidity(const std::string &s, bool allow, Scanner *scanner); 44743d758c56868560fdd3cdcfeea599819ed037031Pirama Arumuga Nainar 448c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Parse a function specification and add it to specFile. 44912398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni static void scanFunctionSpecification(Scanner* scanner, SpecFile* specFile, unsigned int maxApiLevel); 450c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 451c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 452c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet/* A concrete version of a function specification, where all placeholders have been replaced by 453c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * actual values. 454c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 455c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass FunctionPermutation { 456c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprivate: 457c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // These are the expanded version of those found on FunctionSpecification 458c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mName; 459c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mNameTrunk; // The name without any expansion, e.g. convert 460c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mTest; // How to test. One of "scalar", "vector", "noverify", "limited", and 461c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // "none". 462c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mPrecisionLimit; // Maximum precision required when checking output of this 463c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // function. 464c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 465c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // The parameters of the function. This does not include the return type. Owned. 466c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<ParameterDefinition*> mParams; 467c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // The return type. nullptr if a void function. Owned. 468c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet ParameterDefinition* mReturn; 469c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 470c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // The number of input and output parameters. mOutputCount counts the return type. 471c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int mInputCount; 472c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int mOutputCount; 473c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 474c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Whether one of the output parameters is a float. 475c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet bool mHasFloatAnswers; 476c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 477c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // The inline code that implements this function. Will be empty if not an inline. 478c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string> mInline; 479c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 480c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 481c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet FunctionPermutation(Function* function, FunctionSpecification* specification, 482c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int replacementIndexes[MAX_REPLACEABLES], Scanner* scanner); 483c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet ~FunctionPermutation(); 484c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 485c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getName() const { return mName; } 486c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getNameTrunk() const { return mNameTrunk; } 487c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getTest() const { return mTest; } 488c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getPrecisionLimit() const { return mPrecisionLimit; } 489c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 49066fea24fb5f3a02b744a9c71ae0fc22c03c4fc6eJean-Luc Brouillet const std::vector<std::string>& getInline() const { return mInline; } 491c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const ParameterDefinition* getReturn() const { return mReturn; } 492c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int getInputCount() const { return mInputCount; } 493c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet int getOutputCount() const { return mOutputCount; } 494c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet bool hasFloatAnswers() const { return mHasFloatAnswers; } 495c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 496c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<ParameterDefinition*> getParams() const { return mParams; } 497c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 498c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 499c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet// An entire spec file and the methods to process it. 500c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass SpecFile { 501c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprivate: 502c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mSpecFileName; 503c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mHeaderFileName; 504c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mDetailedDocumentationUrl; 505c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string mBriefDescription; 506c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string> mFullDescription; 507c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Text to insert as-is in the generated header. 508c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<std::string> mVerbatimInclude; 509c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 5107c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet /* The constants, types, and functions specifications declared in this 5117c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet * file, in the order they are found in the file. This matters for 512c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet * header generation, as some types and inline functions depend 5137c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet * on each other. Pointers not owned. 514c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 5157c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet std::list<ConstantSpecification*> mConstantSpecificationsList; 5167c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet std::list<TypeSpecification*> mTypeSpecificationsList; 5177c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet std::list<FunctionSpecification*> mFunctionSpecificationsList; 5187c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet 5197c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet /* The constants, types, and functions that are documented in this file. 5207c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet * In very rare cases, specifications for an API are split across multiple 5217c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet * files, e.g. currently for ClearObject(). The documentation for 5227c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet * that function must be found in the first spec file encountered, so the 5237c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet * order of the files on the command line matters. 5247c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet */ 5257c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet std::map<std::string, Constant*> mDocumentedConstants; 5267c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet std::map<std::string, Type*> mDocumentedTypes; 5277c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet std::map<std::string, Function*> mDocumentedFunctions; 528c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 529c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 530c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet explicit SpecFile(const std::string& specFileName); 531c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 532c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getSpecFileName() const { return mSpecFileName; } 533c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getHeaderFileName() const { return mHeaderFileName; } 534c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getDetailedDocumentationUrl() const { return mDetailedDocumentationUrl; } 535c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::string getBriefDescription() const { return mBriefDescription; } 536c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<std::string>& getFullDescription() const { return mFullDescription; } 537c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<std::string>& getVerbatimInclude() const { return mVerbatimInclude; } 538c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 5397c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet const std::list<ConstantSpecification*>& getConstantSpecifications() const { 5407c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet return mConstantSpecificationsList; 5417c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet } 5427c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet const std::list<TypeSpecification*>& getTypeSpecifications() const { 5437c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet return mTypeSpecificationsList; 5447c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet } 5457c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet const std::list<FunctionSpecification*>& getFunctionSpecifications() const { 5467c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet return mFunctionSpecificationsList; 5477c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet } 5487c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet const std::map<std::string, Constant*>& getDocumentedConstants() const { 5497c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet return mDocumentedConstants; 5507c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet } 5517c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet const std::map<std::string, Type*>& getDocumentedTypes() const { return mDocumentedTypes; } 5527c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet const std::map<std::string, Function*>& getDocumentedFunctions() const { 5537c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet return mDocumentedFunctions; 5547c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet } 555c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 5562217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet bool hasSpecifications() const { 5572217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet return !mDocumentedConstants.empty() || !mDocumentedTypes.empty() || 5582217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet !mDocumentedFunctions.empty(); 5592217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet } 5602217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet 56112398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni bool readSpecFile(unsigned int maxApiLevel); 562c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 5637c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet /* These are called by the parser to keep track of the specifications defined in this file. 5647c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet * hasDocumentation is true if this specification containes the documentation. 5657c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet */ 5667c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet void addConstantSpecification(ConstantSpecification* spec, bool hasDocumentation); 5677c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet void addTypeSpecification(TypeSpecification* spec, bool hasDocumentation); 5687c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet void addFunctionSpecification(FunctionSpecification* spec, bool hasDocumentation); 569c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 570c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 571c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet// The collection of all the spec files. 572c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletclass SystemSpecification { 573c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletprivate: 574c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::vector<SpecFile*> mSpecFiles; 575c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 576c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet /* Entries in the table of contents. We accumulate them in a map to sort them. 5777c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet * Pointers are owned. 578c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet */ 579c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::map<std::string, Constant*> mConstants; 580c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::map<std::string, Type*> mTypes; 581c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::map<std::string, Function*> mFunctions; 582c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 583c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletpublic: 584c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet ~SystemSpecification(); 5857c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet 5867c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet /* These are called the parser to create unique instances per name. Set *created to true 5877c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet * if the named specification did not already exist. 5887c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet */ 5897c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Constant* findOrCreateConstant(const std::string& name, bool* created); 5907c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Type* findOrCreateType(const std::string& name, bool* created); 5917c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet Function* findOrCreateFunction(const std::string& name, bool* created); 5927c07854a959eb70ff9623202b2ca064407a1cc68Jean-Luc Brouillet 5932217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet /* Parse the spec file and create the object hierarchy, adding a pointer to mSpecFiles. 5942217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet * We won't include information passed the specified level. 5952217eb7b12e598e5b435a732207647918c171560Jean-Luc Brouillet */ 59612398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni bool readSpecFile(const std::string& fileName, unsigned int maxApiLevel); 597c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Generate all the files. 59812398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni bool generateFiles(bool forVerification, unsigned int maxApiLevel) const; 599c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 600c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::vector<SpecFile*>& getSpecFiles() const { return mSpecFiles; } 601c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::map<std::string, Constant*>& getConstants() const { return mConstants; } 602c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::map<std::string, Type*>& getTypes() const { return mTypes; } 603c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet const std::map<std::string, Function*>& getFunctions() const { return mFunctions; } 604c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 605c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet // Returns "<a href='...'> for the named specification, or empty if not found. 606c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet std::string getHtmlAnchor(const std::string& name) const; 60736090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet 60836090673baf50cf3c70bdc89f9a4a872c05cf0f6Jean-Luc Brouillet // Returns the maximum API level specified in any spec file. 60912398d81f32e5e0479d02b8608a83c75cd991bb3Yang Ni unsigned int getMaximumApiLevel(); 610c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet}; 611c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 612c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet// Singleton that represents the collection of all the specs we're processing. 613c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletextern SystemSpecification systemSpecification; 614c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 615c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet// Table of equivalences of numerical types. 616c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletextern const NumericalType TYPES[]; 617c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouilletextern const int NUM_TYPES; 618c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet 6199309a0665a4866f708db9ae67e43b5ea6a27cf27Dean De Leo/* Given a renderscript type (string) calculate the vector size and base type. If the type 6209309a0665a4866f708db9ae67e43b5ea6a27cf27Dean De Leo * is not a vector the vector size is 1 and baseType is just the type itself. 6219309a0665a4866f708db9ae67e43b5ea6a27cf27Dean De Leo */ 6229309a0665a4866f708db9ae67e43b5ea6a27cf27Dean De Leovoid getVectorSizeAndBaseType(const std::string& type, std::string& vectorSize, 6239309a0665a4866f708db9ae67e43b5ea6a27cf27Dean De Leo std::string& baseType); 6249309a0665a4866f708db9ae67e43b5ea6a27cf27Dean De Leo 625c5184e202ced435258adb2cfe2013570e7190954Jean-Luc Brouillet#endif // ANDROID_RS_API_GENERATOR_SPECIFICATION_H 626