aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-05-22 20:18:45 -0700
committerStephen Hines <srhines@google.com>2014-05-23 16:10:44 -0700
commit4c8b659edc8dca50ffb9c172258412fc1e02b80d (patch)
tree8bef1408ef90e4ceac7ac204583e4f0c6a87fffe
parent44d495d2ad8c350a8f586502c9ee8e97a513646a (diff)
downloadandroid_frameworks_compile_slang-4c8b659edc8dca50ffb9c172258412fc1e02b80d.tar.gz
android_frameworks_compile_slang-4c8b659edc8dca50ffb9c172258412fc1e02b80d.tar.bz2
android_frameworks_compile_slang-4c8b659edc8dca50ffb9c172258412fc1e02b80d.zip
Generate calls to getBitCode32() for new constructor type.
Change-Id: Iec41e3f325ec045362608ee52b0f78c55eb87bed
-rw-r--r--slang_rs_reflect_utils.cpp10
-rw-r--r--slang_rs_reflection.cpp55
-rw-r--r--slang_rs_reflection.h4
3 files changed, 41 insertions, 28 deletions
diff --git a/slang_rs_reflect_utils.cpp b/slang_rs_reflect_utils.cpp
index 294ccc3..950a74d 100644
--- a/slang_rs_reflect_utils.cpp
+++ b/slang_rs_reflect_utils.cpp
@@ -126,7 +126,7 @@ static bool GenerateAccessorMethodSignature(
const RSSlangReflectUtils::BitCodeAccessorContext &context, FILE *pfout) {
// the prototype of the accessor method
fprintf(pfout, " // return byte array representation of the bitcode.\n");
- fprintf(pfout, " public static byte[] getBitCode() {\n");
+ fprintf(pfout, " public static byte[] getBitCode32() {\n");
return true;
}
@@ -135,7 +135,7 @@ static bool GenerateAccessorMethodSignature(
static bool GenerateSegmentMethod(
const char *buff, int blen, int seg_num, FILE *pfout) {
- fprintf(pfout, " private static byte[] getSegment_%d() {\n", seg_num);
+ fprintf(pfout, " private static byte[] getSegment32_%d() {\n", seg_num);
fprintf(pfout, " byte[] data = {\n");
static const int LINE_BYTE_NUM = 16;
@@ -174,7 +174,7 @@ static bool GenerateJavaCodeAccessorMethod(
// start the accessor method
GenerateAccessorMethodSignature(context, pfout);
- fprintf(pfout, " return getBitCodeInternal();\n");
+ fprintf(pfout, " return getBitCode32Internal();\n");
// end the accessor method
fprintf(pfout, " };\n\n");
@@ -197,12 +197,12 @@ static bool GenerateJavaCodeAccessorMethod(
// output the internal accessor method
fprintf(pfout, " private static int bitCodeLength = %d;\n\n",
total_length);
- fprintf(pfout, " private static byte[] getBitCodeInternal() {\n");
+ fprintf(pfout, " private static byte[] getBitCode32Internal() {\n");
fprintf(pfout, " byte[] bc = new byte[bitCodeLength];\n");
fprintf(pfout, " int offset = 0;\n");
fprintf(pfout, " byte[] seg;\n");
for (int i = 0; i < seg_num; ++i) {
- fprintf(pfout, " seg = getSegment_%d();\n", i);
+ fprintf(pfout, " seg = getSegment32_%d();\n", i);
fprintf(pfout, " System.arraycopy(seg, 0, bc, offset, seg.length);\n");
fprintf(pfout, " offset += seg.length;\n");
}
diff --git a/slang_rs_reflection.cpp b/slang_rs_reflection.cpp
index 5e97dcb..2bb3b52 100644
--- a/slang_rs_reflection.cpp
+++ b/slang_rs_reflection.cpp
@@ -317,6 +317,8 @@ bool RSReflection::genScriptClass(Context &C,
}
void RSReflection::genScriptClassConstructor(Context &C) {
+ std::string className(RSSlangReflectUtils::JavaBitcodeClassNameFromRSFileName(
+ C.getInputRSFile().c_str()));
// Provide a simple way to reference this object.
C.indent() << "private static final String " RS_RESOURCE_NAME " = \""
<< C.getResourceId()
@@ -333,30 +335,37 @@ void RSReflection::genScriptClassConstructor(Context &C) {
"RenderScript", "rs");
if (C.getEmbedBitcodeInJava()) {
- // Call new constructor
- }
- // Call alternate constructor with required parameters.
- // Look up the proper raw bitcode resource id via the context.
- C.indent() << "this(rs," << std::endl;
- C.indent() << " rs.getApplicationContext().getResources()," << std::endl;
- C.indent() << " rs.getApplicationContext().getResources()."
- "getIdentifier(" << std::endl;
- C.indent() << " " RS_RESOURCE_NAME ", \"raw\"," << std::endl;
- C.indent() << " rs.getApplicationContext().getPackageName()));"
- << std::endl;
- C.endFunction();
+ // Call new single argument Java-only constructor
+ C.indent() << "super(rs," << std::endl;
+ C.indent() << " " << RS_RESOURCE_NAME "," << std::endl;
+ C.indent() << " " << className << ".getBitCode32()," << std::endl;
+ // TODO(srhines): Replace the extra BitCode32 with Bitcode64 here!
+ //C.indent() << " " << className << ".getBitCode64());" << std::endl;
+ C.indent() << " " << className << ".getBitCode32());" << std::endl;
+ } else {
+ // Call alternate constructor with required parameters.
+ // Look up the proper raw bitcode resource id via the context.
+ C.indent() << "this(rs," << std::endl;
+ C.indent() << " rs.getApplicationContext().getResources()," << std::endl;
+ C.indent() << " rs.getApplicationContext().getResources()."
+ "getIdentifier(" << std::endl;
+ C.indent() << " " RS_RESOURCE_NAME ", \"raw\"," << std::endl;
+ C.indent() << " rs.getApplicationContext().getPackageName()));"
+ << std::endl;
+ C.endFunction();
- // Alternate constructor (legacy) with 3 original parameters.
- C.startFunction(Context::AM_Public,
- false,
- NULL,
- C.getClassName(),
- 3,
- "RenderScript", "rs",
- "Resources", "resources",
- "int", "id");
- // Call constructor of super class
- C.indent() << "super(rs, resources, id);" << std::endl;
+ // Alternate constructor (legacy) with 3 original parameters.
+ C.startFunction(Context::AM_Public,
+ false,
+ NULL,
+ C.getClassName(),
+ 3,
+ "RenderScript", "rs",
+ "Resources", "resources",
+ "int", "id");
+ // Call constructor of super class
+ C.indent() << "super(rs, resources, id);" << std::endl;
+ }
// If an exported variable has initial value, reflect it
diff --git a/slang_rs_reflection.h b/slang_rs_reflection.h
index 1939044..07495aa 100644
--- a/slang_rs_reflection.h
+++ b/slang_rs_reflection.h
@@ -142,6 +142,10 @@ class RSReflection {
return;
}
+ inline std::string &getInputRSFile() {
+ return mInputRSFile;
+ }
+
inline std::ostream &out() const {
return ((mUseStdout) ? std::cout : mOF);
}