blob: 5151c82d3b4c814175eb08c703135c63e31fbe1c [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.
Stephen Hinesd4176402010-09-16 17:14:35 -070039 // Any non-alnum, non-underscore characters will be discarded.
40 // E.g. with rsFileName=./foo/bar/my-Renderscript_file.rs it returns
41 // "myRenderscript_file".
Ying Wang0877f052010-09-09 17:19:33 -070042 // 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
Stephen Hinesd4176402010-09-16 17:14:35 -070047 // class (something like R.raw.<bitcode_filename>), Any non-alnum,
48 // non-underscore character will be discarded.
Ying Wang0877f052010-09-09 17:19:33 -070049 // The difference from JavaClassNameFromRSFileName() is that the result is
Stephen Hinesd4176402010-09-16 17:14:35 -070050 // converted to lowercase.
51 // E.g. with rsFileName=./foo/bar/my-Renderscript_file.rs it returns
52 // "myrenderscript_file"
Ying Wang0877f052010-09-09 17:19:33 -070053 // 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