blob: 73245659e40f2ce24deef5b0914d3da4033a5d32 [file] [log] [blame]
Ying Wang3f8b44d2010-09-04 01:17:01 -07001#ifndef _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP
2#define _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP
3
4#include <string>
5
6namespace slang {
7
Ying Wang0877f052010-09-09 17:19:33 -07008// BitCode storage type
9enum BitCodeStorageType {
10 BCST_APK_RESOURCE,
11 BCST_JAVA_CODE
12};
13
Ying Wang3f8b44d2010-09-04 01:17:01 -070014class RSSlangReflectUtils {
Ying Wang0877f052010-09-09 17:19:33 -070015 public:
Ying Wang3f8b44d2010-09-04 01:17:01 -070016
Ying Wang0877f052010-09-09 17:19:33 -070017 // Encode a binary bitcode file into a Java source file.
18 // rsFileName: the original .rs file name (with or without path).
19 // bcFileName: where is the bit code file
20 // reflectPath: where to output the generated Java file, no package name in
21 // it.
22 // packageName: the package of the output Java file.
23 struct BitCodeAccessorContext {
24 const char* rsFileName;
25 const char* bcFileName;
26 const char* reflectPath;
27 const char* packageName;
Ying Wang3f8b44d2010-09-04 01:17:01 -070028
Ying Wang0877f052010-09-09 17:19:33 -070029 BitCodeStorageType bcStorage;
30 };
Ying Wang3f8b44d2010-09-04 01:17:01 -070031
Ying Wang0877f052010-09-09 17:19:33 -070032 // Compuate a Java source file path from a given prefixPath and its package.
33 // Eg, given prefixPath=./foo/bar and packageName=com.x.y, then it returns
34 // ./foo/bar/com/x/y
35 static std::string ComputePackagedPath(const char* prefixPath,
36 const char* packageName);
Ying Wang3f8b44d2010-09-04 01:17:01 -070037
Ying Wang0877f052010-09-09 17:19:33 -070038 // Compute Java class name from a .rs file name.
39 // Any non-alnum character will be discarded. The result will be camel-cased.
40 // Eg, with rsFileName=./foo/bar/my_renderscript_file.rs it returns
41 // "MyRenderscriptFile".
42 // rsFileName: the input .rs file name (with or without path).
43 static std::string JavaClassNameFromRSFileName(const char* rsFileName);
44
45 // Compute a bitcode file name (no extension) from a .rs file name.
46 // Because the bitcode file name may be used as Resource ID in the generated
47 // class (something like R.raw.<bitcode_filename>), Any non-alnum character
48 // will be discarded.
49 // The difference from JavaClassNameFromRSFileName() is that the result is
50 // not converted to camel case.
51 // Eg, with rsFileName=./foo/bar/my_renderscript_file.rs it returns
52 // "myrenderscriptfile"
53 // rsFileName: the input .rs file name (with or without path).
54 static std::string BCFileNameFromRSFileName(const char* rsFileName);
55
56 // "mkdir -p"
57 static bool mkdir_p(const char* path);
58
59
60 // Generate the bit code accessor Java source file.
61 static bool GenerateBitCodeAccessor(const BitCodeAccessorContext& context);
Ying Wang3f8b44d2010-09-04 01:17:01 -070062
63};
64
65}
66
67#endif // _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP