Commit de7e9208 authored by Murray Cumming's avatar Murray Cumming

Remove the reduced API options and code, as discussed on mailing list.

* configure.ac: Removed the --enable-api-exceptions, --enable-api-properties,
--enable-api-vfuncs and --enable-api-default-signal-handlers options.
* build/reduced.m4: Removed.
* tools/m4/*.m4:
* tools/pm/Output.pm: Remove any use of ifdefs and auto_ptr for reduced API.
* *.[hg|ccg|h|cc]: Remove the idefed code.
parent f5106733
2010-05-31 Murray Cumming <murrayc@murrayc.com>
Remove the reduced API options and code, as discussed on mailing list.
* configure.ac: Removed the --enable-api-exceptions, --enable-api-properties,
--enable-api-vfuncs and --enable-api-default-signal-handlers options.
* build/reduced.m4: Removed.
* tools/m4/*.m4:
* tools/pm/Output.pm: Remove any use of ifdefs and auto_ptr for reduced API.
* *.[hg|ccg|h|cc]: Remove the idefed code.
2010-05-30 Daniel Elstner <danielk@openismus.com>
Avoid compiler warning in TimeVal::as_double()
......
## GLIBMM_ARG_ENABLE_API_PROPERTIES()
##
## Provide the --enable-api-properties configure argument, enabled
## by default.
##
AC_DEFUN([GLIBMM_ARG_ENABLE_API_PROPERTIES],
[
AC_ARG_ENABLE([api-properties],
[ --enable-api-properties Build properties API.
[[default=yes]]],
[glibmm_enable_api_properties="$enableval"],
[glibmm_enable_api_properties='yes'])
if test "x$glibmm_enable_api_properties" = "xyes"; then
{
AC_DEFINE([GLIBMM_PROPERTIES_ENABLED],[1], [Defined when the --enable-api-properties configure argument was given])
}
fi
])
## GLIBMM_ARG_ENABLE_API_VFUNCS()
##
## Provide the --enable-api-vfuncs configure argument, enabled
## by default.
##
AC_DEFUN([GLIBMM_ARG_ENABLE_API_VFUNCS],
[
AC_ARG_ENABLE([api-vfuncs],
[ --enable-api-vfuncs Build vfuncs API.
[[default=yes]]],
[glibmm_enable_api_vfuncs="$enableval"],
[glibmm_enable_api_vfuncs='yes'])
if test "x$glibmm_enable_api_vfuncs" = "xyes"; then
{
AC_DEFINE([GLIBMM_VFUNCS_ENABLED],[1], [Defined when the --enable-api-vfuncs configure argument was given])
}
fi
])
## GLIBMM_ARG_ENABLE_API_EXCEPTIONS()
##
## Provide the --enable-api-exceptions configure argument, enabled
## by default.
##
AC_DEFUN([GLIBMM_ARG_ENABLE_API_EXCEPTIONS],
[
AC_ARG_ENABLE([api-exceptions],
[ --enable-api-exceptions Build exceptions API.
[[default=yes]]],
[glibmm_enable_api_exceptions="$enableval"],
[glibmm_enable_api_exceptions='yes'])
if test "x$glibmm_enable_api_exceptions" = "xyes"; then
{
AC_DEFINE([GLIBMM_EXCEPTIONS_ENABLED],[1], [Defined when the --enable-api-exceptions configure argument was given])
}
fi
])
## GLIBMM_ARG_ENABLE_API_DEFAULT_SIGNAL_HANDLERS()
##
## Provide the --enable-api-default-signal-handlers configure argument, enabled
## by default.
##
AC_DEFUN([GLIBMM_ARG_ENABLE_API_DEFAULT_SIGNAL_HANDLERS],
[
AC_ARG_ENABLE([api-default-signal-handlers],
[ --enable-api-default-signal-handlers Build default signal handlers API.
[[default=yes]]],
[glibmm_enable_api_default_signal_handlers="$enableval"],
[glibmm_enable_api_default_signal_handlers='yes'])
if test "x$glibmm_enable_api_default_signal_handlers" = "xyes"; then
{
AC_DEFINE([GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED],[1], [Defined when the --enable-api-default-signal-handlers configure argument was given])
}
fi
])
......@@ -118,10 +118,12 @@ MM_ARG_ENABLE_WARNINGS([GLIBMM_WXXFLAGS],
# Offer the ability to omit some API from the library,
# to reduce the code size:
MM_ARG_DISABLE_DEPRECATED_API([GLIBMM GIOMM])
GLIBMM_ARG_ENABLE_API_EXCEPTIONS
GLIBMM_ARG_ENABLE_API_PROPERTIES
GLIBMM_ARG_ENABLE_API_VFUNCS
GLIBMM_ARG_ENABLE_API_DEFAULT_SIGNAL_HANDLERS
# These are just defined to avoid breaking old code:
AC_DEFINE([GLIBMM_EXCEPTIONS_ENABLED],[1], [This is always set. This is only for backwards compatibility.])
AC_DEFINE([GLIBMM_PROPERTIES_ENABLED],[1], [This is always set. This is only for backwards compatibility.])
AC_DEFINE([GLIBMM_VFUNCS_ENABLED],[1], [This is always set. This is only for backwards compatibility.])
AC_DEFINE([GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED],[1], [This is always set. This is only for backwards compatibility.])
AC_CONFIG_FILES([Makefile
tools/Makefile
......
......@@ -49,12 +49,7 @@ void fdstreambuf::create_iochannel(int fd, bool manage)
{
iochannel_ = Glib::IOChannel::create_from_fd(fd);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
iochannel_->set_encoding("");
#else
std::auto_ptr<Glib::Error> ex;
iochannel_->set_encoding("", ex);
#endif //GLIBMM_EXCEPTIONS_ENABLED
iochannel_->set_buffered(true);
iochannel_->set_close_on_unref(manage);
......@@ -83,7 +78,6 @@ int fdstreambuf::sync()
if (!iochannel_)
return -1;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
iochannel_->flush();
......@@ -94,16 +88,6 @@ int fdstreambuf::sync()
error_condition.code = io_error.code();
return -1;
}
#else
std::auto_ptr<Glib::Error> io_error;
iochannel_->flush(io_error);
if(io_error.get())
{
error_condition.error = true;
error_condition.code = (Glib::IOChannelError::Code)io_error->code();
return -1;
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
return 0;
}
......@@ -113,7 +97,6 @@ void fdstreambuf::close_iochannel()
iochannel_->set_close_on_unref(false);
reset();
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
iochannel_->close(true);
......@@ -123,15 +106,6 @@ void fdstreambuf::close_iochannel()
error_condition.error = true;
error_condition.code = io_error.code();
}
#else
std::auto_ptr<Glib::Error> io_error;
iochannel_->close(true, io_error);
if(io_error.get())
{
error_condition.error = true;
error_condition.code = (Glib::IOChannelError::Code)io_error->code();
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
}
......@@ -141,7 +115,6 @@ fdstreambuf::traits_type::int_type fdstreambuf::overflow(int_type c)
{
if(!traits_type::eq_int_type(c, traits_type::eof()))
{
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
gsize result = 0;
......@@ -154,18 +127,6 @@ fdstreambuf::traits_type::int_type fdstreambuf::overflow(int_type c)
error_condition.code = io_error.code();
return traits_type::eof();
}
#else
std::auto_ptr<Glib::Error> io_error;
gsize result = 0;
char write_char = c;
iochannel_->write(&write_char, 1, result, io_error);
if(io_error.get())
{
error_condition.error = true;
error_condition.code = (Glib::IOChannelError::Code)io_error->code();
return traits_type::eof();;
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
}
return traits_type::not_eof(c);
}
......@@ -180,7 +141,6 @@ std::streamsize fdstreambuf::xsputn(const char* source, std::streamsize num)
// will only do a short write in the event of stream failure, so there is no
// need to check result and have a second bite (byte) at it as would be
// necessary with Unix write()
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
iochannel_->write(source, num, result);
......@@ -191,16 +151,6 @@ std::streamsize fdstreambuf::xsputn(const char* source, std::streamsize num)
error_condition.code = io_error.code();
result = 0;
}
#else
std::auto_ptr<Glib::Error> io_error;
iochannel_->write(source, num, result, io_error);
if(io_error.get())
{
error_condition.error = true;
error_condition.code = (Glib::IOChannelError::Code)io_error->code();
result = 0;
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
return result;
}
......@@ -218,7 +168,6 @@ fdstreambuf::traits_type::int_type fdstreambuf::underflow()
// now insert a character into the bump position
gsize result = 0;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
iochannel_->read(putback_buffer + 1, 1, result);
......@@ -229,16 +178,6 @@ fdstreambuf::traits_type::int_type fdstreambuf::underflow()
error_condition.code = io_error.code();
return traits_type::eof();
}
#else
std::auto_ptr<Glib::Error> io_error;
iochannel_->read(putback_buffer + 1, 1, result, io_error);
if(io_error.get())
{
error_condition.error = true;
error_condition.code = (Glib::IOChannelError::Code)io_error->code();
return traits_type::eof();
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
// some other error - is this possible? In case it is, cater for it
if (result == 0)
......@@ -282,42 +221,24 @@ std::streamsize fdstreambuf::xsgetn(char* dest, std::streamsize num)
// read up to everything else we need with Glib::IOChannel::read()
gsize result = 0;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
#else
std::auto_ptr<Glib::Error> io_error;
#endif //GLIBMM_EXCEPTIONS_ENABLED
do
{
#ifdef GLIBMM_EXCEPTIONS_ENABLED
iochannel_->read(dest + chars_read,
num - chars_read,
result);
#else
iochannel_->read(dest + chars_read,
num - chars_read,
result, io_error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
if (result > 0)
chars_read += result;
}
while (result > 0 && result < static_cast<gsize>(num - chars_read));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
}
catch(Glib::IOChannelError& io_error)
#else
if(io_error.get())
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
error_condition.error = true;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
error_condition.code = io_error.code();
#else
error_condition.code = (Glib::IOChannelError::Code)io_error->code();
#endif //GLIBMM_EXCEPTIONS_ENABLED
return chars_read;
}
......
......@@ -27,7 +27,6 @@ int main(int, char**)
Glib::KeyFile keyfile;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
// An exception will be thrown if the file is not there, or if the file is incorrectly formatted:
try
{
......@@ -76,45 +75,6 @@ int main(int, char**)
{
std::cerr << "Exception while getting list value: " << ex.what() << std::endl;
}
#else /* !GLIBMM_EXCEPTIONS_ENABLED */
std::auto_ptr<Glib::Error> ex;
if(!keyfile.load_from_file(filepath, Glib::KeyFileFlags(), ex))
{
std::cerr << "Exception while loading key file: " << ex->what() << std::endl;
return 1;
}
// Try to get a value that is not in the file:
{
const Glib::ustring value = keyfile.get_value("somegroup", "somekey", ex);
if (!ex.get())
std::cout << "somekey value=" << value << std::endl;
else
std::cerr << "Exception while getting value: " << ex->what() << std::endl;
}
// Try to get a value that is in the file:
{
const Glib::ustring value = keyfile.get_value("First Group", "Welcome", ex);
if (!ex.get())
std::cout << "Welcome value=" << value << std::endl;
else
std::cerr << "Exception while getting value: " << ex->what() << std::endl;
}
// Try to get a list of integers that is in the file:
{
const std::vector<int> values = keyfile.get_integer_list("Another Group", "Numbers", ex);
if (!ex.get())
{
for(std::vector<int>::const_iterator p = values.begin(); p != values.end(); ++p)
std::cout << "Number list value: item=" << *p << std::endl;
}
else
std::cerr << "Exception while getting list value: " << ex->what() << std::endl;
}
#endif /* !GLIBMM_EXCEPTIONS_ENABLED */
return 0;
}
......
......@@ -23,20 +23,11 @@
namespace
{
#ifndef GLIBMM_EXCEPTIONS_ENABLED
//This is an alternative, to use when we have disabled exceptions:
std::auto_ptr<Glib::Error> processing_error;
#endif //GLIBMM_EXCEPTIONS_ENABLED
void file_get_contents(const std::string& filename, Glib::ustring& contents)
{
#ifdef GLIBMM_EXCEPTIONS_ENABLED
const Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_file(filename, "r");
channel->read_to_end(contents);
#else
const Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_file(filename, "r", processing_error);
channel->read_to_end(contents, processing_error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
}
Glib::ustring trim_whitespace(const Glib::ustring& text)
......@@ -146,29 +137,19 @@ int main(int argc, char** argv)
DumpParser parser;
Glib::Markup::ParseContext context (parser);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
#endif //GLIBMM_EXCEPTIONS_ENABLED
Glib::ustring contents;
file_get_contents(argv[1], contents);
context.parse(contents);
context.end_parse();
#ifdef GLIBMM_EXCEPTIONS_ENABLED
}
catch(const Glib::Error& error)
{
std::cerr << argv[1] << ": " << error.what() << std::endl;
return 1;
}
#else
if(processing_error.get())
{
std::cerr << argv[1] << ": " << processing_error->what() << std::endl;
return 1;
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
return 0;
......
......@@ -116,7 +116,6 @@ int main(int argc, char** argv)
ExampleOptionGroup group;
context.set_main_group(group);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
context.parse(argc, argv);
......@@ -125,14 +124,6 @@ int main(int argc, char** argv)
{
std::cout << "Exception: " << ex.what() << std::endl;
}
#else
std::auto_ptr<Glib::Error> ex;
context.parse(argc, argv, ex);
if(ex.get())
{
std::cout << "Exception: " << ex->what() << std::endl;
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
std::cout << "parsed values: " << std::endl <<
" foo = " << group.m_arg_foo << std::endl <<
......
......@@ -19,7 +19,6 @@
#include <iostream>
// This example will not work without properties support
#ifdef GLIBMM_PROPERTIES_ENABLED
// A class that contains properties must inherit from Glib::Object (or a class
// that inherits from Glib::Object)
class Person : public Glib::Object
......@@ -58,11 +57,9 @@ void on_lastname_changed ()
{ std::cout << "- lastname changed!" << std::endl; }
void on_age_changed ()
{ std::cout << "- age changed!" << std::endl; }
#endif // GLIBMM_PROPERTIES_ENABLED
int main(int, char**)
{
#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::init ();
Person p;
// Register some handlers that will be called when the values of the
......@@ -82,5 +79,4 @@ int main(int, char**)
std::cout << "Done changing the properties of 'p'" << std::endl;
return 0;
#endif // GLIBMM_PROPERTIES_ENABLED
}
......@@ -24,15 +24,7 @@ int main(int, char**)
Glib::init();
/* Reusing one regex pattern: */
#ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create("(a)?(b)");
#else
std::auto_ptr<Glib::Error> error;
Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create("(a)?(b)",
Glib::RegexCompileFlags(),
Glib::RegexMatchFlags(),
error);
#endif
std::cout << "Pattern=" << regex->get_pattern()
<< ", with string=abcd, result="
<< std::boolalpha << regex->match("abcd")
......
......@@ -151,9 +151,7 @@ Application::Application()
// Note that unless you're targetting an embedded platform, you can assume
// exceptions to be enabled. The #ifdef is only here to make the example
// compile in either case; you may ignore it otherwise.
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
#endif
{
for (std::vector<ThreadProgress*>::size_type i = 0; i < progress_threads_.size(); ++i)
{
......@@ -164,7 +162,6 @@ Application::Application()
sigc::bind<1>(sigc::mem_fun(*this, &Application::on_progress_finished), progress));
}
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
catch (...)
{
// In your own code, you should preferably use a smart pointer
......@@ -173,7 +170,6 @@ Application::Application()
DeletePtr<ThreadProgress*>());
throw;
}
#endif
}
Application::~Application()
......
......@@ -27,19 +27,15 @@ SignalProxy_async_callback(GObject*, GAsyncResult* res, void* data)
{
Gio::SlotAsyncReady* the_slot = static_cast<Gio::SlotAsyncReady*>(data);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
#endif //GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<Gio::AsyncResult> result = Glib::wrap(res, true /* take copy */);
(*the_slot)(result);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
}
catch(...)
{
Glib::exception_handlers_invoke();
}
#endif //GLIBMM_EXCEPTIONS_ENABLED
delete the_slot;
}
......
......@@ -23,18 +23,10 @@
namespace Gio
{
#ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<AppInfo>
AppInfo::create_from_commandline(const std::string& commandline,
const std::string& application_name,
AppInfoCreateFlags flags)
#else
Glib::RefPtr<AppInfo>
AppInfo::create_from_commandline(const std::string& commandline,
const std::string& application_name,
AppInfoCreateFlags flags,
std::auto_ptr<Glib::Error>& error)
#endif // GLIBMM_EXCEPTIONS_ENABLED
{
GAppInfo* capp_info = 0;
GError* gerror = 0;
......@@ -45,31 +37,18 @@ AppInfo::create_from_commandline(const std::string& commandline,
&gerror);
if (gerror)
#ifdef GLIBMM_EXCEPTIONS_ENABLED
::Glib::Error::throw_exception(gerror);
#else
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
return Glib::wrap(capp_info);
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool AppInfo::launch_default_for_uri(const std::string& uri)
#else
bool AppInfo::launch_default_for_uri(const std::string& uri, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
GError* gerror = 0;
const bool retvalue = g_app_info_launch_default_for_uri(uri.c_str(), 0, &(gerror));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
::Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
return retvalue;
}
......
......@@ -17,9 +17,7 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef GLIBMM_EXCEPTIONS_ENABLED
#include <exception>
#endif
#include <string>
......@@ -80,16 +78,9 @@ class AppInfo : public Glib::Interface
_CLASS_INTERFACE(AppInfo, GAppInfo, G_APP_INFO, GAppInfoIface)
public:
#ifdef GLIBMM_EXCEPTIONS_ENABLED
static Glib::RefPtr<AppInfo> create_from_commandline(const std::string& commandline,
const std::string& application_name,
AppInfoCreateFlags flags);
#else
static Glib::RefPtr<AppInfo> create_from_commandline(const std::string& commandline,
const std::string& application_name,
AppInfoCreateFlags flags,
std::auto_ptr<Glib::Error>& error);
#endif // GLIBMM_EXCEPTIONS_ENABLED
//_IGNORE(g_app_info_dup)
_IGNORE(g_app_info_equal)
......@@ -144,11 +135,7 @@ public:
_WRAP_METHOD(static void reset_type_associations(const std::string& content_type), g_app_info_reset_type_associations)
_WRAP_METHOD(static bool launch_default_for_uri(const std::string& uri, const Glib::RefPtr<AppLaunchContext>& context), g_app_info_launch_default_for_uri, errthrow)
// same as above but without optional AppLaunchContext
#ifdef GLIBMM_EXCEPTIONS_ENABLED
static bool launch_default_for_uri(const std::string& uri);
#else
static bool launch_default_for_uri(const std::string& uri, std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
protected:
//_WRAP_VFUNC(Glib::RefPtr<AppInfo> dup(), "dup")
......
......@@ -27,21 +27,12 @@ Glib::RefPtr<BufferedInputStream> BufferedInputStream::create_sized(const Glib::
return Glib::RefPtr<Gio::BufferedInputStream>(new BufferedInputStream(base_stream, size));
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
gssize BufferedInputStream::fill(gssize count)
#else
gssize BufferedInputStream::fill(gssize count, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
GError* gerror = 0;
const gssize retvalue = g_buffered_input_stream_fill(const_cast<GBufferedInputStream*>(gobj()), count, 0, &(gerror));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
if(gerror)
::Glib::Error::throw_exception(gerror);
#else
if(gerror)
error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED
return retvalue;
}
......@@ -81,21 +72,12 @@ void BufferedInputStream::fill_async(const SlotAsyncReady& slot,
slot_copy);
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
int BufferedInputStream::read_byte()