diff options
| author | Jean-Luc Brouillet <jeanluc@google.com> | 2015-04-30 14:41:24 -0700 |
|---|---|---|
| committer | Jean-Luc Brouillet <jeanluc@google.com> | 2015-05-28 08:13:21 -0700 |
| commit | 36e2be56cd398bf4a318114bbc9fa3f4573c158f (patch) | |
| tree | 3744816216629e562919c3d9987aa98d82f6568f /api/GenerateHeaderFiles.cpp | |
| parent | c246d91e490df18899490931469d277064070a63 (diff) | |
Generate __attribute__(deprecated) for deprecated APIs.
We allow also a custom deprecation message.
Change-Id: I297bed611c7fbbb34d41e7edd796557c9afe50da
Diffstat (limited to 'api/GenerateHeaderFiles.cpp')
| -rw-r--r-- | api/GenerateHeaderFiles.cpp | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/api/GenerateHeaderFiles.cpp b/api/GenerateHeaderFiles.cpp index 45cdba94..e908ff1b 100644 --- a/api/GenerateHeaderFiles.cpp +++ b/api/GenerateHeaderFiles.cpp @@ -129,12 +129,17 @@ static void writeTypeSpecification(GeneratedFile* file, const TypeSpecification& const string& typeName = type->getName(); const VersionInfo info = spec.getVersionInfo(); writeVersionGuardStart(file, info, type->getFinalVersion()); + + const string attribute = + makeAttributeTag(spec.getAttribute(), "", type->getDeprecatedApiLevel(), + type->getDeprecatedMessage()); + *file << "typedef "; switch (spec.getKind()) { case SIMPLE: - *file << "typedef " << spec.getSimpleType() << " " << typeName << ";\n"; + *file << spec.getSimpleType() << attribute; break; case ENUM: { - *file << "typedef enum "; + *file << "enum" << attribute << " "; const string name = spec.getEnumName(); if (!name.empty()) { *file << name << " "; @@ -154,11 +159,11 @@ static void writeTypeSpecification(GeneratedFile* file, const TypeSpecification& } *file << "\n"; } - *file << "} " << typeName << ";\n"; + *file << "}"; break; } case STRUCT: { - *file << "typedef struct "; + *file << "struct" << attribute << " "; const string name = spec.getStructName(); if (!name.empty()) { *file << name << " "; @@ -174,15 +179,12 @@ static void writeTypeSpecification(GeneratedFile* file, const TypeSpecification& } *file << "\n"; } - *file << "} "; - const string attrib = spec.getAttrib(); - if (!attrib.empty()) { - *file << attrib << " "; - } - *file << typeName << ";\n"; + *file << "}"; break; } } + *file << " " << typeName << ";\n"; + writeVersionGuardEnd(file, info); *file << "\n"; } @@ -213,20 +215,9 @@ static void writeFunctionPermutation(GeneratedFile* file, const FunctionSpecific *file << "void"; } - // Write the attribute. - *file << " __attribute__(("; - const string attrib = spec.getAttribute(); - if (attrib.empty()) { - *file << "overloadable"; - } else if (attrib[0] == '=') { - /* If starts with an equal, we don't automatically add overloadable. - * This is because of the error we made defining rsUnpackColor8888(). - */ - *file << attrib.substr(1); - } else { - *file << attrib << ", overloadable"; - } - *file << "))\n"; + *file << makeAttributeTag(spec.getAttribute(), "overloadable", + function->getDeprecatedApiLevel(), function->getDeprecatedMessage()); + *file << "\n"; // Write the function name. *file << " " << permutation.getName() << "("; |
