Commit c1b88bea authored by Christian Hergert's avatar Christian Hergert

cmake: port to IdeTask

parent 2f71cf55
......@@ -99,17 +99,17 @@ gbp_cmake_build_system_ensure_config_cb (GObject *object,
gpointer user_data)
{
IdeBuildManager *build_manager = (IdeBuildManager *)object;
g_autoptr(GTask) task = user_data;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
g_assert (IDE_IS_BUILD_MANAGER (build_manager));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
if (!ide_build_manager_execute_finish (build_manager, result, &error))
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
}
static void
......@@ -118,16 +118,16 @@ gbp_cmake_build_system_ensure_config_async (GbpCMakeBuildSystem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
IdeBuildManager *build_manager;
IdeContext *context;
g_assert (GBP_IS_CMAKE_BUILD_SYSTEM (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gbp_cmake_build_system_ensure_config_async);
g_task_set_priority (task, G_PRIORITY_LOW);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, gbp_cmake_build_system_ensure_config_async);
ide_task_set_priority (task, G_PRIORITY_LOW);
context = ide_object_get_context (IDE_OBJECT (self));
build_manager = ide_context_get_build_manager (context);
......@@ -145,9 +145,9 @@ gbp_cmake_build_system_ensure_config_finish (GbpCMakeBuildSystem *self,
GError **error)
{
g_assert (GBP_IS_CMAKE_BUILD_SYSTEM (self));
g_assert (G_IS_TASK (result));
g_assert (IDE_IS_TASK (result));
return g_task_propagate_boolean (G_TASK (result), error);
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
static void
......@@ -157,25 +157,25 @@ gbp_cmake_build_system_load_commands_load_cb (GObject *object,
{
IdeCompileCommands *compile_commands = (IdeCompileCommands *)object;
GbpCMakeBuildSystem *self;
g_autoptr(GTask) task = user_data;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
g_assert (IDE_IS_COMPILE_COMMANDS (compile_commands));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
self = g_task_get_source_object (task);
self = ide_task_get_source_object (task);
g_assert (GBP_IS_CMAKE_BUILD_SYSTEM (self));
if (!ide_compile_commands_load_finish (compile_commands, result, &error))
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
return;
}
g_set_object (&self->compile_commands, compile_commands);
g_task_return_pointer (task, g_object_ref (compile_commands), g_object_unref);
ide_task_return_pointer (task, g_object_ref (compile_commands), g_object_unref);
}
static void
......@@ -185,7 +185,7 @@ gbp_cmake_build_system_load_commands_config_cb (GObject *object,
{
GbpCMakeBuildSystem *self = (GbpCMakeBuildSystem *)object;
g_autoptr(IdeCompileCommands) compile_commands = NULL;
g_autoptr(GTask) task = user_data;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GFileMonitor) monitor = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GFile) file = NULL;
......@@ -197,11 +197,11 @@ gbp_cmake_build_system_load_commands_config_cb (GObject *object,
g_assert (GBP_IS_CMAKE_BUILD_SYSTEM (self));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
if (!gbp_cmake_build_system_ensure_config_finish (self, result, &error))
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
return;
}
......@@ -212,10 +212,10 @@ gbp_cmake_build_system_load_commands_config_cb (GObject *object,
if (pipeline == NULL)
{
/* Unlikely, but possible */
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"No build pipeline is available");
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"No build pipeline is available");
return;
}
......@@ -224,16 +224,16 @@ gbp_cmake_build_system_load_commands_config_cb (GObject *object,
if (!g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
/* Unlikely, but possible */
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"Failed to locate compile_commands.json");
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"Failed to locate compile_commands.json");
return;
}
compile_commands = ide_compile_commands_new ();
file = g_file_new_for_path (path);
cancellable = g_task_get_cancellable (task);
cancellable = ide_task_get_cancellable (task);
ide_compile_commands_load_async (compile_commands,
file,
......@@ -250,7 +250,7 @@ gbp_cmake_build_system_load_commands_async (GbpCMakeBuildSystem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
IdeBuildManager *build_manager;
IdeBuildPipeline *pipeline;
IdeContext *context;
......@@ -258,9 +258,9 @@ gbp_cmake_build_system_load_commands_async (GbpCMakeBuildSystem *self,
g_assert (GBP_IS_CMAKE_BUILD_SYSTEM (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gbp_cmake_build_system_load_commands_async);
g_task_set_priority (task, G_PRIORITY_LOW);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, gbp_cmake_build_system_load_commands_async);
ide_task_set_priority (task, G_PRIORITY_LOW);
/*
* If we've already load the compile commands database, use it and
......@@ -270,9 +270,9 @@ gbp_cmake_build_system_load_commands_async (GbpCMakeBuildSystem *self,
if (self->compile_commands != NULL)
{
g_task_return_pointer (task,
g_object_ref (self->compile_commands),
g_object_unref);
ide_task_return_pointer (task,
g_object_ref (self->compile_commands),
g_object_unref);
return;
}
......@@ -330,9 +330,9 @@ gbp_cmake_build_system_load_commands_finish (GbpCMakeBuildSystem *self,
GError **error)
{
g_assert (GBP_IS_CMAKE_BUILD_SYSTEM (self));
g_assert (G_IS_TASK (result));
g_assert (IDE_IS_TASK (result));
return g_task_propagate_pointer (G_TASK (result), error);
return ide_task_propagate_pointer (IDE_TASK (result), error);
}
static void
......@@ -434,7 +434,7 @@ gbp_cmake_build_system_get_build_flags_cb (GObject *object,
{
GbpCMakeBuildSystem *self = (GbpCMakeBuildSystem *)object;
g_autoptr(IdeCompileCommands) compile_commands = NULL;
g_autoptr(GTask) task = user_data;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
g_autoptr(GFile) directory = NULL;
g_auto(GStrv) system_includes = NULL;
......@@ -447,17 +447,17 @@ gbp_cmake_build_system_get_build_flags_cb (GObject *object,
g_assert (GBP_IS_CMAKE_BUILD_SYSTEM (self));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
compile_commands = gbp_cmake_build_system_load_commands_finish (self, result, &error);
if (compile_commands == NULL)
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
return;
}
file = g_task_get_task_data (task);
file = ide_task_get_task_data (task);
g_assert (G_IS_FILE (file));
/* Get non-standard system includes */
......@@ -474,9 +474,9 @@ gbp_cmake_build_system_get_build_flags_cb (GObject *object,
&error);
if (build_flags == NULL)
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, g_steal_pointer (&build_flags), (GDestroyNotify)g_strfreev);
ide_task_return_pointer (task, g_steal_pointer (&build_flags), (GDestroyNotify)g_strfreev);
}
static void
......@@ -487,7 +487,7 @@ gbp_cmake_build_system_get_build_flags_async (IdeBuildSystem *build_system,
gpointer user_data)
{
GbpCMakeBuildSystem *self = (GbpCMakeBuildSystem *)build_system;
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
GFile *gfile;
IDE_ENTRY;
......@@ -498,10 +498,10 @@ gbp_cmake_build_system_get_build_flags_async (IdeBuildSystem *build_system,
gfile = ide_file_get_file (file);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_priority (task, G_PRIORITY_LOW);
g_task_set_source_tag (task, gbp_cmake_build_system_get_build_flags_async);
g_task_set_task_data (task, g_object_ref (gfile), g_object_unref);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_priority (task, G_PRIORITY_LOW);
ide_task_set_source_tag (task, gbp_cmake_build_system_get_build_flags_async);
ide_task_set_task_data (task, g_object_ref (gfile), g_object_unref);
gbp_cmake_build_system_load_commands_async (self,
cancellable,
......@@ -521,9 +521,9 @@ gbp_cmake_build_system_get_build_flags_finish (IdeBuildSystem *build_system,
IDE_ENTRY;
g_assert (GBP_IS_CMAKE_BUILD_SYSTEM (build_system));
g_assert (G_IS_TASK (result));
g_assert (IDE_IS_TASK (result));
build_flags = g_task_propagate_pointer (G_TASK (result), error);
build_flags = ide_task_propagate_pointer (IDE_TASK (result), error);
IDE_RETURN (build_flags);
}
......@@ -559,7 +559,7 @@ gbp_cmake_build_system_notify_pipeline (GbpCMakeBuildSystem *self,
}
static void
gbp_cmake_build_system_init_worker (GTask *task,
gbp_cmake_build_system_init_worker (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
......@@ -577,7 +577,7 @@ gbp_cmake_build_system_init_worker (GTask *task,
if (dzl_str_equal0 (name, "CMakeLists.txt"))
{
g_task_return_pointer (task, g_object_ref (project_file), g_object_unref);
ide_task_return_pointer (task, g_object_ref (project_file), g_object_unref);
IDE_EXIT;
}
......@@ -587,16 +587,16 @@ gbp_cmake_build_system_init_worker (GTask *task,
if (g_file_query_exists (cmake_file, cancellable))
{
g_task_return_pointer (task, g_object_ref (cmake_file), g_object_unref);
ide_task_return_pointer (task, g_object_ref (cmake_file), g_object_unref);
IDE_EXIT;
}
}
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"%s is not supported by the cmake plugin",
name);
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"%s is not supported by the cmake plugin",
name);
IDE_EXIT;
}
......@@ -609,7 +609,7 @@ gbp_cmake_build_system_init_async (GAsyncInitable *initable,
gpointer user_data)
{
GbpCMakeBuildSystem *self = (GbpCMakeBuildSystem *)initable;
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
IdeBuildManager *build_manager;
IdeContext *context;
......@@ -625,10 +625,10 @@ gbp_cmake_build_system_init_async (GAsyncInitable *initable,
build_manager = ide_context_get_build_manager (context);
g_assert (IDE_IS_BUILD_MANAGER (build_manager));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gbp_cmake_build_system_init_async);
g_task_set_priority (task, io_priority);
g_task_set_task_data (task, g_object_ref (self->project_file), g_object_unref);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, gbp_cmake_build_system_init_async);
ide_task_set_priority (task, io_priority);
ide_task_set_task_data (task, g_object_ref (self->project_file), g_object_unref);
/*
* We want to be notified of any changes to the current build manager.
......@@ -640,7 +640,7 @@ gbp_cmake_build_system_init_async (GAsyncInitable *initable,
self,
G_CONNECT_SWAPPED);
g_task_run_in_thread (task, gbp_cmake_build_system_init_worker);
ide_task_run_in_thread (task, gbp_cmake_build_system_init_worker);
IDE_EXIT;
}
......@@ -656,9 +656,9 @@ gbp_cmake_build_system_init_finish (GAsyncInitable *initable,
IDE_ENTRY;
g_assert (GBP_IS_CMAKE_BUILD_SYSTEM (self));
g_assert (G_IS_TASK (result));
g_assert (IDE_IS_TASK (result));
project_file = g_task_propagate_pointer (G_TASK (result), error);
project_file = ide_task_propagate_pointer (IDE_TASK (result), error);
if (g_set_object (&self->project_file, project_file))
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PROJECT_FILE]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment