diff options
author | Murray Cumming <murrayc@murrayc.com> | 2005-01-20 16:28:17 +0000 |
---|---|---|
committer | Murray Cumming <murrayc@src.gnome.org> | 2005-01-20 16:28:17 +0000 |
commit | 5d783de9a21c0dd3e50ebbf16de41bea7a412027 (patch) | |
tree | e64865d4c9daba1733701025c27deddd71959bb2 /glib/src/optiongroup.ccg | |
parent | d3c5c7637ddf69bb1df177bde94b68e106d13a8b (diff) | |
download | glibmm-5d783de9a21c0dd3e50ebbf16de41bea7a412027.tar.gz |
Make C callacks separate extern C functions instead of static member
2005-01-20 Murray Cumming <murrayc@murrayc.com>
* glib/src/iochannel.[hg|ccg], markup.[hg|ccg], optiongroup.ccg,
spawn.ccg, thread.ccg:
Make C callacks
separate extern C functions instead of static member functions, to
satisfy the IRIX MipsPro compiler. Unfortunately this means that
we export some private API.
* glib/src/optionentry.hg: Remove the include of value.h, because
it is not used and it causes a MipsPro compile error in
optioncontext.cc because its templates are included before the
types that the template uses.
* glib/src/optiongroup.ccg: Do not use the StringArrayHandle,
because the MipsPro compiler has problems with it - see comments
in code.
* configure.in, scripts/cxx.m4, glibmm/glibmmconfig.h.in: Added a
compiler test, because the IRIX MipsPro compiler does not allow us
to define a template that uses an undefined type, even if we do not
use it before defining the type. That's probably correct.
* glib/glibmm/containerhandler_helpers.h: When the compiler does not
alllow the GObject and GtkObject (dynamic_cast of) specializations
here, then put them in glib/glibmm/object.h and
gtkmm/gtk/src/object.hg instead.- needed by MipsPro (IRIX) compiler..
Diffstat (limited to 'glib/src/optiongroup.ccg')
-rw-r--r-- | glib/src/optiongroup.ccg | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/glib/src/optiongroup.ccg b/glib/src/optiongroup.ccg index db26b8e4..5e82ee5e 100644 --- a/glib/src/optiongroup.ccg +++ b/glib/src/optiongroup.ccg @@ -21,7 +21,7 @@ #include <glibmm/optionentry.h> #include <glibmm/optioncontext.h> #include <glibmm/utility.h> -#include <glibmm/containers.h> +//#include <glibmm/containers.h> #include <glib/goption.h> namespace Glib @@ -30,7 +30,10 @@ namespace Glib namespace //anonymous { -gboolean g_callback_pre_parse(GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** /* TODO error */) +extern "C" +{ + +static gboolean g_callback_pre_parse(GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** /* TODO error */) { OptionContext cppContext(context, false /* take_ownership */); //OptionGroup cppGroup(group, true /* take_copy */); //Maybe this should be option_group. @@ -42,7 +45,7 @@ gboolean g_callback_pre_parse(GOptionContext* context, GOptionGroup* /* group */ return false; } -gboolean g_callback_post_parse(GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** /* TODO error */) +static gboolean g_callback_post_parse(GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** /* TODO error */) { OptionContext cppContext(context, false /* take_ownership */); //OptionGroup cppGroup(group, true /* take_copy */); //Maybe this should be option_group. @@ -56,7 +59,7 @@ gboolean g_callback_post_parse(GOptionContext* context, GOptionGroup* /* group * return false; } -void g_callback_error(GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** /* TODO error*/) +static void g_callback_error(GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** /* TODO error*/) { OptionContext cppContext(context, false /* take_ownership */); //OptionGroup cppGroup(group); //Maybe this should be option_group. @@ -66,6 +69,8 @@ void g_callback_error(GOptionContext* context, GOptionGroup* /* group */, gpoint return option_group->on_error(cppContext, *option_group); } +} /* extern "C" */ + } //anonymous namespace @@ -344,8 +349,10 @@ void OptionGroup::CppOptionEntry::convert_c_to_cpp() vecustrings* typed_cpp_arg = (vecustrings*)cpparg_; if(typed_arg && typed_cpp_arg) { + typed_cpp_arg->clear(); + //The C array seems to be null-terminated. - Glib::StringArrayHandle array_handle(*typed_arg, Glib::OWNERSHIP_NONE); + //Glib::StringArrayHandle array_handle(*typed_arg, Glib::OWNERSHIP_NONE); //The SUN Forte compiler complains about this: // "optiongroup.cc", line 354: Error: Cannot assign Glib::ArrayHandle<Glib::ustring, @@ -353,12 +360,25 @@ void OptionGroup::CppOptionEntry::convert_c_to_cpp() // "std::vector<Glib::ustring>::operator=(const std::vector<Glib::ustring>&)";. // //(*typed_cpp_arg) = array_handle; + // + //And the MipsPro (IRIX) compiler does not even like us to instantiate the StringArrayHandle: + // + // cxx: Error: ../../glib/glibmm/containerhandle_shared.h, line 149: the operand + // of a pointer dynamic_cast must be a pointer to a complete class type + // return dynamic_cast<CppType>(Glib::wrap_auto(cobj, false /* take_copy */)); + + //for(Glib::StringArrayHandle::iterator iter = array_handle.begin(); iter != array_handle.end(); ++iter) + //{ + // typed_cpp_arg->push_back(*iter); + //} //So we do this: - typed_cpp_arg->clear(); - for(Glib::StringArrayHandle::iterator iter = array_handle.begin(); iter != array_handle.end(); ++iter) + + char** char_array_next = *typed_arg; + while(char_array_next && *char_array_next) { - typed_cpp_arg->push_back(*iter); + typed_cpp_arg->push_back(*char_array_next); + ++char_array_next; } } @@ -369,18 +389,16 @@ void OptionGroup::CppOptionEntry::convert_c_to_cpp() char*** typed_arg = (char***)carg_; vecustrings* typed_cpp_arg = (vecustrings*)cpparg_; if(typed_arg && typed_cpp_arg) - { - //The C array seems to be null-terminated. - Glib::ArrayHandle<std::string> array_handle(*typed_arg, Glib::OWNERSHIP_NONE); - - //The SUN Forte compiler complains about this: - //(*typed_cpp_arg) = array_handle; - - //So we do this: + { typed_cpp_arg->clear(); - for(Glib::ArrayHandle<std::string>::iterator iter = array_handle.begin(); iter != array_handle.end(); ++iter) + + //See comments above about the SUN Forte and MipsPro compilers. + + char** char_array_next = *typed_arg; + while(char_array_next && *char_array_next) { - typed_cpp_arg->push_back(*iter); + typed_cpp_arg->push_back(*char_array_next); + ++char_array_next; } } |