From bc54751766b8e23495904db5ff0ff17357866638 Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Sun, 12 Oct 2008 21:07:22 +0000 Subject: [PATCH] Refactor handling of transfer=none/shallow/full to separate function 2008-10-12 Tommi Komulainen * girepository/girparser.c (parse_param_transfer, start_parameter): Refactor handling of transfer=none/shallow/full to separate function svn path=/trunk/; revision=688 --- girparser.c | 58 +++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/girparser.c b/girparser.c index 5b66fa682..b8bff22e7 100644 --- a/girparser.c +++ b/girparser.c @@ -658,6 +658,36 @@ start_function (GMarkupParseContext *context, return TRUE; } +static void +parse_param_transfer (GIrNodeParam *param, const gchar *transfer) +{ + if (transfer && strcmp (transfer, "none") == 0) + { + param->transfer = FALSE; + param->shallow_transfer = FALSE; + } + else if (transfer && strcmp (transfer, "shallow") == 0) + { + param->transfer = FALSE; + param->shallow_transfer = TRUE; + } + else + { + if (transfer) + { + if (strcmp (transfer, "full") != 0) + g_warning ("Unknown transfer %s", transfer); + else + param->transfer = TRUE; + } + else if (param->in && !param->out) + param->transfer = FALSE; + else + param->transfer = TRUE; + param->shallow_transfer = FALSE; + } +} + static gboolean start_parameter (GMarkupParseContext *context, const gchar *element_name, @@ -733,32 +763,8 @@ start_parameter (GMarkupParseContext *context, else param->null_ok = FALSE; - if (transfer && strcmp (transfer, "none") == 0) - { - param->transfer = FALSE; - param->shallow_transfer = FALSE; - } - else if (transfer && strcmp (transfer, "shallow") == 0) - { - param->transfer = FALSE; - param->shallow_transfer = TRUE; - } - else - { - if (transfer) - { - if (strcmp (transfer, "full") != 0) - g_warning ("Unknown transfer %s", transfer); - else - param->transfer = TRUE; - } - else if (param->in && !param->out) - param->transfer = FALSE; - else - param->transfer = TRUE; - param->shallow_transfer = FALSE; - } - + parse_param_transfer (param, transfer); + ((GIrNode *)param)->name = g_strdup (name); switch (ctx->current_node->type)