diff options
author | Stephen Hines <srhines@google.com> | 2011-10-26 16:18:14 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2011-10-26 16:18:14 -0700 |
commit | f736d5a12269e7e74740b130cdca98d9839b31e6 (patch) | |
tree | ca3de7d14657bc3c331096e8bd5a490efb207394 | |
parent | 12580dcd125d958bff87385ab13599ad01bd8aea (diff) | |
download | slang-ics-mr0-release.tar.gz |
Add back pre-ICS support for "int root(int);".android-sdk-adt_r16.0.1android-cts-4.0_r1android-4.0.2_r1android-4.0.1_r1.2android-4.0.1_r1.1android-4.0.1_r1ics-mr0-releaseics-mr0ics-factoryrom-2-release
BUG=5521638
Change-Id: Ic1f3c071562c687a98125c2151e306313c5405b8
-rw-r--r-- | slang_rs_context.cpp | 5 | ||||
-rw-r--r-- | slang_rs_export_foreach.cpp | 21 | ||||
-rw-r--r-- | slang_rs_export_foreach.h | 5 | ||||
-rw-r--r-- | tests/F_root_graphics_13/root_graphics_13.rs | 7 | ||||
-rw-r--r-- | tests/F_root_graphics_13/stderr.txt.expect | 3 | ||||
-rw-r--r-- | tests/F_root_graphics_13/stdout.txt.expect | 0 | ||||
-rw-r--r-- | tests/P_root_graphics_13/root_graphics_13.rs | 9 | ||||
-rw-r--r-- | tests/P_root_graphics_13/stderr.txt.expect | 0 | ||||
-rw-r--r-- | tests/P_root_graphics_13/stdout.txt.expect | 1 |
9 files changed, 45 insertions, 6 deletions
diff --git a/slang_rs_context.cpp b/slang_rs_context.cpp index e1a2857..980038c 100644 --- a/slang_rs_context.cpp +++ b/slang_rs_context.cpp @@ -116,7 +116,7 @@ bool RSContext::processExportFunc(const clang::FunctionDecl *FD) { return false; } - if (RSExportForEach::isRSForEachFunc(FD)) { + if (RSExportForEach::isRSForEachFunc(mTargetAPI, FD)) { RSExportForEach *EFE = RSExportForEach::Create(this, FD); if (EFE == NULL) return false; @@ -125,7 +125,8 @@ bool RSContext::processExportFunc(const clang::FunctionDecl *FD) { return true; } else if (RSExportForEach::isSpecialRSFunc(FD)) { // Do not reflect specialized RS functions like init or graphics root. - if (!RSExportForEach::validateSpecialFuncDecl(getDiagnostics(), FD)) { + if (!RSExportForEach::validateSpecialFuncDecl(mTargetAPI, + getDiagnostics(), FD)) { return false; } return true; diff --git a/slang_rs_export_foreach.cpp b/slang_rs_export_foreach.cpp index faa5f17..924bc06 100644 --- a/slang_rs_export_foreach.cpp +++ b/slang_rs_export_foreach.cpp @@ -292,7 +292,8 @@ RSExportForEach *RSExportForEach::Create(RSContext *Context, return FE; } -bool RSExportForEach::isRSForEachFunc(const clang::FunctionDecl *FD) { +bool RSExportForEach::isRSForEachFunc(int targetAPI, + const clang::FunctionDecl *FD) { // We currently support only compute root() being exported via forEach if (!isRootRSFunc(FD)) { return false; @@ -302,10 +303,23 @@ bool RSExportForEach::isRSForEachFunc(const clang::FunctionDecl *FD) { // Graphics compute function return false; } + + // Handle legacy graphics root functions. + if ((targetAPI < SLANG_ICS_TARGET_API) && (FD->getNumParams() == 1)) { + const clang::ParmVarDecl *PVD = FD->getParamDecl(0); + clang::QualType QT = PVD->getType().getCanonicalType(); + const clang::QualType &IntType = FD->getASTContext().IntTy; + if ((FD->getResultType().getCanonicalType() == IntType) && + (QT == IntType)) { + return false; + } + } + return true; } -bool RSExportForEach::validateSpecialFuncDecl(clang::Diagnostic *Diags, +bool RSExportForEach::validateSpecialFuncDecl(int targetAPI, + clang::Diagnostic *Diags, const clang::FunctionDecl *FD) { slangAssert(Diags && FD); bool valid = true; @@ -323,6 +337,9 @@ bool RSExportForEach::validateSpecialFuncDecl(clang::Diagnostic *Diags, "an int for graphics usage")); valid = false; } + } else if ((targetAPI < SLANG_ICS_TARGET_API) && (numParams == 1)) { + // Legacy graphics root function + // This has already been validated in isRSForEachFunc(). } else { slangAssert(false && "Should not call validateSpecialFuncDecl() on compute root()"); diff --git a/slang_rs_export_foreach.h b/slang_rs_export_foreach.h index 13fd3a7..cf9ed3f 100644 --- a/slang_rs_export_foreach.h +++ b/slang_rs_export_foreach.h @@ -148,13 +148,14 @@ class RSExportForEach : public RSExportable { return Name.equals(FuncDtor); } - static bool isRSForEachFunc(const clang::FunctionDecl *FD); + static bool isRSForEachFunc(int targetAPI, const clang::FunctionDecl *FD); inline static bool isSpecialRSFunc(const clang::FunctionDecl *FD) { return isRootRSFunc(FD) || isInitRSFunc(FD) || isDtorRSFunc(FD); } - static bool validateSpecialFuncDecl(clang::Diagnostic *Diags, + static bool validateSpecialFuncDecl(int targetAPI, + clang::Diagnostic *Diags, const clang::FunctionDecl *FD); }; // RSExportForEach diff --git a/tests/F_root_graphics_13/root_graphics_13.rs b/tests/F_root_graphics_13/root_graphics_13.rs new file mode 100644 index 0000000..c6c1fbd --- /dev/null +++ b/tests/F_root_graphics_13/root_graphics_13.rs @@ -0,0 +1,7 @@ +// -target-api 13 +#pragma version(1) +#pragma rs java_package_name(foo) + +int root(unsigned int launchID) { + return 10; +} diff --git a/tests/F_root_graphics_13/stderr.txt.expect b/tests/F_root_graphics_13/stderr.txt.expect new file mode 100644 index 0000000..5670930 --- /dev/null +++ b/tests/F_root_graphics_13/stderr.txt.expect @@ -0,0 +1,3 @@ +root_graphics_13.rs:5:5: error: compute root() is required to return a void type +root_graphics_13.rs:5:5: error: Compute root() must have at least one parameter for in or out +root_graphics_13.rs:5:5: error: Compute root() targeting SDK levels 11-13 may not skip parameters diff --git a/tests/F_root_graphics_13/stdout.txt.expect b/tests/F_root_graphics_13/stdout.txt.expect new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/F_root_graphics_13/stdout.txt.expect diff --git a/tests/P_root_graphics_13/root_graphics_13.rs b/tests/P_root_graphics_13/root_graphics_13.rs new file mode 100644 index 0000000..882bea1 --- /dev/null +++ b/tests/P_root_graphics_13/root_graphics_13.rs @@ -0,0 +1,9 @@ +// -target-api 13 +#pragma version(1) +#pragma rs java_package_name(foo) + +typedef int myInt; + +myInt root(myInt launchID) { + return 10; +} diff --git a/tests/P_root_graphics_13/stderr.txt.expect b/tests/P_root_graphics_13/stderr.txt.expect new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/P_root_graphics_13/stderr.txt.expect diff --git a/tests/P_root_graphics_13/stdout.txt.expect b/tests/P_root_graphics_13/stdout.txt.expect new file mode 100644 index 0000000..f61211e --- /dev/null +++ b/tests/P_root_graphics_13/stdout.txt.expect @@ -0,0 +1 @@ +Generating ScriptC_root_graphics_13.java ... |