glibmm r769 - in trunk: . glib/src
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glibmm r769 - in trunk: . glib/src
- Date: Wed, 24 Dec 2008 22:10:09 +0000 (UTC)
Author: murrayc
Date: Wed Dec 24 22:10:09 2008
New Revision: 769
URL: http://svn.gnome.org/viewvc/glibmm?rev=769&view=rev
Log:
2008-12-24 Murray Cumming <murrayc murrayc com>
* glib/src/spawn.ccg:
* glib/src/spawn.hg: Added Glib::spawn_*() alternative API for when
GLIBMM_EXCEPTIONS_ENABLED is not enabled (when compiling without
C++ exceptions.)
Bug #565487
(Jonathon Jongsma)
Modified:
trunk/ChangeLog
trunk/glib/src/spawn.ccg
trunk/glib/src/spawn.hg
Modified: trunk/glib/src/spawn.ccg
==============================================================================
--- trunk/glib/src/spawn.ccg (original)
+++ trunk/glib/src/spawn.ccg Wed Dec 24 22:10:09 2008
@@ -70,6 +70,7 @@
/**** process spawning functions *******************************************/
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
@@ -79,10 +80,21 @@
int* standard_input,
int* standard_output,
int* standard_error)
+#else
+void spawn_async_with_pipes(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ const Glib::ArrayHandle<std::string>& envp,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ Pid* child_pid,
+ int* standard_input,
+ int* standard_output,
+ int* standard_error, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
- GError* error = 0;
+ GError* gerror = 0;
g_spawn_async_with_pipes(
working_directory.c_str(),
@@ -93,12 +105,18 @@
(setup_slot) ? &child_setup_ : 0,
child_pid,
standard_input, standard_output, standard_error,
- &error);
+ &gerror);
- if(error)
- Glib::Error::throw_exception(error);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ Glib::Error::throw_exception(gerror);
+ #else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
@@ -107,10 +125,20 @@
int* standard_input,
int* standard_output,
int* standard_error)
+#else
+void spawn_async_with_pipes(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ Pid* child_pid,
+ int* standard_input,
+ int* standard_output,
+ int* standard_error, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
- GError* error = 0;
+ GError* gerror = 0;
g_spawn_async_with_pipes(
working_directory.c_str(),
@@ -120,22 +148,36 @@
(setup_slot) ? &child_setup_ : 0,
child_pid,
standard_input, standard_output, standard_error,
- &error);
+ &gerror);
- if(error)
- Glib::Error::throw_exception(error);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ Glib::Error::throw_exception(gerror);
+ #else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid)
+#else
+void spawn_async(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ const Glib::ArrayHandle<std::string>& envp,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ Pid* child_pid, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
- GError* error = 0;
+ GError* gerror = 0;
g_spawn_async(
working_directory.c_str(),
@@ -145,21 +187,34 @@
(setup_slot) ? &child_setup_callback : 0,
(setup_slot) ? &child_setup_ : 0,
child_pid,
- &error);
+ &gerror);
- if(error)
- Glib::Error::throw_exception(error);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ Glib::Error::throw_exception(gerror);
+ #else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
const sigc::slot<void>& child_setup,
Pid* child_pid)
+#else
+void spawn_async(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ Pid* child_pid, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
- GError* error = 0;
+ GError* gerror = 0;
g_spawn_async(
working_directory.c_str(),
@@ -168,12 +223,18 @@
(setup_slot) ? &child_setup_callback : 0,
(setup_slot) ? &child_setup_ : 0,
child_pid,
- &error);
+ &gerror);
- if(error)
- Glib::Error::throw_exception(error);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ Glib::Error::throw_exception(gerror);
+ #else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
@@ -182,13 +243,23 @@
std::string* standard_output,
std::string* standard_error,
int* exit_status)
+#else
+void spawn_sync(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ const Glib::ArrayHandle<std::string>& envp,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ std::string* standard_output,
+ std::string* standard_error,
+ int* exit_status, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
Glib::ScopedPtr<char> buf_standard_output;
Glib::ScopedPtr<char> buf_standard_error;
- GError* error = 0;
+ GError* gerror = 0;
g_spawn_sync(
working_directory.c_str(),
@@ -200,15 +271,21 @@
(standard_output) ? buf_standard_output.addr() : 0,
(standard_error) ? buf_standard_error.addr() : 0,
exit_status,
- &error);
+ &gerror);
- if(error)
- Glib::Error::throw_exception(error);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ Glib::Error::throw_exception(gerror);
+ #else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
copy_output_buf(standard_output, buf_standard_output.get());
copy_output_buf(standard_error, buf_standard_error.get());
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags,
@@ -216,13 +293,22 @@
std::string* standard_output,
std::string* standard_error,
int* exit_status)
+#else
+void spawn_sync(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ std::string* standard_output,
+ std::string* standard_error,
+ int* exit_status, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
{
const bool setup_slot = !child_setup.empty();
sigc::slot<void> child_setup_ = child_setup;
Glib::ScopedPtr<char> buf_standard_output;
Glib::ScopedPtr<char> buf_standard_error;
- GError* error = 0;
+ GError* gerror = 0;
g_spawn_sync(
working_directory.c_str(),
@@ -233,42 +319,68 @@
(standard_output) ? buf_standard_output.addr() : 0,
(standard_error) ? buf_standard_error.addr() : 0,
exit_status,
- &error);
+ &gerror);
- if(error)
- Glib::Error::throw_exception(error);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ Glib::Error::throw_exception(gerror);
+ #else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
copy_output_buf(standard_output, buf_standard_output.get());
copy_output_buf(standard_error, buf_standard_error.get());
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_command_line_async(const std::string& command_line)
+#else
+void spawn_command_line_async(const std::string& command_line, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
{
- GError* error = 0;
- g_spawn_command_line_async(command_line.c_str(), &error);
+ GError* gerror = 0;
+ g_spawn_command_line_async(command_line.c_str(), &gerror);
- if(error)
- Glib::Error::throw_exception(error);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ Glib::Error::throw_exception(gerror);
+ #else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_command_line_sync(const std::string& command_line,
std::string* standard_output,
std::string* standard_error,
int* exit_status)
+#else
+void spawn_command_line_sync(const std::string& command_line,
+ std::string* standard_output,
+ std::string* standard_error,
+ int* exit_status, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
{
Glib::ScopedPtr<char> buf_standard_output;
Glib::ScopedPtr<char> buf_standard_error;
- GError* error = 0;
+ GError* gerror = 0;
g_spawn_command_line_sync(
command_line.c_str(),
(standard_output) ? buf_standard_output.addr() : 0,
(standard_error) ? buf_standard_error.addr() : 0,
exit_status,
- &error);
+ &gerror);
- if(error)
- Glib::Error::throw_exception(error);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ Glib::Error::throw_exception(gerror);
+ #else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
copy_output_buf(standard_output, buf_standard_output.get());
copy_output_buf(standard_error, buf_standard_error.get());
Modified: trunk/glib/src/spawn.hg
==============================================================================
--- trunk/glib/src/spawn.hg (original)
+++ trunk/glib/src/spawn.hg Wed Dec 24 22:10:09 2008
@@ -192,6 +192,7 @@
* to users. If an error occurs, @a child_pid, @a standard_input, @a standard_output,
* and @a standard_error will not be filled with valid values.
*/
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
@@ -201,6 +202,17 @@
int* standard_input = 0,
int* standard_output = 0,
int* standard_error = 0);
+#else
+void spawn_async_with_pipes(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ const Glib::ArrayHandle<std::string>& envp,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ Pid* child_pid,
+ int* standard_input,
+ int* standard_output,
+ int* standard_error, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
/** Like the main spawn_async_with_pipes() method, but inheriting the parent's environment.
*
@@ -219,7 +231,7 @@
* to users. If an error occurs, @a child_pid, @a standard_input, @a standard_output,
* and @a standard_error will not be filled with valid values.
*/
-
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async_with_pipes(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags = SpawnFlags(0),
@@ -228,6 +240,16 @@
int* standard_input = 0,
int* standard_output = 0,
int* standard_error = 0);
+#else
+void spawn_async_with_pipes(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ Pid* child_pid,
+ int* standard_input,
+ int* standard_output,
+ int* standard_error, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
/** See pawn_async_with_pipes() for a full description. This function
* simply calls the spawn_async_with_pipes() without any pipes.
@@ -250,12 +272,21 @@
* the message field of returned errors should be displayed
* to users.
*/
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
SpawnFlags flags = SpawnFlags(0),
const sigc::slot<void>& child_setup = sigc::slot<void>(),
Pid* child_pid = 0);
+#else
+void spawn_async(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ const Glib::ArrayHandle<std::string>& envp,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ Pid* child_pid, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
/** Like the main spawn_async() method, but inheriting the parent's environment.
*
@@ -271,11 +302,19 @@
* the message field of returned errors should be displayed
* to users.
*/
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags = SpawnFlags(0),
const sigc::slot<void>& child_setup = sigc::slot<void>(),
Pid* child_pid = 0);
+#else
+void spawn_async(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ Pid* child_pid, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
/** Executes a child synchronously (waits for the child to exit before returning).
* All output from the child is stored in @a standard_output and @a standard_error,
@@ -309,6 +348,7 @@
* to users. If an error occurs, @a child_pid, @a standard_input, @a standard_output,
* and @a standard_error will not be filled with valid values.
*/
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
const Glib::ArrayHandle<std::string>& envp,
@@ -317,6 +357,16 @@
std::string* standard_output = 0,
std::string* standard_error = 0,
int* exit_status = 0);
+#else
+void spawn_sync(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ const Glib::ArrayHandle<std::string>& envp,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ std::string* standard_output,
+ std::string* standard_error,
+ int* exit_status, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
/** Like the main spawn_sync() method, but inheriting the parent's environment.
*
@@ -334,6 +384,7 @@
* to users. If an error occurs, @a child_pid, @a standard_input, @a standard_output,
* and @a standard_error will not be filled with valid values.
*/
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_sync(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags = SpawnFlags(0),
@@ -341,6 +392,15 @@
std::string* standard_output = 0,
std::string* standard_error = 0,
int* exit_status = 0);
+#else
+void spawn_sync(const std::string& working_directory,
+ const Glib::ArrayHandle<std::string>& argv,
+ SpawnFlags flags,
+ const sigc::slot<void>& child_setup,
+ std::string* standard_output,
+ std::string* standard_error ,
+ int* exit_status, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
/** A simple version of spawn_async() that parses a command line with
* shell_parse_argv() and passes it to spawn_async(). It runs a
@@ -359,7 +419,11 @@
* to users.
* @throws ShellError If the command line could not be parsed.
*/
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_command_line_async(const std::string& command_line);
+#else
+void spawn_command_line_async(const std::string& command_line, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
/** A simple version of spawn_sync() with little-used parameters
* removed, taking a command line instead of an argument vector. See
@@ -394,10 +458,17 @@
* to users.
* @throws ShellError If the command line could not be parsed.
*/
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
void spawn_command_line_sync(const std::string& command_line,
std::string* standard_output = 0,
std::string* standard_error = 0,
int* exit_status = 0);
+#else
+void spawn_command_line_sync(const std::string& command_line,
+ std::string* standard_output,
+ std::string* standard_error,
+ int* exit_status, std::auto_ptr<Glib::Error>& error;
+#endif //GLIBMM_EXCEPTIONS_ENABLED
/** On some platforms, notably WIN32, the Pid type represents a resource
* which must be closed to prevent resource leaking. close_pid()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]