Encode the bitcode binary files into Java source files.

So that the apps don't need to have the bc files as resources.
The bitcode java files will be put at the same dir as the reflected java files.
The bitcode java file name will be <ClassName>BitCode.java.
The bitcode is represented as byte array and you can reference it as:
byte[] bitcode = <ClassName>BitCode.getBitCode();

To enable this feature, pass "-s jc" to the command line.

The class name <ClassName> is converted from the .rs file name, for example:
foo.rs -> FooBitCode.java
foo_bar.rs -> FooBarBitCode.java
fooBar.rs -> FooBarBitCode.java
foobar.rs -> FoobarBitCode.java

i.e., any non-alnum characters in the rs file name are filtered
and the rest are converted to camel case.

The above method is also applied to the reflected java classes now.

Change-Id: Idf234d4c017e33740a13d6cd68bc3e14710ec149
diff --git a/slang_rs_reflect_utils.hpp b/slang_rs_reflect_utils.hpp
new file mode 100644
index 0000000..a00288a
--- /dev/null
+++ b/slang_rs_reflect_utils.hpp
@@ -0,0 +1,52 @@
+#ifndef _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP
+#define _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP
+
+#include <string>
+
+namespace slang {
+
+class RSSlangReflectUtils {
+public:
+   // Compuate a Java source file path from a given prefixPath and its package.
+   // Eg, given prefixPath=./foo/bar and packageName=com.x.y, then it returns
+   // ./foo/bar/com/x/y
+   static std::string ComputePackagedPath(const std::string& prefixPath,
+                                          const std::string& packageName);
+
+   // Compute Java class name from a .rs file name.
+   // Any non-alnum character will be discarded. The result will be camel-cased.
+   // Eg, with rsFileName=./foo/bar/my_renderscript_file.rs it returns
+   // "MyRenderscriptFile".
+   // rsFileName: the input .rs file name (with or without path).
+   static std::string JavaClassNameFromRSFileName(const char* rsFileName);
+
+   // Compute a bitcode file name (no extension) from a .rs file name.
+   // Because the bitcode file name may be used as Resource ID in the generated
+   // class (something like R.raw.<bitcode_filename>), Any non-alnum character
+   // will be discarded.
+   // The difference from JavaClassNameFromRSFileName() is that the result is
+   // not converted to camel case.
+   // Eg, with rsFileName=./foo/bar/my_renderscript_file.rs it returns
+   // "myrenderscriptfile"
+   // rsFileName: the input .rs file name (with or without path).
+   static std::string BCFileNameFromRSFileName(const char* rsFileName);
+
+   // "mkdir -p"
+   static bool mkdir_p(const char* path);
+
+   // Encode a binary bitcode file into a Java source file.
+   // rsFileName: the original .rs file name (with or without path).
+   // inputBCFileName: the bitcode file to be encoded.
+   // outputPath: where to output the generated Java file, no package name in
+   // it.
+   // packageName: the package of the output Java file.
+   static bool EncodeBitcodeToJavaFile(const char* rsFileName,
+                                       const char* inputBCFileName,
+                                       const std::string& outputPath,
+                                       const std::string& packageName);
+
+};
+
+}
+
+#endif  // _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP