summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2019-07-19 19:58:52 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2019-07-19 19:58:52 +0200
commit995bbf3352134f19aff227be26c38a55942527eb (patch)
treea4063ddd9251713a238e70b6ce465d6f8cf39eab
parent0068464609cc5c2e6690ff9ffd8ebba2f3b90011 (diff)
Make UIClass controllable from commandline.
-rw-r--r--ttlgen.cc103
1 files changed, 97 insertions, 6 deletions
diff --git a/ttlgen.cc b/ttlgen.cc
index 7d6bd93..1e9c257 100644
--- a/ttlgen.cc
+++ b/ttlgen.cc
@@ -32,6 +32,17 @@
typedef PluginLV2* create_t();
+enum class UIType
+{
+ CocoaUI,
+ Gtk3UI,
+ GtkUI,
+ Qt4UI,
+ Qt5UI,
+ WindowsUI,
+ X11UI,
+};
+
static void header(std::ostream& output)
{
output << "\
@@ -86,16 +97,42 @@ static void includes(std::ostream& output)
#endif
#endif
-static void ui(Plugin& plugin, const std::string& pluginfile, std::ostream& output)
+static void ui(Plugin& plugin, const std::string& pluginfile, UIType uitype,
+ std::ostream& output)
{
if(!plugin.hasGUI())
{
return;
}
+ output << "<" << plugin.getURI() << "/lv2#ui>\n";
+
+ switch(uitype)
+ {
+ case UIType::CocoaUI:
+ output << " a ui:CocoaUI ;\n";
+ break;
+ case UIType::Gtk3UI:
+ output << " a ui:Gtk3UI ;\n";
+ break;
+ case UIType::GtkUI:
+ output << " a ui:GtkUI ;\n";
+ break;
+ case UIType::Qt4UI:
+ output << " a ui:Qt4UI ;\n";
+ break;
+ case UIType::Qt5UI:
+ output << " a ui:Qt5UI ;\n";
+ break;
+ case UIType::WindowsUI:
+ output << " a ui:WindowsUI ;\n";
+ break;
+ case UIType::X11UI:
+ output << " a ui:X11UI ;\n";
+ break;
+ }
+
output << "\
-<" << plugin.getURI() << "/lv2#ui>\n\
- a ui:" UIClass " ;\n \
lv2:requiredFeature ui:resize ;\n\
lv2:extensionData ui:resize ;\n\
lv2:requiredFeature ui:idleInterface ;\n\
@@ -168,14 +205,68 @@ static void ports(Plugin& plugin, std::ostream& output)
}
}
+void usage(const char* app)
+{
+ std::cout << "Usage: " << app << " <plugin binary> <output file> [uitype]\n";
+ std::cout << "where uitype can be one of:\n";
+ std::cout << " CocoaUI\n";
+ std::cout << " Gtk3UI\n";
+ std::cout << " GtkUI\n";
+ std::cout << " Qt4UI\n";
+ std::cout << " Qt5UI\n";
+ std::cout << " WindowsUI\n";
+ std::cout << " X11UI\n";
+ std::cout << "default is " UIClass "\n";
+}
+
+UIType fromString(const std::string& t)
+{
+ if(t == "CocoaUI")
+ {
+ return UIType::CocoaUI;
+ }
+ if(t == "Gtk3UI")
+ {
+ return UIType::Gtk3UI;
+ }
+ if(t == "GtkUI")
+ {
+ return UIType::GtkUI;
+ }
+ if(t == "Qt4UI")
+ {
+ return UIType::Qt4UI;
+ }
+ if(t == "Qt5UI")
+ {
+ return UIType::Qt5UI;
+ }
+ if(t == "WindowsUI")
+ {
+ return UIType::WindowsUI;
+ }
+ if(t == "X11UI")
+ {
+ return UIType::X11UI;
+ }
+
+ std::cerr << "Bad uitype: '" << t << "'\n";
+ exit(1);
+}
+
int main(int argc, char* argv[])
{
- if(argc != 3)
+ if(argc < 3 || argc > 4)
{
std::cerr << "Missing argument.\n";
- std::cout << "Usage: " << argv[0] << " <plugin binary> <output file>\n";
+ usage(argv[0]);
return 1;
}
+ UIType uitype = UIType::X11UI;
+ if(argc == 4)
+ {
+ uitype = fromString(argv[3]);
+ }
std::string library = argv[1];
auto seppos = library.rfind("/");
@@ -215,7 +306,7 @@ int main(int argc, char* argv[])
output << std::endl;
includes(output);
output << std::endl;
- ui(*p, binary, output);
+ ui(*p, binary, uitype, output);
output << std::endl;
output << "\