aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2011-10-26 16:18:14 -0700
committerStephen Hines <srhines@google.com>2011-10-26 16:18:14 -0700
commitf736d5a12269e7e74740b130cdca98d9839b31e6 (patch)
treeca3de7d14657bc3c331096e8bd5a490efb207394
parent12580dcd125d958bff87385ab13599ad01bd8aea (diff)
downloadslang-ics-mr0-release.tar.gz
BUG=5521638 Change-Id: Ic1f3c071562c687a98125c2151e306313c5405b8
-rw-r--r--slang_rs_context.cpp5
-rw-r--r--slang_rs_export_foreach.cpp21
-rw-r--r--slang_rs_export_foreach.h5
-rw-r--r--tests/F_root_graphics_13/root_graphics_13.rs7
-rw-r--r--tests/F_root_graphics_13/stderr.txt.expect3
-rw-r--r--tests/F_root_graphics_13/stdout.txt.expect0
-rw-r--r--tests/P_root_graphics_13/root_graphics_13.rs9
-rw-r--r--tests/P_root_graphics_13/stderr.txt.expect0
-rw-r--r--tests/P_root_graphics_13/stdout.txt.expect1
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 ...