mirror of https://github.com/libAthena/athena.git
Global: Make SeekOrigin an enum class
Makes the enumeration strongly typed and also allows forward declaring the enumeration type as well.
This commit is contained in:
parent
2392dde366
commit
9bde23011f
|
@ -629,7 +629,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||||
} else if (!tsDecl->getName().compare("Seek")) {
|
} else if (!tsDecl->getName().compare("Seek")) {
|
||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
std::string offsetExprStr;
|
std::string offsetExprStr;
|
||||||
llvm::APSInt direction(64, 0);
|
llvm::APSInt direction(64, false);
|
||||||
const clang::Expr* directionExpr = nullptr;
|
const clang::Expr* directionExpr = nullptr;
|
||||||
bool bad = false;
|
bool bad = false;
|
||||||
for (const clang::TemplateArgument& arg : *tsType) {
|
for (const clang::TemplateArgument& arg : *tsType) {
|
||||||
|
@ -649,8 +649,11 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||||
offsetExprStr = offsetLiteral.toString(10);
|
offsetExprStr = offsetLiteral.toString(10);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
directionExpr = expr;
|
clang::APValue result;
|
||||||
if (!expr->isIntegerConstantExpr(direction, context)) {
|
if (expr->isCXX11ConstantExpr(context, &result)) {
|
||||||
|
directionExpr = expr;
|
||||||
|
direction = result.getInt();
|
||||||
|
} else {
|
||||||
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getExprLoc(), AthenaError);
|
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getExprLoc(), AthenaError);
|
||||||
diag.AddString("Unable to use non-constant direction expression in Athena");
|
diag.AddString("Unable to use non-constant direction expression in Athena");
|
||||||
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true));
|
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true));
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace athena {
|
||||||
namespace error {
|
namespace error {
|
||||||
enum class Level { Message, Warning, Error, Fatal };
|
enum class Level { Message, Warning, Error, Fatal };
|
||||||
}
|
}
|
||||||
enum SeekOrigin { Begin, Current, End };
|
enum class SeekOrigin { Begin, Current, End };
|
||||||
|
|
||||||
enum Endian { Little, Big };
|
enum Endian { Little, Big };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue