File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ int main(int argc, char *argv[]) {
15
15
llvm::cl::cat (Category));
16
16
llvm::cl::opt<std::string> ExcludePrefix (" exclude-prefix" ,
17
17
llvm::cl::cat (Category));
18
-
18
+ llvm::cl::opt<std::string> Package (
19
+ " package" , llvm::cl::cat (Category),
20
+ llvm::cl::value_desc (" package-name" ),
21
+ llvm::cl::desc (" Package name of generated Scala file" ));
19
22
clang::tooling::CommonOptionsParser op (argc, (const char **)argv, Category);
20
23
clang::tooling::ClangTool Tool (op.getCompilations (),
21
24
op.getSourcePathList ());
@@ -41,6 +44,10 @@ int main(int argc, char *argv[]) {
41
44
42
45
IR ir = actionFactory.getIntermediateRepresentation ();
43
46
47
+ if (!Package.empty ()) {
48
+ ir.setPackageName (Package.getValue ());
49
+ }
50
+
44
51
auto printLoc = PrintHeadersLocation.getValue ();
45
52
if (printLoc) {
46
53
for (const auto &location : locations) {
Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ bool IR::libObjEmpty() const {
37
37
llvm::raw_ostream &operator <<(llvm::raw_ostream &s, const IR &ir) {
38
38
assert (ir.generated ); // typedefs were generated
39
39
40
+ if (!ir.packageName .empty ()) {
41
+ s << " package " << ir.packageName << " \n\n " ;
42
+ }
43
+
40
44
if (!ir.libObjEmpty () || !ir.enums .empty ()) {
41
45
s << " import scala.scalanative._\n "
42
46
<< " import scala.scalanative.native._\n "
@@ -194,3 +198,7 @@ bool IR::typeIsUsedOnlyInTypeDefs(std::string type) {
194
198
return !(isTypeUsed (functions, type) || isTypeUsed (structs, type) ||
195
199
isTypeUsed (unions, type));
196
200
}
201
+
202
+ void IR::setPackageName (std::string packageName) {
203
+ this ->packageName = packageName;
204
+ }
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ class IR {
39
39
40
40
void generate (const std::string &excludePrefix);
41
41
42
+ void setPackageName (std::string packageName);
43
+
42
44
private:
43
45
/* *
44
46
* Generates type defs for enums, structs and unions
@@ -106,6 +108,7 @@ class IR {
106
108
std::vector<Union> unions;
107
109
std::vector<Enum> enums;
108
110
bool generated = false ; // generate type defs only once
111
+ std::string packageName;
109
112
};
110
113
111
114
#endif // SCALA_NATIVE_BINDGEN_INTERMEDIATEREPRESENTATION_H
You can’t perform that action at this time.
0 commit comments