Ying Wang | 3f8b44d | 2010-09-04 01:17:01 -0700 | [diff] [blame^] | 1 | #ifndef _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP |
| 2 | #define _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP |
| 3 | |
| 4 | #include <string> |
| 5 | |
| 6 | namespace slang { |
| 7 | |
| 8 | class RSSlangReflectUtils { |
| 9 | public: |
| 10 | // Compuate a Java source file path from a given prefixPath and its package. |
| 11 | // Eg, given prefixPath=./foo/bar and packageName=com.x.y, then it returns |
| 12 | // ./foo/bar/com/x/y |
| 13 | static std::string ComputePackagedPath(const std::string& prefixPath, |
| 14 | const std::string& packageName); |
| 15 | |
| 16 | // Compute Java class name from a .rs file name. |
| 17 | // Any non-alnum character will be discarded. The result will be camel-cased. |
| 18 | // Eg, with rsFileName=./foo/bar/my_renderscript_file.rs it returns |
| 19 | // "MyRenderscriptFile". |
| 20 | // rsFileName: the input .rs file name (with or without path). |
| 21 | static std::string JavaClassNameFromRSFileName(const char* rsFileName); |
| 22 | |
| 23 | // Compute a bitcode file name (no extension) from a .rs file name. |
| 24 | // Because the bitcode file name may be used as Resource ID in the generated |
| 25 | // class (something like R.raw.<bitcode_filename>), Any non-alnum character |
| 26 | // will be discarded. |
| 27 | // The difference from JavaClassNameFromRSFileName() is that the result is |
| 28 | // not converted to camel case. |
| 29 | // Eg, with rsFileName=./foo/bar/my_renderscript_file.rs it returns |
| 30 | // "myrenderscriptfile" |
| 31 | // rsFileName: the input .rs file name (with or without path). |
| 32 | static std::string BCFileNameFromRSFileName(const char* rsFileName); |
| 33 | |
| 34 | // "mkdir -p" |
| 35 | static bool mkdir_p(const char* path); |
| 36 | |
| 37 | // Encode a binary bitcode file into a Java source file. |
| 38 | // rsFileName: the original .rs file name (with or without path). |
| 39 | // inputBCFileName: the bitcode file to be encoded. |
| 40 | // outputPath: where to output the generated Java file, no package name in |
| 41 | // it. |
| 42 | // packageName: the package of the output Java file. |
| 43 | static bool EncodeBitcodeToJavaFile(const char* rsFileName, |
| 44 | const char* inputBCFileName, |
| 45 | const std::string& outputPath, |
| 46 | const std::string& packageName); |
| 47 | |
| 48 | }; |
| 49 | |
| 50 | } |
| 51 | |
| 52 | #endif // _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP |