[gegl] serialize: add more corner cases and workarounds for them
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] serialize: add more corner cases and workarounds for them
- Date: Fri, 15 Apr 2016 21:41:02 +0000 (UTC)
commit 3270e9336185e8b8b6d32d74662e1ff6c0c14f05
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Apr 15 17:51:55 2016 +0100
serialize: add more corner cases and workarounds for them
gegl/gegl-serialize.c | 66 ++++++++++++++++++++++++++++++++---------
tests/simple/test-serialize.c | 33 +++++++++-----------
2 files changed, 67 insertions(+), 32 deletions(-)
---
diff --git a/gegl/gegl-serialize.c b/gegl/gegl-serialize.c
index 1d1c38c..f6fa076 100644
--- a/gegl/gegl-serialize.c
+++ b/gegl/gegl-serialize.c
@@ -88,18 +88,7 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
}
else
{
- if (!strcmp (*arg, "l"))
- {
- fprintf (stderr, "linear\n");
- }
- else if (!strcmp (*arg, "s"))
- {
- fprintf (stderr, "step\n");
- }
- else if (!strcmp (*arg, "c"))
- {
- fprintf (stderr, "cubic\n");
- }
+ fprintf (stderr, "unhandled path data\n");
}
g_free (key);
@@ -134,7 +123,7 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
in_strkeyframes = 0;
};
}
- else if (strchr (*arg, ']'))
+ else if (!strchr(*arg, '=') && strchr (*arg, ']'))
{
level--;
gegl_node_connect_to (iter[level+1], "output", iter[level], level_pad[level]);
@@ -149,7 +138,14 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
GValue gvalue={0,};
char *key = g_strdup (*arg);
char *value = strchr (key, '=') + 1;
+ int end_block = 0;
value[-1] = '\0';
+ if (strchr (value, ']') &&
+ strrchr (value, ']')[1] == '\0')
+ {
+ end_block = 1;
+ * strchr (value, ']') = 0;
+ }
if (!strcmp (key, "id"))
{
@@ -215,10 +211,47 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
level_pad[level]=(void*)g_intern_string(pad);
g_free (pad);
level++;
-
iter[level]=NULL;
level_op[level]=NULL;
level_pad[level]=NULL;
+
+ if (strlen (&match[2]))
+ {
+ if (strchr (&match[2], ':')) /* contains : is a non-prefixed operation */
+ {
+ level_op[level] = (void*)g_intern_string(&match[2]);
+ }
+ else /* default to gegl: as prefix if no : specified */
+ {
+ char temp[1024];
+ g_snprintf (temp, 1023, "gegl:%s", &match[2]);
+ level_op[level] = (void*)g_intern_string (temp);
+ }
+
+ if (gegl_has_operation (level_op[level]))
+ {
+ new = gegl_node_new_child (gegl_node_get_parent (proxy), "operation",
+ level_op[level], NULL);
+
+ if (iter[level])
+ gegl_node_link_many (iter[level], new, proxy, NULL);
+ else
+ gegl_node_link_many (new, proxy, NULL);
+ iter[level] = new;
+ }
+ else if (error)
+ {
+ GString *str = g_string_new ("");
+ g_string_append_printf (str, "No such op '%s'", level_op[level]);
+ *error = g_error_new_literal (g_quark_from_static_string ("gegl"),
+ 0, str->str);
+ g_string_free (str, TRUE);
+ }
+
+
+ }
+ /* XXX: ... */
+
}
else
if (target_type == 0)
@@ -337,6 +370,11 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
}
}
g_free (key);
+ if (end_block)
+ {
+ level--;
+ gegl_node_connect_to (iter[level+1], "output", iter[level], level_pad[level]);
+ }
}
}
else
diff --git a/tests/simple/test-serialize.c b/tests/simple/test-serialize.c
index b02e788..6fdcd9f 100644
--- a/tests/simple/test-serialize.c
+++ b/tests/simple/test-serialize.c
@@ -25,28 +25,24 @@
#define FAILURE -1
typedef struct TestCase {
- gchar *argv_chain;
- gchar *expected_serialization;
- gchar *expected_error;
+ gchar *argv_chain; gchar *expected_serialization; gchar *expected_error;
} TestCase;
TestCase tests[] = {
- {"invert", " gegl:invert-linear", ""},
- {"invert a=b", " gegl:invert-linear", "gegl:invert has no a property, but has "},
- {"invert a=c", " gegl:invert-linear", "gegl:invert has no a property, but has "},
- {"gaussian-blur", " gegl:gaussian-blur", ""},
- {"over aux=[ text string='foo bar' ]", " svg:src-over aux=[ gegl:text string='foo bar' width=35
height=11 ]", ""},
-
+ {"invert", " gegl:invert-linear", ""},
+ {"invert a=b", " gegl:invert-linear", "gegl:invert has no a property, but has "},
+ {"invert a=c", " gegl:invert-linear", "gegl:invert has no a property, but has "},
+ {"gaussian-blur", " gegl:gaussian-blur", ""},
+ {"over aux=[ text string='foo bar' ]", " svg:src-over aux=[ gegl:text string='foo bar' width=35
height=11 ]", ""},
+ {"over aux=[text string='foo bar' ]", " svg:src-over aux=[ gegl:text string='foo bar' width=35
height=11 ]", ""},
+ {"over aux=[ text string={ 0='foo bar' } ]", " svg:src-over aux=[ gegl:text string='foo bar' width=35
height=11 ]", ""},
{"over aux= [ ", " svg:src-over", "No such op 'gegl:['"},
-
/* the following cause undesired warnings on console */
- {"over aux=[ string='foo bar' ]", " svg:src-over", ""},
-
+ {"over aux=[ string='foo bar' ]", " svg:src-over", ""},
/* the following should have error message */
- {"over aux=[ ", " svg:src-over", ""},
- {"over aux=[ ]", " svg:src-over", ""},
-
- {"exposure foo=2", " gegl:exposure", "gegl:exposure has no foo property, but has 'exposure', 'offset',
'gamma', "},
+ {"over aux=[ ", " svg:src-over", ""},
+ {"over aux=[ ]", " svg:src-over", ""},
+ {"exposure foo=2"," gegl:exposure", "gegl:exposure has no foo property, but has 'exposure',
'offset', 'gamma', "},
#if 0
{"id=foo over aux=[ ref=foo invert ]", " id=001 svg:src-over aux=[ ref=001 gegl:invert-linear ]", ""},
@@ -54,6 +50,7 @@ TestCase tests[] = {
{"id=foo over aux=[ ref=foo invert ]", " svg:src-over aux=[ gegl:nop gegl:invert-linear ]", ""},
#endif
+ {"over aux=[text string='foo bar']", " svg:src-over aux=[ gegl:text string='foo bar' width=35
height=11 ]", ""},
/* the following causes crashes */
#if 0
{"over aux=[]", " svg:src-over", "No such op 'gegl:['"}, /* should report error message */
@@ -65,7 +62,6 @@ static int
test_serialize (void)
{
gint result = SUCCESS;
- gint res = SUCCESS;
GeglNode *node = gegl_node_new ();
GeglNode *start = gegl_node_new_child (node, "operation", "gegl:nop", NULL);
GeglNode *end = gegl_node_new_child (node, "operation", "gegl:nop", NULL);
@@ -76,6 +72,7 @@ test_serialize (void)
for (i = 0; tests[i].argv_chain; i++)
{
GError *error = NULL;
+ gint res = SUCCESS;
gchar *serialization = NULL;
gegl_create_chain (tests[i].argv_chain, start, end,
0.0, 500, &error);
@@ -111,7 +108,7 @@ test_serialize (void)
if (res == FAILURE)
{
result = FAILURE;
- printf ("failed: %s\n", tests[i].argv_chain);
+ printf ("FAILED: %s\n", tests[i].argv_chain);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]