[gtk+/wip/otte/shader: 25/150] gskslfunction: Change name printing to name getting
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/shader: 25/150] gskslfunction: Change name printing to name getting
- Date: Sat, 21 Oct 2017 02:28:16 +0000 (UTC)
commit f32f85274274cbde08ca8c528b14ee4f7019cb98
Author: Benjamin Otte <otte redhat com>
Date: Sun Sep 24 23:17:18 2017 +0200
gskslfunction: Change name printing to name getting
Since gsk_sl_type_get_name() exists now, we can have a name getter also
for builtin constructors.
gsk/gskslexpression.c | 2 +-
gsk/gskslfunction.c | 25 +++++++++++--------------
gsk/gskslfunctionprivate.h | 6 ++----
gsk/gskslprogram.c | 4 +---
4 files changed, 15 insertions(+), 22 deletions(-)
---
diff --git a/gsk/gskslexpression.c b/gsk/gskslexpression.c
index aafd3e3..d5a2421 100644
--- a/gsk/gskslexpression.c
+++ b/gsk/gskslexpression.c
@@ -728,7 +728,7 @@ gsk_sl_expression_function_call_print (const GskSlExpression *expression,
const GskSlExpressionFunctionCall *function_call = (const GskSlExpressionFunctionCall *) expression;
guint i;
- gsk_sl_function_print_name (function_call->function, string);
+ g_string_append (string, gsk_sl_function_get_name (function_call->function));
g_string_append (string, " (");
for (i = 0; i < function_call->n_arguments; i++)
diff --git a/gsk/gskslfunction.c b/gsk/gskslfunction.c
index c9e2ac5..61415f4 100644
--- a/gsk/gskslfunction.c
+++ b/gsk/gskslfunction.c
@@ -70,13 +70,12 @@ gsk_sl_function_constructor_get_return_type (const GskSlFunction *function)
return constructor->type;
}
-static void
-gsk_sl_function_constructor_print_name (const GskSlFunction *function,
- GString *string)
+static const char *
+gsk_sl_function_constructor_get_name (const GskSlFunction *function)
{
const GskSlFunctionConstructor *constructor = (const GskSlFunctionConstructor *) function;
- g_string_append (string, gsk_sl_type_get_name (constructor->type));
+ return gsk_sl_type_get_name (constructor->type);
}
static void
@@ -147,7 +146,7 @@ gsk_sl_function_constructor_write_spv (const GskSlFunction *function,
static const GskSlFunctionClass GSK_SL_FUNCTION_CONSTRUCTOR = {
gsk_sl_function_constructor_free,
gsk_sl_function_constructor_get_return_type,
- gsk_sl_function_constructor_print_name,
+ gsk_sl_function_constructor_get_name,
gsk_sl_function_constructor_print,
gsk_sl_function_constructor_matches,
gsk_sl_function_constructor_write_spv,
@@ -189,13 +188,12 @@ gsk_sl_function_declared_get_return_type (const GskSlFunction *function)
return declared->return_type;
}
-static void
-gsk_sl_function_declared_print_name (const GskSlFunction *function,
- GString *string)
+static const char *
+gsk_sl_function_declared_get_name (const GskSlFunction *function)
{
const GskSlFunctionDeclared *declared = (const GskSlFunctionDeclared *) function;
- g_string_append (string, declared->name);
+ return declared->name;
}
static void
@@ -288,7 +286,7 @@ gsk_sl_function_declared_write_spv (const GskSlFunction *function,
static const GskSlFunctionClass GSK_SL_FUNCTION_DECLARED = {
gsk_sl_function_declared_free,
gsk_sl_function_declared_get_return_type,
- gsk_sl_function_declared_print_name,
+ gsk_sl_function_declared_get_name,
gsk_sl_function_declared_print,
gsk_sl_function_declared_matches,
gsk_sl_function_declared_write_spv,
@@ -416,11 +414,10 @@ gsk_sl_function_get_return_type (const GskSlFunction *function)
return function->class->get_return_type (function);
}
-void
-gsk_sl_function_print_name (const GskSlFunction *function,
- GString *string)
+const char *
+gsk_sl_function_get_name (const GskSlFunction *function)
{
- function->class->print_name (function, string);
+ return function->class->get_name (function);
}
void
diff --git a/gsk/gskslfunctionprivate.h b/gsk/gskslfunctionprivate.h
index 99967cb..9e28374 100644
--- a/gsk/gskslfunctionprivate.h
+++ b/gsk/gskslfunctionprivate.h
@@ -38,8 +38,7 @@ struct _GskSlFunctionClass {
void (* free) (GskSlFunction *function);
GskSlType * (* get_return_type) (const GskSlFunction *function);
- void (* print_name) (const GskSlFunction *function,
- GString *string);
+ const char * (* get_name) (const GskSlFunction *function);
void (* print) (const GskSlFunction *function,
GString *string);
gboolean (* matches) (const GskSlFunction *function,
@@ -62,8 +61,7 @@ void gsk_sl_function_unref (GskSlFunction
void gsk_sl_function_print (const GskSlFunction *function,
GString *string);
-void gsk_sl_function_print_name (const GskSlFunction *function,
- GString *string);
+const char * gsk_sl_function_get_name (const GskSlFunction *function);
GskSlType * gsk_sl_function_get_return_type (const GskSlFunction *function);
gboolean gsk_sl_function_matches (const GskSlFunction *function,
GskSlType **arguments,
diff --git a/gsk/gskslprogram.c b/gsk/gskslprogram.c
index 8a1d6de..4f721ef 100644
--- a/gsk/gskslprogram.c
+++ b/gsk/gskslprogram.c
@@ -151,15 +151,13 @@ gsk_sl_program_write_spv (GskSlProgram *program,
for (l = program->declarations; l; l = l->next)
gsk_sl_node_write_spv (l->data, writer);
-#if 0
for (l = program->functions; l; l = l->next)
{
guint32 id = gsk_sl_function_write_spv (l->data, writer);
- if (g_str_equal (((GskSlNodeFunction *) l->data)->name, "main"))
+ if (g_str_equal (gsk_sl_function_get_name (l->data), "main"))
gsk_spv_writer_set_entry_point (writer, id);
}
-#endif
}
GBytes *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]