2005-01-25 19:11:26 +00:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2002-03-27 23:15:00 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpscanner.c
|
|
|
|
* Copyright (C) 2002 Sven Neumann <sven@gimp.org>
|
|
|
|
* Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2005-01-25 19:11:26 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-17 22:28:01 +00:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2002-03-27 23:15:00 +00:00
|
|
|
*
|
2005-01-25 19:11:26 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2002-03-27 23:15:00 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2005-01-25 19:11:26 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
2002-03-27 23:15:00 +00:00
|
|
|
*
|
2005-01-25 19:11:26 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-17 22:28:01 +00:00
|
|
|
* License along with this library. If not, see
|
2018-07-11 23:27:07 +02:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2002-03-27 23:15:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-09-06 22:25:19 +00:00
|
|
|
#include <string.h>
|
2002-05-31 13:58:18 +00:00
|
|
|
#include <errno.h>
|
2002-03-27 23:15:00 +00:00
|
|
|
|
2011-04-28 15:50:39 +02:00
|
|
|
#include <cairo.h>
|
2012-05-03 03:36:22 +02:00
|
|
|
#include <gegl.h>
|
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2002-03-27 23:15:00 +00:00
|
|
|
|
2003-07-07 16:22:45 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2002-05-31 13:58:18 +00:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2003-07-07 16:22:45 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2002-05-31 13:58:18 +00:00
|
|
|
|
2003-07-24 14:14:23 +00:00
|
|
|
#include "gimpconfig-error.h"
|
2002-03-27 23:15:00 +00:00
|
|
|
#include "gimpscanner.h"
|
|
|
|
|
2005-01-25 19:11:26 +00:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
2002-03-27 23:15:00 +00:00
|
|
|
|
|
|
|
|
2010-06-29 20:57:52 +02:00
|
|
|
/**
|
|
|
|
* SECTION: gimpscanner
|
|
|
|
* @title: GimpScanner
|
|
|
|
* @short_description: A wrapper around #GScanner with some convenience API.
|
|
|
|
*
|
|
|
|
* A wrapper around #GScanner with some convenience API.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2003-06-24 11:46:19 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2019-08-09 12:42:52 +02:00
|
|
|
gint ref_count;
|
2005-09-28 18:48:42 +00:00
|
|
|
gchar *name;
|
2014-07-02 16:05:23 +02:00
|
|
|
GMappedFile *mapped;
|
|
|
|
gchar *text;
|
2005-09-28 18:48:42 +00:00
|
|
|
GError **error;
|
2003-06-24 11:46:19 +00:00
|
|
|
} GimpScannerData;
|
|
|
|
|
|
|
|
|
2019-08-09 12:42:52 +02:00
|
|
|
G_DEFINE_BOXED_TYPE (GimpScanner, gimp_scanner,
|
|
|
|
gimp_scanner_ref, gimp_scanner_unref)
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-05-31 13:58:18 +00:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
static GimpScanner * gimp_scanner_new (const gchar *name,
|
|
|
|
GMappedFile *mapped,
|
|
|
|
gchar *text,
|
|
|
|
GError **error);
|
|
|
|
static void gimp_scanner_message (GimpScanner *scanner,
|
|
|
|
gchar *message,
|
|
|
|
gboolean is_error);
|
|
|
|
static GTokenType gimp_scanner_parse_deprecated_color (GimpScanner *scanner,
|
|
|
|
GeglColor **color);
|
2002-05-31 13:58:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
|
|
|
* gimp_scanner_new_file:
|
2014-07-01 01:54:31 +02:00
|
|
|
* @file: a #GFile
|
|
|
|
* @error: return location for #GError, or %NULL
|
|
|
|
*
|
2019-08-09 12:42:52 +02:00
|
|
|
* Returns: (transfer full): The new #GimpScanner.
|
2014-07-01 01:54:31 +02:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.10
|
2014-07-01 01:54:31 +02:00
|
|
|
**/
|
2019-08-09 12:42:52 +02:00
|
|
|
GimpScanner *
|
2019-09-21 12:53:38 +02:00
|
|
|
gimp_scanner_new_file (GFile *file,
|
|
|
|
GError **error)
|
2014-07-01 01:54:31 +02:00
|
|
|
{
|
2019-08-09 12:42:52 +02:00
|
|
|
GimpScanner *scanner;
|
|
|
|
gchar *path;
|
2014-07-01 01:54:31 +02:00
|
|
|
|
|
|
|
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
2014-07-02 16:05:23 +02:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
2014-07-01 01:54:31 +02:00
|
|
|
|
|
|
|
path = g_file_get_path (file);
|
|
|
|
|
2014-07-02 16:05:23 +02:00
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
GMappedFile *mapped;
|
|
|
|
|
|
|
|
mapped = g_mapped_file_new (path, FALSE, error);
|
|
|
|
g_free (path);
|
|
|
|
|
|
|
|
if (! mapped)
|
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
(*error)->domain = GIMP_CONFIG_ERROR;
|
|
|
|
(*error)->code = ((*error)->code == G_FILE_ERROR_NOENT ?
|
|
|
|
GIMP_CONFIG_ERROR_OPEN_ENOENT :
|
|
|
|
GIMP_CONFIG_ERROR_OPEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-07-01 01:54:31 +02:00
|
|
|
|
2014-07-02 16:05:23 +02:00
|
|
|
/* gimp_scanner_new() takes a "name" for the scanner, not a filename */
|
|
|
|
scanner = gimp_scanner_new (gimp_file_get_utf8_name (file),
|
|
|
|
mapped, NULL, error);
|
|
|
|
|
|
|
|
g_scanner_input_text (scanner,
|
|
|
|
g_mapped_file_get_contents (mapped),
|
|
|
|
g_mapped_file_get_length (mapped));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GInputStream *input;
|
|
|
|
|
|
|
|
input = G_INPUT_STREAM (g_file_read (file, NULL, error));
|
|
|
|
|
|
|
|
if (! input)
|
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
(*error)->domain = GIMP_CONFIG_ERROR;
|
|
|
|
(*error)->code = ((*error)->code == G_IO_ERROR_NOT_FOUND ?
|
|
|
|
GIMP_CONFIG_ERROR_OPEN_ENOENT :
|
|
|
|
GIMP_CONFIG_ERROR_OPEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-07-04 03:29:09 +02:00
|
|
|
g_object_set_data (G_OBJECT (input), "gimp-data", file);
|
2014-07-02 16:05:23 +02:00
|
|
|
|
2014-07-04 03:29:09 +02:00
|
|
|
scanner = gimp_scanner_new_stream (input, error);
|
|
|
|
|
|
|
|
g_object_unref (input);
|
|
|
|
}
|
|
|
|
|
|
|
|
return scanner;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_scanner_new_stream:
|
|
|
|
* @input: a #GInputStream
|
|
|
|
* @error: return location for #GError, or %NULL
|
|
|
|
*
|
2019-08-09 12:42:52 +02:00
|
|
|
* Returns: (transfer full): The new #GimpScanner.
|
2014-07-04 03:29:09 +02:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.10
|
2014-07-04 03:29:09 +02:00
|
|
|
**/
|
2019-08-09 12:42:52 +02:00
|
|
|
GimpScanner *
|
2014-07-04 03:29:09 +02:00
|
|
|
gimp_scanner_new_stream (GInputStream *input,
|
|
|
|
GError **error)
|
|
|
|
{
|
2019-08-09 12:42:52 +02:00
|
|
|
GimpScanner *scanner;
|
2014-07-04 03:29:09 +02:00
|
|
|
GFile *file;
|
|
|
|
const gchar *path;
|
|
|
|
GString *string;
|
|
|
|
gchar buffer[4096];
|
|
|
|
gsize bytes_read;
|
|
|
|
|
|
|
|
g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
|
|
|
file = g_object_get_data (G_OBJECT (input), "gimp-file");
|
|
|
|
if (file)
|
|
|
|
path = gimp_file_get_utf8_name (file);
|
|
|
|
else
|
|
|
|
path = "stream";
|
2014-07-02 16:05:23 +02:00
|
|
|
|
2014-07-04 03:29:09 +02:00
|
|
|
string = g_string_new (NULL);
|
2014-07-02 16:05:23 +02:00
|
|
|
|
2014-07-04 03:29:09 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
GError *my_error = NULL;
|
|
|
|
gboolean success;
|
|
|
|
|
|
|
|
success = g_input_stream_read_all (input, buffer, sizeof (buffer),
|
|
|
|
&bytes_read, NULL, &my_error);
|
|
|
|
|
|
|
|
if (bytes_read > 0)
|
|
|
|
g_string_append_len (string, buffer, bytes_read);
|
2014-07-02 16:05:23 +02:00
|
|
|
|
2014-07-04 03:29:09 +02:00
|
|
|
if (! success)
|
|
|
|
{
|
|
|
|
if (string->len > 0)
|
2014-07-02 16:05:23 +02:00
|
|
|
{
|
2014-07-04 03:29:09 +02:00
|
|
|
g_printerr ("%s: read error in '%s', trying to scan "
|
|
|
|
"partial content: %s",
|
|
|
|
G_STRFUNC, path, my_error->message);
|
|
|
|
g_clear_error (&my_error);
|
|
|
|
break;
|
2014-07-02 16:05:23 +02:00
|
|
|
}
|
|
|
|
|
2014-07-04 03:29:09 +02:00
|
|
|
g_string_free (string, TRUE);
|
2014-07-02 16:05:23 +02:00
|
|
|
|
2014-07-04 03:29:09 +02:00
|
|
|
g_propagate_error (error, my_error);
|
2014-07-02 16:05:23 +02:00
|
|
|
|
2014-07-04 03:29:09 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2014-07-02 16:05:23 +02:00
|
|
|
}
|
2014-07-04 03:29:09 +02:00
|
|
|
while (bytes_read == sizeof (buffer));
|
|
|
|
|
|
|
|
/* gimp_scanner_new() takes a "name" for the scanner, not a filename */
|
|
|
|
scanner = gimp_scanner_new (path, NULL, string->str, error);
|
|
|
|
|
|
|
|
bytes_read = string->len;
|
|
|
|
|
|
|
|
g_scanner_input_text (scanner, g_string_free (string, FALSE), bytes_read);
|
2014-07-01 01:54:31 +02:00
|
|
|
|
|
|
|
return scanner;
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
|
|
|
* gimp_scanner_new_string:
|
2020-05-03 18:11:29 +02:00
|
|
|
* @text: (array length=text_len):
|
|
|
|
* @text_len: The length of @text, or -1 if NULL-terminated
|
|
|
|
* @error: return location for #GError, or %NULL
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-09 12:42:52 +02:00
|
|
|
* Returns: (transfer full): The new #GimpScanner.
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2019-08-09 12:42:52 +02:00
|
|
|
GimpScanner *
|
2003-06-23 22:02:56 +00:00
|
|
|
gimp_scanner_new_string (const gchar *text,
|
2006-04-12 10:53:28 +00:00
|
|
|
gint text_len,
|
|
|
|
GError **error)
|
2003-06-23 22:02:56 +00:00
|
|
|
{
|
2019-08-09 12:42:52 +02:00
|
|
|
GimpScanner *scanner;
|
2003-06-23 22:02:56 +00:00
|
|
|
|
2020-01-29 21:08:35 +02:00
|
|
|
g_return_val_if_fail (text != NULL || text_len <= 0, NULL);
|
2003-06-23 22:02:56 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
|
|
|
if (text_len < 0)
|
2020-01-29 21:08:35 +02:00
|
|
|
text_len = text ? strlen (text) : 0;
|
2003-06-23 22:02:56 +00:00
|
|
|
|
2014-07-02 16:05:23 +02:00
|
|
|
scanner = gimp_scanner_new (NULL, NULL, NULL, error);
|
2003-06-23 22:02:56 +00:00
|
|
|
|
|
|
|
g_scanner_input_text (scanner, text, text_len);
|
|
|
|
|
|
|
|
return scanner;
|
|
|
|
}
|
|
|
|
|
2019-08-09 12:42:52 +02:00
|
|
|
static GimpScanner *
|
2003-06-24 11:46:19 +00:00
|
|
|
gimp_scanner_new (const gchar *name,
|
2014-07-02 16:05:23 +02:00
|
|
|
GMappedFile *mapped,
|
|
|
|
gchar *text,
|
2003-06-24 11:46:19 +00:00
|
|
|
GError **error)
|
2003-06-23 22:02:56 +00:00
|
|
|
{
|
2019-08-09 12:42:52 +02:00
|
|
|
GimpScanner *scanner;
|
2003-06-24 11:46:19 +00:00
|
|
|
GimpScannerData *data;
|
2003-06-23 22:02:56 +00:00
|
|
|
|
|
|
|
scanner = g_scanner_new (NULL);
|
2002-05-31 13:58:18 +00:00
|
|
|
|
2007-05-22 17:58:02 +00:00
|
|
|
data = g_slice_new0 (GimpScannerData);
|
2003-06-24 11:46:19 +00:00
|
|
|
|
2019-08-09 12:42:52 +02:00
|
|
|
data->ref_count = 1;
|
|
|
|
data->name = g_strdup (name);
|
|
|
|
data->mapped = mapped;
|
|
|
|
data->text = text;
|
|
|
|
data->error = error;
|
2003-06-24 11:46:19 +00:00
|
|
|
|
|
|
|
scanner->user_data = data;
|
2002-05-31 13:58:18 +00:00
|
|
|
scanner->msg_handler = gimp_scanner_message;
|
|
|
|
|
|
|
|
scanner->config->cset_identifier_first = ( G_CSET_a_2_z G_CSET_A_2_Z );
|
2003-02-08 23:48:29 +00:00
|
|
|
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z G_CSET_A_2_Z
|
|
|
|
G_CSET_DIGITS "-_" );
|
2002-05-31 13:58:18 +00:00
|
|
|
scanner->config->scan_identifier_1char = TRUE;
|
2002-03-27 23:15:00 +00:00
|
|
|
|
2003-11-14 13:41:16 +00:00
|
|
|
scanner->config->store_int64 = TRUE;
|
|
|
|
|
2002-03-27 23:15:00 +00:00
|
|
|
return scanner;
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
2019-08-09 12:42:52 +02:00
|
|
|
* gimp_scanner_ref:
|
|
|
|
* @scanner: #GimpScanner to ref
|
|
|
|
*
|
|
|
|
* Adds a reference to a #GimpScanner.
|
|
|
|
*
|
|
|
|
* Returns: the same @scanner.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
GimpScanner *
|
|
|
|
gimp_scanner_ref (GimpScanner *scanner)
|
|
|
|
{
|
|
|
|
GimpScannerData *data;
|
|
|
|
|
|
|
|
g_return_val_if_fail (scanner != NULL, NULL);
|
|
|
|
|
|
|
|
data = scanner->user_data;
|
|
|
|
|
|
|
|
data->ref_count++;
|
|
|
|
|
|
|
|
return scanner;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_scanner_unref:
|
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-09 12:42:52 +02:00
|
|
|
* Unref a #GimpScanner. If the reference count drops to zero, the
|
|
|
|
* scanner is freed.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2002-03-27 23:15:00 +00:00
|
|
|
void
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_unref (GimpScanner *scanner)
|
2002-03-27 23:15:00 +00:00
|
|
|
{
|
2003-06-24 11:46:19 +00:00
|
|
|
GimpScannerData *data;
|
|
|
|
|
2002-03-27 23:15:00 +00:00
|
|
|
g_return_if_fail (scanner != NULL);
|
|
|
|
|
2003-06-24 11:46:19 +00:00
|
|
|
data = scanner->user_data;
|
|
|
|
|
2019-08-09 12:42:52 +02:00
|
|
|
data->ref_count--;
|
2014-07-02 16:05:23 +02:00
|
|
|
|
2019-08-09 12:42:52 +02:00
|
|
|
if (data->ref_count < 1)
|
|
|
|
{
|
|
|
|
if (data->mapped)
|
|
|
|
g_mapped_file_unref (data->mapped);
|
|
|
|
|
|
|
|
if (data->text)
|
|
|
|
g_free (data->text);
|
2003-06-24 11:46:19 +00:00
|
|
|
|
2019-08-09 12:42:52 +02:00
|
|
|
g_free (data->name);
|
|
|
|
g_slice_free (GimpScannerData, data);
|
2003-06-24 11:46:19 +00:00
|
|
|
|
2019-08-09 12:42:52 +02:00
|
|
|
g_scanner_destroy (scanner);
|
|
|
|
}
|
2002-03-27 23:15:00 +00:00
|
|
|
}
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
|
|
|
* gimp_scanner_parse_token:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
2018-07-17 12:32:05 +02:00
|
|
|
* @token: the #GTokenType expected as next token.
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE if the next token is @token, %FALSE otherwise.
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2002-03-27 23:15:00 +00:00
|
|
|
gboolean
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_parse_token (GimpScanner *scanner,
|
|
|
|
GTokenType token)
|
2002-03-27 23:15:00 +00:00
|
|
|
{
|
|
|
|
if (g_scanner_peek_next_token (scanner) != token)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
|
|
|
* gimp_scanner_parse_identifier:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
2020-05-03 18:12:37 +02:00
|
|
|
* @identifier: (out): the expected identifier.
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE if the next token is an identifier and if its
|
2018-07-17 12:32:05 +02:00
|
|
|
* value matches @identifier.
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2002-05-24 02:53:20 +00:00
|
|
|
gboolean
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_parse_identifier (GimpScanner *scanner,
|
2002-05-24 02:53:20 +00:00
|
|
|
const gchar *identifier)
|
|
|
|
{
|
|
|
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
if (strcmp (scanner->value.v_identifier, identifier))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
|
|
|
* gimp_scanner_parse_string:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
2020-05-03 18:12:37 +02:00
|
|
|
* @dest: (out): Return location for the parsed string
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE on success
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2002-03-27 23:15:00 +00:00
|
|
|
gboolean
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_parse_string (GimpScanner *scanner,
|
|
|
|
gchar **dest)
|
2002-03-27 23:15:00 +00:00
|
|
|
{
|
|
|
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
if (*scanner->value.v_string)
|
|
|
|
{
|
|
|
|
if (! g_utf8_validate (scanner->value.v_string, -1, NULL))
|
|
|
|
{
|
|
|
|
g_scanner_warn (scanner, _("invalid UTF-8 string"));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-11-14 13:41:16 +00:00
|
|
|
|
2002-03-27 23:15:00 +00:00
|
|
|
*dest = g_strdup (scanner->value.v_string);
|
|
|
|
}
|
2003-02-03 14:48:39 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*dest = NULL;
|
|
|
|
}
|
2002-03-27 23:15:00 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
|
|
|
* gimp_scanner_parse_string_no_validate:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
2020-05-03 18:12:37 +02:00
|
|
|
* @dest: (out): Return location for the parsed string
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE on success
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2002-03-27 23:15:00 +00:00
|
|
|
gboolean
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_parse_string_no_validate (GimpScanner *scanner,
|
|
|
|
gchar **dest)
|
2002-03-27 23:15:00 +00:00
|
|
|
{
|
|
|
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
if (*scanner->value.v_string)
|
|
|
|
*dest = g_strdup (scanner->value.v_string);
|
2003-02-03 14:48:39 +00:00
|
|
|
else
|
|
|
|
*dest = NULL;
|
2002-03-27 23:15:00 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
|
|
|
* gimp_scanner_parse_data:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
2018-05-12 12:13:12 -04:00
|
|
|
* @length: Length of the data to parse
|
2021-12-02 12:46:05 +01:00
|
|
|
* @dest: (out) (array length=length): Return location for the parsed data
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE on success
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2004-05-18 21:19:43 +00:00
|
|
|
gboolean
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_parse_data (GimpScanner *scanner,
|
|
|
|
gint length,
|
|
|
|
guint8 **dest)
|
2004-05-18 21:19:43 +00:00
|
|
|
{
|
|
|
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
if (scanner->value.v_string)
|
2021-08-26 17:18:32 +02:00
|
|
|
*dest = g_memdup2 (scanner->value.v_string, length);
|
2004-05-18 21:19:43 +00:00
|
|
|
else
|
|
|
|
*dest = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
|
|
|
* gimp_scanner_parse_int:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
2020-05-03 18:12:37 +02:00
|
|
|
* @dest: (out): Return location for the parsed integer
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE on success
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2002-03-27 23:15:00 +00:00
|
|
|
gboolean
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_parse_int (GimpScanner *scanner,
|
|
|
|
gint *dest)
|
2002-03-27 23:15:00 +00:00
|
|
|
{
|
2003-02-03 14:48:39 +00:00
|
|
|
gboolean negate = FALSE;
|
|
|
|
|
|
|
|
if (g_scanner_peek_next_token (scanner) == '-')
|
|
|
|
{
|
|
|
|
negate = TRUE;
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
}
|
|
|
|
|
2002-03-27 23:15:00 +00:00
|
|
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_INT)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
2003-02-03 14:48:39 +00:00
|
|
|
if (negate)
|
2003-11-14 13:41:16 +00:00
|
|
|
*dest = -scanner->value.v_int64;
|
2003-02-03 14:48:39 +00:00
|
|
|
else
|
2003-11-14 13:41:16 +00:00
|
|
|
*dest = scanner->value.v_int64;
|
2002-03-27 23:15:00 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-06-28 22:02:29 +02:00
|
|
|
/**
|
|
|
|
* gimp_scanner_parse_int64:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2013-06-28 22:02:29 +02:00
|
|
|
* gimp_scanner_new_string()
|
2020-05-03 18:12:37 +02:00
|
|
|
* @dest: (out): Return location for the parsed integer
|
2013-06-28 22:02:29 +02:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE on success
|
2013-06-28 22:02:29 +02:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.8
|
2013-06-28 22:02:29 +02:00
|
|
|
**/
|
|
|
|
gboolean
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_parse_int64 (GimpScanner *scanner,
|
|
|
|
gint64 *dest)
|
2013-06-28 22:02:29 +02:00
|
|
|
{
|
|
|
|
gboolean negate = FALSE;
|
|
|
|
|
|
|
|
if (g_scanner_peek_next_token (scanner) == '-')
|
|
|
|
{
|
|
|
|
negate = TRUE;
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_INT)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
if (negate)
|
|
|
|
*dest = -scanner->value.v_int64;
|
|
|
|
else
|
|
|
|
*dest = scanner->value.v_int64;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 14:03:37 +01:00
|
|
|
* gimp_scanner_parse_double:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 14:03:37 +01:00
|
|
|
* @dest: (out): Return location for the parsed double
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE on success
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2002-03-27 23:15:00 +00:00
|
|
|
gboolean
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 14:03:37 +01:00
|
|
|
gimp_scanner_parse_double (GimpScanner *scanner,
|
|
|
|
gdouble *dest)
|
2002-03-27 23:15:00 +00:00
|
|
|
{
|
2017-05-27 15:48:51 -04:00
|
|
|
gboolean negate = FALSE;
|
|
|
|
|
|
|
|
if (g_scanner_peek_next_token (scanner) == '-')
|
|
|
|
{
|
|
|
|
negate = TRUE;
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
}
|
|
|
|
|
2019-07-30 14:31:14 +02:00
|
|
|
if (g_scanner_peek_next_token (scanner) == G_TOKEN_FLOAT)
|
|
|
|
{
|
|
|
|
g_scanner_get_next_token (scanner);
|
2002-03-27 23:15:00 +00:00
|
|
|
|
2019-07-30 14:31:14 +02:00
|
|
|
if (negate)
|
|
|
|
*dest = -scanner->value.v_float;
|
|
|
|
else
|
|
|
|
*dest = scanner->value.v_float;
|
2002-03-27 23:15:00 +00:00
|
|
|
|
2019-07-30 14:31:14 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (g_scanner_peek_next_token (scanner) == G_TOKEN_INT)
|
|
|
|
{
|
2020-09-21 19:36:25 -04:00
|
|
|
/* v_int is unsigned so we need to cast to
|
2019-08-18 18:17:19 +02:00
|
|
|
*
|
2020-09-21 19:36:25 -04:00
|
|
|
* gint64 first for negative values.
|
2019-08-18 18:17:19 +02:00
|
|
|
*/
|
|
|
|
|
2019-07-30 14:31:14 +02:00
|
|
|
g_scanner_get_next_token (scanner);
|
2002-03-27 23:15:00 +00:00
|
|
|
|
2019-07-30 14:31:14 +02:00
|
|
|
if (negate)
|
2020-09-21 19:36:25 -04:00
|
|
|
*dest = - (gint64) scanner->value.v_int;
|
2019-07-30 14:31:14 +02:00
|
|
|
else
|
2020-09-21 19:36:25 -04:00
|
|
|
*dest = scanner->value.v_int;
|
2019-07-30 14:31:14 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2002-03-27 23:15:00 +00:00
|
|
|
}
|
2002-05-31 13:58:18 +00:00
|
|
|
|
2011-11-05 17:02:51 +01:00
|
|
|
/**
|
|
|
|
* gimp_scanner_parse_boolean:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
2020-05-03 18:12:37 +02:00
|
|
|
* @dest: (out): Return location for the parsed boolean
|
2011-11-05 17:02:51 +01:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE on success
|
2011-11-05 17:02:51 +01:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2011-11-05 17:02:51 +01:00
|
|
|
**/
|
|
|
|
gboolean
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_parse_boolean (GimpScanner *scanner,
|
|
|
|
gboolean *dest)
|
2011-11-05 17:02:51 +01:00
|
|
|
{
|
|
|
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
if (! g_ascii_strcasecmp (scanner->value.v_identifier, "yes") ||
|
|
|
|
! g_ascii_strcasecmp (scanner->value.v_identifier, "true"))
|
|
|
|
{
|
|
|
|
*dest = TRUE;
|
|
|
|
}
|
|
|
|
else if (! g_ascii_strcasecmp (scanner->value.v_identifier, "no") ||
|
|
|
|
! g_ascii_strcasecmp (scanner->value.v_identifier, "false"))
|
|
|
|
{
|
|
|
|
*dest = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_scanner_error
|
|
|
|
(scanner,
|
|
|
|
/* please don't translate 'yes' and 'no' */
|
|
|
|
_("expected 'yes' or 'no' for boolean token, got '%s'"),
|
|
|
|
scanner->value.v_identifier);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-05-31 13:58:18 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLOR_RGB = 1,
|
|
|
|
COLOR_RGBA,
|
|
|
|
COLOR_HSV,
|
2023-12-12 00:34:24 +09:00
|
|
|
COLOR_HSVA,
|
|
|
|
COLOR
|
2002-05-31 13:58:18 +00:00
|
|
|
};
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
|
|
|
* gimp_scanner_parse_color:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
2023-12-12 00:34:24 +09:00
|
|
|
* @color: (out callee-allocates): Pointer to a color to store the result
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE on success
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2002-05-31 13:58:18 +00:00
|
|
|
gboolean
|
2023-12-12 00:34:24 +09:00
|
|
|
gimp_scanner_parse_color (GimpScanner *scanner,
|
|
|
|
GeglColor **color)
|
2002-05-31 13:58:18 +00:00
|
|
|
{
|
|
|
|
guint scope_id;
|
|
|
|
guint old_scope_id;
|
|
|
|
GTokenType token;
|
2023-12-12 00:34:24 +09:00
|
|
|
gboolean success = TRUE;
|
2002-05-31 13:58:18 +00:00
|
|
|
|
|
|
|
scope_id = g_quark_from_static_string ("gimp_scanner_parse_color");
|
|
|
|
old_scope_id = g_scanner_set_scope (scanner, scope_id);
|
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
if (! g_scanner_scope_lookup_symbol (scanner, scope_id, "color"))
|
2002-05-31 13:58:18 +00:00
|
|
|
{
|
2023-12-12 00:34:24 +09:00
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
|
|
|
"color", GINT_TO_POINTER (COLOR));
|
|
|
|
/* Deprecated. Kept for backward compatibility. */
|
2004-07-26 19:56:47 +00:00
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
2002-05-31 13:58:18 +00:00
|
|
|
"color-rgb", GINT_TO_POINTER (COLOR_RGB));
|
2004-07-26 19:56:47 +00:00
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
2002-05-31 13:58:18 +00:00
|
|
|
"color-rgba", GINT_TO_POINTER (COLOR_RGBA));
|
2004-07-26 19:56:47 +00:00
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
2002-05-31 13:58:18 +00:00
|
|
|
"color-hsv", GINT_TO_POINTER (COLOR_HSV));
|
2004-07-26 19:56:47 +00:00
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
2002-05-31 13:58:18 +00:00
|
|
|
"color-hsva", GINT_TO_POINTER (COLOR_HSVA));
|
|
|
|
}
|
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
token = g_scanner_peek_next_token (scanner);
|
2002-05-31 13:58:18 +00:00
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
if (token == G_TOKEN_IDENTIFIER)
|
2002-05-31 13:58:18 +00:00
|
|
|
{
|
2023-12-12 00:34:24 +09:00
|
|
|
g_scanner_get_next_token (scanner);
|
2002-05-31 13:58:18 +00:00
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
if (g_ascii_strcasecmp (scanner->value.v_identifier, "null") != 0)
|
|
|
|
/* Do not fail the whole color parsing. Just output to stderr and assume
|
|
|
|
* a NULL color property.
|
|
|
|
*/
|
|
|
|
g_printerr ("%s: expected NULL identifier for serialized color, got '%s'. "
|
|
|
|
"Assuming NULL instead.\n",
|
|
|
|
G_STRFUNC, scanner->value.v_identifier);
|
2002-05-31 13:58:18 +00:00
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
*color = NULL;
|
2003-07-07 16:22:45 +00:00
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
token = g_scanner_peek_next_token (scanner);
|
|
|
|
if (token == G_TOKEN_RIGHT_PAREN)
|
|
|
|
token = G_TOKEN_NONE;
|
|
|
|
else
|
|
|
|
token = G_TOKEN_RIGHT_PAREN;
|
|
|
|
}
|
|
|
|
else if (token == G_TOKEN_LEFT_PAREN)
|
|
|
|
{
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
token = g_scanner_peek_next_token (scanner);
|
2002-05-31 13:58:18 +00:00
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
if (token == G_TOKEN_SYMBOL)
|
|
|
|
{
|
|
|
|
if (GPOINTER_TO_INT (scanner->next_value.v_symbol) != COLOR)
|
|
|
|
{
|
|
|
|
/* Support historical GimpRGB format which may be stored in various config
|
|
|
|
* files, but even some data (such as GTP tool presets which contains
|
|
|
|
* tool-options which are GimpContext).
|
|
|
|
*/
|
|
|
|
if (gimp_scanner_parse_deprecated_color (scanner, color))
|
|
|
|
token = G_TOKEN_RIGHT_PAREN;
|
|
|
|
else
|
|
|
|
success = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const Babl *format;
|
|
|
|
gchar *encoding;
|
|
|
|
guint8 *data;
|
|
|
|
gint data_length;
|
|
|
|
gint profile_data_length;
|
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_string (scanner, &encoding))
|
|
|
|
{
|
|
|
|
token = G_TOKEN_STRING;
|
|
|
|
goto color_parsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! babl_format_exists (encoding))
|
|
|
|
{
|
|
|
|
g_scanner_error (scanner,
|
|
|
|
"%s: format \"%s\" for serialized color is not a valid babl format.",
|
|
|
|
G_STRFUNC, encoding);
|
|
|
|
g_free (encoding);
|
|
|
|
success = FALSE;
|
|
|
|
goto color_parsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
format = babl_format (encoding);
|
|
|
|
g_free (encoding);
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_int (scanner, &data_length))
|
|
|
|
{
|
|
|
|
token = G_TOKEN_INT;
|
|
|
|
goto color_parsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data_length != babl_format_get_bytes_per_pixel (format))
|
|
|
|
{
|
|
|
|
g_scanner_error (scanner,
|
|
|
|
"%s: format \"%s\" expects %d bpp but color was serialized with %d bpp.",
|
|
|
|
G_STRFUNC, babl_get_name (format),
|
|
|
|
babl_format_get_bytes_per_pixel (format),
|
|
|
|
data_length);
|
|
|
|
success = FALSE;
|
|
|
|
goto color_parsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_data (scanner, data_length, &data))
|
|
|
|
{
|
|
|
|
token = G_TOKEN_STRING;
|
|
|
|
goto color_parsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_int (scanner, &profile_data_length))
|
|
|
|
{
|
|
|
|
g_free (data);
|
|
|
|
token = G_TOKEN_INT;
|
|
|
|
goto color_parsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (profile_data_length > 0)
|
|
|
|
{
|
|
|
|
const Babl *space = NULL;
|
|
|
|
GimpColorProfile *profile;
|
|
|
|
guint8 *profile_data;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_data (scanner, profile_data_length, &profile_data))
|
|
|
|
{
|
|
|
|
g_free (data);
|
|
|
|
token = G_TOKEN_STRING;
|
|
|
|
goto color_parsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
profile = gimp_color_profile_new_from_icc_profile (profile_data, profile_data_length, &error);
|
|
|
|
|
|
|
|
if (profile)
|
|
|
|
{
|
|
|
|
space = gimp_color_profile_get_space (profile,
|
|
|
|
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
|
|
|
|
&error);
|
|
|
|
|
|
|
|
if (! space)
|
|
|
|
{
|
|
|
|
g_scanner_error (scanner,
|
|
|
|
"%s: failed to create Babl space for serialized color from profile: %s\n",
|
|
|
|
G_STRFUNC, error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
g_object_unref (profile);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_scanner_error (scanner,
|
|
|
|
"%s: invalid profile data for serialized color: %s",
|
|
|
|
G_STRFUNC, error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
format = babl_format_with_space (babl_format_get_encoding (format), space);
|
|
|
|
|
|
|
|
g_free (profile_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
*color = gegl_color_new (NULL);
|
|
|
|
gegl_color_set_pixel (*color, format, data);
|
|
|
|
|
|
|
|
token = G_TOKEN_RIGHT_PAREN;
|
|
|
|
g_free (data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
token = G_TOKEN_SYMBOL;
|
|
|
|
}
|
2002-05-31 13:58:18 +00:00
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
if (success && token == G_TOKEN_RIGHT_PAREN)
|
|
|
|
{
|
|
|
|
token = g_scanner_peek_next_token (scanner);
|
|
|
|
if (token == G_TOKEN_RIGHT_PAREN)
|
|
|
|
{
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
token = G_TOKEN_NONE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_clear_object (color);
|
|
|
|
token = G_TOKEN_RIGHT_PAREN;
|
|
|
|
}
|
2002-05-31 13:58:18 +00:00
|
|
|
}
|
|
|
|
}
|
2023-12-12 00:34:24 +09:00
|
|
|
else
|
|
|
|
{
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
}
|
2002-05-31 13:58:18 +00:00
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
color_parsed:
|
2002-05-31 13:58:18 +00:00
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
if (success && token != G_TOKEN_NONE)
|
2002-05-31 13:58:18 +00:00
|
|
|
{
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
|
|
|
|
_("fatal parse error"), TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_scanner_set_scope (scanner, old_scope_id);
|
|
|
|
|
2023-12-12 00:34:24 +09:00
|
|
|
return (success && token == G_TOKEN_NONE);
|
2002-06-02 19:48:01 +00:00
|
|
|
}
|
|
|
|
|
2005-01-29 12:54:48 +00:00
|
|
|
/**
|
|
|
|
* gimp_scanner_parse_matrix2:
|
2019-08-09 12:42:52 +02:00
|
|
|
* @scanner: A #GimpScanner created by gimp_scanner_new_file() or
|
2011-11-05 17:02:51 +01:00
|
|
|
* gimp_scanner_new_string()
|
2021-12-02 12:46:05 +01:00
|
|
|
* @dest: (out caller-allocates): Pointer to a matrix to store the result
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: %TRUE on success
|
2005-01-29 12:54:48 +00:00
|
|
|
*
|
2015-05-31 21:18:09 +02:00
|
|
|
* Since: 2.4
|
2005-01-29 12:54:48 +00:00
|
|
|
**/
|
2003-07-07 16:22:45 +00:00
|
|
|
gboolean
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_parse_matrix2 (GimpScanner *scanner,
|
2003-07-07 16:22:45 +00:00
|
|
|
GimpMatrix2 *dest)
|
|
|
|
{
|
|
|
|
guint scope_id;
|
|
|
|
guint old_scope_id;
|
|
|
|
GTokenType token;
|
|
|
|
GimpMatrix2 matrix;
|
|
|
|
|
|
|
|
scope_id = g_quark_from_static_string ("gimp_scanner_parse_matrix");
|
|
|
|
old_scope_id = g_scanner_set_scope (scanner, scope_id);
|
|
|
|
|
|
|
|
if (! g_scanner_scope_lookup_symbol (scanner, scope_id, "matrix"))
|
2004-11-14 02:50:33 +00:00
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
|
|
|
"matrix", GINT_TO_POINTER (0));
|
2003-07-07 16:22:45 +00:00
|
|
|
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
|
|
|
|
while (g_scanner_peek_next_token (scanner) == token)
|
|
|
|
{
|
|
|
|
token = g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case G_TOKEN_LEFT_PAREN:
|
|
|
|
token = G_TOKEN_SYMBOL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_SYMBOL:
|
|
|
|
{
|
|
|
|
token = G_TOKEN_FLOAT;
|
|
|
|
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 14:03:37 +01:00
|
|
|
if (! gimp_scanner_parse_double (scanner, &matrix.coeff[0][0]))
|
2003-07-07 16:22:45 +00:00
|
|
|
goto finish;
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 14:03:37 +01:00
|
|
|
if (! gimp_scanner_parse_double (scanner, &matrix.coeff[0][1]))
|
2003-07-07 16:22:45 +00:00
|
|
|
goto finish;
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 14:03:37 +01:00
|
|
|
if (! gimp_scanner_parse_double (scanner, &matrix.coeff[1][0]))
|
2003-07-07 16:22:45 +00:00
|
|
|
goto finish;
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 14:03:37 +01:00
|
|
|
if (! gimp_scanner_parse_double (scanner, &matrix.coeff[1][1]))
|
2003-07-07 16:22:45 +00:00
|
|
|
goto finish;
|
|
|
|
|
|
|
|
token = G_TOKEN_RIGHT_PAREN;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_RIGHT_PAREN:
|
|
|
|
token = G_TOKEN_NONE; /* indicates success */
|
|
|
|
goto finish;
|
|
|
|
|
|
|
|
default: /* do nothing */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
finish:
|
|
|
|
|
|
|
|
if (token != G_TOKEN_NONE)
|
|
|
|
{
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
|
|
|
|
_("fatal parse error"), TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*dest = matrix;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_scanner_set_scope (scanner, old_scope_id);
|
|
|
|
|
|
|
|
return (token == G_TOKEN_NONE);
|
|
|
|
}
|
|
|
|
|
2002-05-31 13:58:18 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2019-08-09 12:42:52 +02:00
|
|
|
gimp_scanner_message (GimpScanner *scanner,
|
|
|
|
gchar *message,
|
|
|
|
gboolean is_error)
|
2002-05-31 13:58:18 +00:00
|
|
|
{
|
2003-06-24 11:46:19 +00:00
|
|
|
GimpScannerData *data = scanner->user_data;
|
2002-05-31 13:58:18 +00:00
|
|
|
|
|
|
|
/* we don't expect warnings */
|
|
|
|
g_return_if_fail (is_error);
|
|
|
|
|
2003-06-24 11:46:19 +00:00
|
|
|
if (data->name)
|
2003-11-14 15:33:40 +00:00
|
|
|
g_set_error (data->error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
|
|
|
|
_("Error while parsing '%s' in line %d: %s"),
|
2003-06-24 11:46:19 +00:00
|
|
|
data->name, scanner->line, message);
|
2003-06-23 22:02:56 +00:00
|
|
|
else
|
2003-06-24 11:46:19 +00:00
|
|
|
/* should never happen, thus not marked for translation */
|
2003-11-14 15:33:40 +00:00
|
|
|
g_set_error (data->error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
|
|
|
|
"Error parsing internal buffer: %s", message);
|
2002-05-31 13:58:18 +00:00
|
|
|
}
|
2023-12-12 00:34:24 +09:00
|
|
|
|
|
|
|
static GTokenType
|
|
|
|
gimp_scanner_parse_deprecated_color (GimpScanner *scanner,
|
|
|
|
GeglColor **color)
|
|
|
|
{
|
|
|
|
guint scope_id;
|
|
|
|
guint old_scope_id;
|
|
|
|
GTokenType token;
|
|
|
|
|
|
|
|
scope_id = g_quark_from_static_string ("gimp_scanner_parse_deprecated_color");
|
|
|
|
old_scope_id = g_scanner_set_scope (scanner, scope_id);
|
|
|
|
|
|
|
|
if (! g_scanner_scope_lookup_symbol (scanner, scope_id, "color-rgb"))
|
|
|
|
{
|
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
|
|
|
"color-rgb", GINT_TO_POINTER (COLOR_RGB));
|
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
|
|
|
"color-rgba", GINT_TO_POINTER (COLOR_RGBA));
|
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
|
|
|
"color-hsv", GINT_TO_POINTER (COLOR_HSV));
|
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
|
|
|
"color-hsva", GINT_TO_POINTER (COLOR_HSVA));
|
|
|
|
}
|
|
|
|
|
|
|
|
token = G_TOKEN_SYMBOL;
|
|
|
|
|
|
|
|
while (g_scanner_peek_next_token (scanner) == token)
|
|
|
|
{
|
|
|
|
token = g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case G_TOKEN_SYMBOL:
|
|
|
|
{
|
|
|
|
gdouble col[4] = { 0.0, 0.0, 0.0, 1.0 };
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 14:03:37 +01:00
|
|
|
gfloat col_f[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
2023-12-12 00:34:24 +09:00
|
|
|
gint n_channels = 4;
|
|
|
|
gboolean is_hsv = FALSE;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
|
|
|
|
{
|
|
|
|
case COLOR_RGB:
|
|
|
|
n_channels = 3;
|
|
|
|
/* fallthrough */
|
|
|
|
case COLOR_RGBA:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLOR_HSV:
|
|
|
|
n_channels = 3;
|
|
|
|
/* fallthrough */
|
|
|
|
case COLOR_HSVA:
|
|
|
|
is_hsv = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = G_TOKEN_FLOAT;
|
|
|
|
|
|
|
|
for (i = 0; i < n_channels; i++)
|
|
|
|
{
|
app, libgimp*, pdb, plug-ins: rename various public API name s/float/double/.
Several types functions were using the wording "float" historically to
mean double-precision, e.g. the float array type (which was in fact a
double array). Or the scanner function gimp_scanner_parse_float() was in
fact returning a double value. What if we wanted someday to actually add
float (usually this naming means in C the single-precision IEEE 754
floating point representation) support? How would we name this?
Now technically it's not entirely wrong (a double is still a floating
point). So I've been wondering if that is because maybe we never planned
to have float and double precision may be good enough for all usage in a
plug-in API (which doesn't have to be as generic so the higher precision
is enough)? But how can we be sure? Also we already had some functions
using the wording double (e.g. gimp_procedure_add_double_argument()), so
let's just go the safe route and use the accurate wording.
The additional change in PDB is internal, but there too, I was also
finding very confusing that we were naming double-precision float as
'float' type. So I took the opportunity to update this. It doesn't
change any signature.
In fact the whole commit doesn't change any type or code logic, only
naming, except for one bug fix in the middle which I encountered while
renaming: in gimp_scanner_parse_deprecated_color(), I discovered a
hidden bug in scanning (color-hsv*) values, which was mistakenly using a
double type for an array of float.
2024-11-02 14:03:37 +01:00
|
|
|
if (! gimp_scanner_parse_double (scanner, &col[i]))
|
2023-12-12 00:34:24 +09:00
|
|
|
goto finish;
|
2024-04-21 03:42:27 +00:00
|
|
|
|
|
|
|
col_f[i] = (gfloat) col[i];
|
2023-12-12 00:34:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
*color = gegl_color_new (NULL);
|
|
|
|
if (is_hsv)
|
2024-04-21 03:42:27 +00:00
|
|
|
gegl_color_set_pixel (*color, babl_format ("HSVA float"), col_f);
|
2023-12-12 00:34:24 +09:00
|
|
|
else
|
|
|
|
gegl_color_set_pixel (*color, babl_format ("R'G'B'A double"), col);
|
|
|
|
|
|
|
|
/* Indicates success. */
|
|
|
|
token = G_TOKEN_NONE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* do nothing */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
finish:
|
|
|
|
|
|
|
|
g_scanner_set_scope (scanner, old_scope_id);
|
|
|
|
|
|
|
|
return token;
|
|
|
|
}
|