diff options
-rw-r--r-- | examples/options/main.cc | 4 | ||||
-rw-r--r-- | gio/src/application.ccg | 14 | ||||
-rw-r--r-- | gio/src/application.hg | 17 | ||||
-rw-r--r-- | glib/src/glib_docs_override.xml | 2 | ||||
-rw-r--r-- | glib/src/optionentry.ccg | 2 | ||||
-rw-r--r-- | glib/src/optionentry.hg | 20 | ||||
-rw-r--r-- | glib/src/optiongroup.ccg | 10 |
7 files changed, 34 insertions, 35 deletions
diff --git a/examples/options/main.cc b/examples/options/main.cc index ca7ea0cc..c0973adb 100644 --- a/examples/options/main.cc +++ b/examples/options/main.cc @@ -89,7 +89,7 @@ ExampleOptionGroup::ExampleOptionGroup() entry6.set_long_name("x-string"); entry6.set_short_name('x'); entry6.set_description("A string with custom parsing"); - entry6.set_flags(Glib::OptionEntry::FLAG_OPTIONAL_ARG); + entry6.set_flags(Glib::OptionEntry::Flags::OPTIONAL_ARG); m_arg_x_string = "not specified"; add_entry(entry6, sigc::mem_fun(*this, &ExampleOptionGroup::on_option_arg_string)); @@ -97,7 +97,7 @@ ExampleOptionGroup::ExampleOptionGroup() entry7.set_long_name("x-filename"); entry7.set_short_name('X'); entry7.set_description("A filename with custom parsing"); - entry7.set_flags(Glib::OptionEntry::FLAG_OPTIONAL_ARG); + entry7.set_flags(Glib::OptionEntry::Flags::OPTIONAL_ARG); m_arg_x_filename = "not specified"; add_entry_filename(entry7, sigc::mem_fun(*this, &ExampleOptionGroup::on_option_arg_filename)); diff --git a/gio/src/application.ccg b/gio/src/application.ccg index 08104501..e6bc3d29 100644 --- a/gio/src/application.ccg +++ b/gio/src/application.ccg @@ -396,7 +396,7 @@ Application::open(const Glib::RefPtr<Gio::File>& file, const Glib::ustring& hint void Application::add_main_option_entry(OptionType arg_type, const Glib::ustring& long_name, gchar short_name, const Glib::ustring& description, const Glib::ustring& arg_description, - int flags) + Glib::OptionEntry::Flags flags) { add_main_option_entry_private( (GOptionArg)arg_type, long_name, short_name, description, arg_description, flags); @@ -405,7 +405,7 @@ Application::add_main_option_entry(OptionType arg_type, const Glib::ustring& lon void Application::add_main_option_entry(const Glib::OptionGroup::SlotOptionArgString& slot, const Glib::ustring& long_name, gchar short_name, const Glib::ustring& description, - const Glib::ustring& arg_description, int flags) + const Glib::ustring& arg_description, Glib::OptionEntry::Flags flags) { { std::lock_guard<std::mutex> lock(option_arg_callback_data_mutex); @@ -418,13 +418,13 @@ Application::add_main_option_entry(const Glib::OptionGroup::SlotOptionArgString& } // option_arg_callback_data_mutex.unlock() add_main_option_entry_private(G_OPTION_ARG_CALLBACK, long_name, short_name, description, - arg_description, flags & ~Glib::OptionEntry::FLAG_FILENAME); + arg_description, flags & ~Glib::OptionEntry::Flags::FILENAME); } void Application::add_main_option_entry_filename(const Glib::OptionGroup::SlotOptionArgFilename& slot, const Glib::ustring& long_name, gchar short_name, const Glib::ustring& description, - const Glib::ustring& arg_description, int flags) + const Glib::ustring& arg_description, Glib::OptionEntry::Flags flags) { { std::lock_guard<std::mutex> lock(option_arg_callback_data_mutex); @@ -437,13 +437,13 @@ Application::add_main_option_entry_filename(const Glib::OptionGroup::SlotOptionA } // option_arg_callback_data_mutex.unlock() add_main_option_entry_private(G_OPTION_ARG_CALLBACK, long_name, short_name, description, - arg_description, flags | Glib::OptionEntry::FLAG_FILENAME); + arg_description, flags | Glib::OptionEntry::Flags::FILENAME); } void Application::add_main_option_entry_private(GOptionArg arg, const Glib::ustring& long_name, gchar short_name, const Glib::ustring& description, const Glib::ustring& arg_description, - int flags) + Glib::OptionEntry::Flags flags) { // Create a temporary array, just so we can give the correct thing to // g_application_add_main_option_entries(): @@ -480,7 +480,7 @@ Application::add_main_option_entry_private(GOptionArg arg, const Glib::ustring& array[0].short_name = short_name; array[0].description = desc; array[0].arg_description = arg_desc; - array[0].flags = flags; + array[0].flags = static_cast<int>(flags); if (arg == G_OPTION_ARG_CALLBACK) { diff --git a/gio/src/application.hg b/gio/src/application.hg index 6fc4d49a..565d196a 100644 --- a/gio/src/application.hg +++ b/gio/src/application.hg @@ -228,12 +228,13 @@ public: * @param description The description for the option in `--help` output. * @param arg_description The placeholder to use for the extra argument parsed * by the option in `--help` output. - * @param flags Flags from Glib::OptionEntry::Flags. Do not set FLAG_FILENAME. + * @param flags Flags from Glib::OptionEntry::Flags. Do not set OptionEntry::Flags::FILENAME. * Character encoding is chosen with @a arg_type. */ void add_main_option_entry(OptionType arg_type, const Glib::ustring& long_name, gchar short_name = '\0', const Glib::ustring& description = Glib::ustring(), - const Glib::ustring& arg_description = Glib::ustring(), int flags = 0); + const Glib::ustring& arg_description = Glib::ustring(), + Glib::OptionEntry::Flags flags = Glib::OptionEntry::Flags::NONE); _IGNORE(g_application_add_main_option_entries) //g_application_add_main_option() seems to be just a new convenience function, @@ -253,12 +254,13 @@ public: * @newin{2,42} * * @see add_main_option_entry(OptionType, const Glib::ustring&, - * gchar, const Glib::ustring&, const Glib::ustring&, int) + * gchar, const Glib::ustring&, const Glib::ustring&, Glib::OptionEntry::Flags) */ void add_main_option_entry(const Glib::OptionGroup::SlotOptionArgString& slot, const Glib::ustring& long_name, gchar short_name = '\0', const Glib::ustring& description = Glib::ustring(), - const Glib::ustring& arg_description = Glib::ustring(), int flags = 0); + const Glib::ustring& arg_description = Glib::ustring(), + Glib::OptionEntry::Flags flags = Glib::OptionEntry::Flags::NONE); /** Adds a main option entry to be handled by the Application. * @@ -273,12 +275,13 @@ public: * @newin{2,42} * * @see add_main_option_entry(OptionType, const Glib::ustring&, - * gchar, const Glib::ustring&, const Glib::ustring&, int) + * gchar, const Glib::ustring&, const Glib::ustring&, Glib::OptionEntry::Flags) */ void add_main_option_entry_filename(const Glib::OptionGroup::SlotOptionArgFilename& slot, const Glib::ustring& long_name, gchar short_name = '\0', const Glib::ustring& description = Glib::ustring(), - const Glib::ustring& arg_description = Glib::ustring(), int flags = 0); + const Glib::ustring& arg_description = Glib::ustring(), + Glib::OptionEntry::Flags flags = Glib::OptionEntry::Flags::NONE); // _WRAP_METHOD(void add_option_group(Glib::OptionGroup& group), g_application_add_option_group) // add_option_group() is probably not very useful. If implemented, it must probably @@ -431,7 +434,7 @@ private: // Code, common to the public add_main_option_entry*() methods. void add_main_option_entry_private(GOptionArg arg, const Glib::ustring& long_name, gchar short_name, const Glib::ustring& description, - const Glib::ustring& arg_description, int flags); + const Glib::ustring& arg_description, Glib::OptionEntry::Flags flags); }; } // namespace Gio diff --git a/glib/src/glib_docs_override.xml b/glib/src/glib_docs_override.xml index 6a038971..f9eba41c 100644 --- a/glib/src/glib_docs_override.xml +++ b/glib/src/glib_docs_override.xml @@ -18,6 +18,8 @@ <substitute_enumerator_name from_prefix="G_TIME_TYPE_" to_prefix="Glib::TimeType::" /> <substitute_enumerator_name from_prefix="G_UNICODE_BREAK_" to_prefix="Glib::UnicodeBreakType::" /> <substitute_enumerator_name from_prefix="G_NORMALIZE_" to_prefix="Glib::NormalizeMode::" /> + <!-- enum GOptionArg is not wrapped. Don't substitute. --> + <substitute_enumerator_name from_prefix="G_OPTION_ARG_" to_prefix="G_OPTION_ARG_" /> <!-- These are preprocessor defines. Don't substitute. --> <substitute_enumerator_name from="G_PARAM_STATIC_STRINGS" to="G_PARAM_STATIC_STRINGS" /> <substitute_enumerator_name from_prefix="G_VARIANT_TYPE_" to_prefix="G_VARIANT_TYPE_" /> diff --git a/glib/src/optionentry.ccg b/glib/src/optionentry.ccg index 0a807a51..705e3735 100644 --- a/glib/src/optionentry.ccg +++ b/glib/src/optionentry.ccg @@ -21,6 +21,8 @@ namespace Glib { +using Flags = OptionEntry::Flags; + OptionEntry::OptionEntry() { gobject_ = g_new0(GOptionEntry, 1); diff --git a/glib/src/optionentry.hg b/glib/src/optionentry.hg index 246aa965..c64d13bb 100644 --- a/glib/src/optionentry.hg +++ b/glib/src/optionentry.hg @@ -45,17 +45,7 @@ class OptionEntry _CLASS_GENERIC(OptionEntry, GOptionEntry) public: - //Copied from goption.h, instead of generated, so that we can put it inside the class. - enum Flags - { - FLAG_HIDDEN = 1 << 0, - FLAG_IN_MAIN = 1 << 1, - FLAG_REVERSE = 1 << 2, - FLAG_NO_ARG = 1 << 3, - FLAG_FILENAME = 1 << 4, - FLAG_OPTIONAL_ARG = 1 << 5, - FLAG_NOALIAS = 1 << 6 - } GOptionFlags; + _WRAP_ENUM(Flags, GOptionFlags, NO_GTYPE) OptionEntry(); OptionEntry(const OptionEntry& src); @@ -76,13 +66,15 @@ public: _MEMBER_GET(short_name, short_name, gchar, gchar) _MEMBER_SET(short_name, short_name, gchar, gchar) - _MEMBER_GET(flags, flags, int, int) +#m4 _CONVERSION(`int',`Flags',`static_cast<Flags>($3)') + _MEMBER_GET(flags, flags, Flags, int) +#m4 _CONVERSION(`Flags',`int',`static_cast<int>($3)') /** Set one or more OptionEntry::Flags. - * Do not set FLAG_FILENAME. Character encoding is chosen when the OptionEntry + * Do not set Flags::FILENAME. Character encoding is chosen when the OptionEntry * is added to an OptionGroup. */ - _MEMBER_SET(flags, flags, int, int) + _MEMBER_SET(flags, flags, Flags, int) _MEMBER_GET(description, description, Glib::ustring, const char*) diff --git a/glib/src/optiongroup.ccg b/glib/src/optiongroup.ccg index 08cfe6d1..0bd922f5 100644 --- a/glib/src/optiongroup.ccg +++ b/glib/src/optiongroup.ccg @@ -378,7 +378,7 @@ OptionGroup::add_entry_filename(const OptionEntry& entry, vecstrings& arg) } // When the command argument value is to be parsed by a user-supplied function -// (indicated by G_OPTION_ARG_CALLBACK), the FLAG_FILENAME in 'entry' is ignored. +// (indicated by G_OPTION_ARG_CALLBACK), the OptionEntry::Flags::FILENAME in 'entry' is ignored. // set_c_arg_default() clears or sets it as required in a copy of 'entry'. // // The glib API is inconsistent here. The choice between UTF-8 and filename @@ -386,7 +386,7 @@ OptionGroup::add_entry_filename(const OptionEntry& entry, vecstrings& arg) // G_OPTION_ARG_STRING_ARRAY, and G_OPTION_ARG_FILENAME_ARRAY, which in glibmm // are set by OptionGroup::add_entry[_filename]. But when a callback function // is chosen, there is only G_OPTION_ARG_CALLBACK, and the encoding is chosen -// with G_OPTION_FLAG_FILENAME. We do this automatiically in set_c_arg_default(). +// with OptionEntry::Flags::FILENAME. We do this automatiically in set_c_arg_default(). // Other option flags are set by OptionEntry::set_flags(). void @@ -621,15 +621,15 @@ OptionGroup::CppOptionEntry::set_c_arg_default(void* cpp_arg) { // No value to set here. The arg pointer is a function pointer. - // Set or clear FLAG_FILENAME in *entry_. + // Set or clear OptionEntry::Flags::FILENAME in *entry_. const OptionArgCallback* const option_arg = static_cast<const OptionArgCallback*>(cpp_arg); if (option_arg->is_filename_option()) { - entry_->set_flags(entry_->get_flags() | OptionEntry::FLAG_FILENAME); + entry_->set_flags(entry_->get_flags() | OptionEntry::Flags::FILENAME); } else { - entry_->set_flags(entry_->get_flags() & ~OptionEntry::FLAG_FILENAME); + entry_->set_flags(entry_->get_flags() & ~OptionEntry::Flags::FILENAME); } break; } |