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[]) {
1515 llvm::cl::cat (Category));
1616 llvm::cl::opt<std::string> ExcludePrefix (" exclude-prefix" ,
1717 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" ));
1922 clang::tooling::CommonOptionsParser op (argc, (const char **)argv, Category);
2023 clang::tooling::ClangTool Tool (op.getCompilations (),
2124 op.getSourcePathList ());
@@ -41,6 +44,10 @@ int main(int argc, char *argv[]) {
4144
4245 IR ir = actionFactory.getIntermediateRepresentation ();
4346
47+ if (!Package.empty ()) {
48+ ir.setPackageName (Package.getValue ());
49+ }
50+
4451 auto printLoc = PrintHeadersLocation.getValue ();
4552 if (printLoc) {
4653 for (const auto &location : locations) {
Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ bool IR::libObjEmpty() const {
3737llvm::raw_ostream &operator <<(llvm::raw_ostream &s, const IR &ir) {
3838 assert (ir.generated ); // typedefs were generated
3939
40+ if (!ir.packageName .empty ()) {
41+ s << " package " << ir.packageName << " \n\n " ;
42+ }
43+
4044 if (!ir.libObjEmpty () || !ir.enums .empty ()) {
4145 s << " import scala.scalanative._\n "
4246 << " import scala.scalanative.native._\n "
@@ -194,3 +198,7 @@ bool IR::typeIsUsedOnlyInTypeDefs(std::string type) {
194198 return !(isTypeUsed (functions, type) || isTypeUsed (structs, type) ||
195199 isTypeUsed (unions, type));
196200}
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 {
3939
4040 void generate (const std::string &excludePrefix);
4141
42+ void setPackageName (std::string packageName);
43+
4244 private:
4345 /* *
4446 * Generates type defs for enums, structs and unions
@@ -106,6 +108,7 @@ class IR {
106108 std::vector<Union> unions;
107109 std::vector<Enum> enums;
108110 bool generated = false ; // generate type defs only once
111+ std::string packageName;
109112};
110113
111114#endif // SCALA_NATIVE_BINDGEN_INTERMEDIATEREPRESENTATION_H
You can’t perform that action at this time.
0 commit comments