Commit 637d152e authored by Christian Hergert's avatar Christian Hergert

wip: templates

parent b719bbf5
SUBDIRS = . build contrib data libide src plugins tools po tests doc
pkgconfigdir = $(libdir)/gnome-builder/pkgconfig
pkgconfig_DATA = $(top_builddir)/data/libide-1.0.pc
INTLTOOL_FILES = \
intltool-extract.in \
intltool-merge.in \
......@@ -75,7 +72,7 @@ run:
GB_IN_TREE_PLUGINS=1 \
GB_IN_TREE_FONTS=1 \
GB_IN_TREE_STYLE_SCHEMES=1 \
GI_TYPELIB_PATH="libide:$(GI_TYPELIB_PATH)" \
GI_TYPELIB_PATH="libide:contrib/tmpl:$(GI_TYPELIB_PATH)" \
GOBJECT_DEBUG=instance-count \
PATH=$(top_builddir)/src:${PATH} \
$(LIBTOOL) --mode=execute gdb -ex run --args src/gnome-builder -vvvv -s
......@@ -85,7 +82,7 @@ strace:
GB_IN_TREE_PLUGINS=1 \
GB_IN_TREE_FONTS=1 \
GB_IN_TREE_STYLE_SCHEMES=1 \
GI_TYPELIB_PATH="libide:$(GI_TYPELIB_PATH)" \
GI_TYPELIB_PATH="libide:contrib/tmpl:$(GI_TYPELIB_PATH)" \
GOBJECT_DEBUG=instance-count \
PATH=$(top_builddir)/src:${PATH} \
$(LIBTOOL) --mode=execute strace -T src/gnome-builder -vvvv -s
......@@ -95,7 +92,7 @@ debug:
GB_IN_TREE_PLUGINS=1 \
GB_IN_TREE_FONTS=1 \
GB_IN_TREE_STYLE_SCHEMES=1 \
GI_TYPELIB_PATH="libide:$(GI_TYPELIB_PATH)" \
GI_TYPELIB_PATH="libide:contrib/tmpl:$(GI_TYPELIB_PATH)" \
G_DEBUG=fatal-criticals \
GOBJECT_DEBUG=instance-count \
PATH=$(top_builddir)/src:${PATH} \
......@@ -106,7 +103,7 @@ valgrind:
GB_IN_TREE_PLUGINS=1 \
GB_IN_TREE_FONTS=1 \
GB_IN_TREE_STYLE_SCHEMES=1 \
GI_TYPELIB_PATH="libide:$(GI_TYPELIB_PATH)" \
GI_TYPELIB_PATH="libide:contrib/tmpl:$(GI_TYPELIB_PATH)" \
G_DEBUG=fatal-criticals \
G_SLICE=always-malloc \
PATH=$(top_builddir)/src:${PATH} \
......
......@@ -66,6 +66,8 @@ AM_PROG_CC_C_O
AC_PROG_CXX
AM_PROG_VALAC
AC_PROG_INSTALL
AM_PROG_LEX
AC_PROG_YACC
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
AC_PATH_PROG([GLIB_COMPILE_RESOURCES], [glib-compile-resources])
......@@ -168,6 +170,7 @@ m4_define([gtk_required_version], [3.19.7])
m4_define([glib_required_version], [2.47.4])
m4_define([gtksourceview_required_version], [3.19.4])
m4_define([ggit_required_version], [0.23.7])
m4_define([gobject_introspection_version], [1.47.1])
m4_define([pygobject_required_version], [3.19.3])
m4_define([libxml_required_version], [2.9.0])
m4_define([pangoft2_required_version], [1.38.0])
......@@ -196,6 +199,8 @@ PKG_CHECK_MODULES(PYGOBJECT,[pygobject-3.0 >= pygobject_required_version],
[have_pygobject=no])
PKG_CHECK_MODULES(RG, [gtk+-3.0 >= gtk_required_version])
PKG_CHECK_MODULES(SEARCH, [glib-2.0 >= glib_required_version])
PKG_CHECK_MODULES(TMPL, [gio-2.0 >= glib_required_version
gobject-introspection-1.0 >= gobject_introspection_version])
PKG_CHECK_MODULES(XML, [gio-2.0 >= glib_required_version
libxml-2.0 >= libxml_required_version])
......@@ -243,6 +248,7 @@ m4_include([plugins/c-pack/configure.ac])
m4_include([plugins/clang/configure.ac])
m4_include([plugins/command-bar/configure.ac])
m4_include([plugins/contributing/configure.ac])
m4_include([plugins/create-project/configure.ac])
m4_include([plugins/ctags/configure.ac])
m4_include([plugins/devhelp/configure.ac])
m4_include([plugins/file-search/configure.ac])
......@@ -253,6 +259,7 @@ m4_include([plugins/gnome-code-assistance/configure.ac])
m4_include([plugins/html-completion/configure.ac])
m4_include([plugins/html-preview/configure.ac])
m4_include([plugins/jedi/configure.ac])
m4_include([plugins/library-template/configure.ac])
m4_include([plugins/mingw/configure.ac])
m4_include([plugins/project-tree/configure.ac])
m4_include([plugins/python-gi-imports-completion/configure.ac])
......@@ -435,6 +442,8 @@ AC_CONFIG_FILES([
contrib/nautilus/Makefile
contrib/rg/Makefile
contrib/search/Makefile
contrib/tmpl/Makefile
contrib/tmpl/tmpl-debug.h
contrib/xml/Makefile
libide/ide-debug.h
......@@ -450,6 +459,7 @@ AC_CONFIG_FILES([
data/icons/hicolor/Makefile
data/libide-1.0.pc
data/style-schemes/Makefile
data/template-glib-1.0.pc
doc/Makefile
doc/examples/Makefile
......@@ -511,6 +521,7 @@ echo " GNOME Code Assistance ................ : ${enable_gnome_code_assistance_
echo " HTML Autocompletion .................. : ${enable_html_completion_plugin}"
echo " HTML and Markdown Preview ............ : ${enable_html_preview_plugin}"
echo " MinGW ................................ : ${enable_mingw_plugin}"
echo " Project Creation ..................... : ${enable_create_project_plugin}"
echo " Project Tree ......................... : ${enable_project_tree_plugin}"
echo " Python GObject Introspection ......... : ${enable_python_gi_imports_completion_plugin}"
echo " Python Jedi Autocompletion ........... : ${enable_jedi_plugin}"
......@@ -523,4 +534,8 @@ echo " Terminal ............................. : ${enable_terminal_plugin}"
echo " Vala Language Pack ................... : ${enable_vala_pack_plugin}"
echo " XML Language Pack .................... : ${enable_xml_pack_plugin}"
echo ""
echo " Templates"
echo ""
echo " Library .............................. : ${enable_library_template_plugin}"
echo ""
......@@ -6,6 +6,7 @@ SUBDIRS = \
nautilus \
rg \
search \
tmpl \
xml \
$(NULL)
......
DISTCLEANFILES =
CLEANFILES =
BUILT_SOURCES =
pkglib_LTLIBRARIES = libtemplate-glib-1.0.la
AM_CPPFLAGS = \
-D_GNU_SOURCE \
-DTMPL_GLIB_COMPILATION
EXTRA_DIST = \
tmpl-expr-parser.c \
tmpl-expr-parser.h \
tmpl-expr-scanner.c \
tmpl-expr-scanner.h
pkgincludedir = $(includedir)/template-glib-1.0
pkginclude_HEADERS = \
tmpl-error.h \
tmpl-expr-types.h \
tmpl-expr.h \
tmpl-glib.h \
tmpl-scope.h \
tmpl-symbol.h \
tmpl-template-locator.h \
tmpl-template.h \
$(NULL)
libtemplate_glib_1_0_la_CFLAGS = $(TMPL_CFLAGS)
libtemplate_glib_1_0_la_LIBADD = $(TMPL_LIBS)
libtemplate_glib_1_0_la_SOURCES = \
$(pkginclude_HEADERS) \
tmpl-branch-node.c \
tmpl-branch-node.h \
tmpl-condition-node.c \
tmpl-condition-node.h \
tmpl-debug.h \
tmpl-enums.c \
tmpl-enums.h \
tmpl-error.c \
tmpl-expr-eval.c \
tmpl-expr-node.c \
tmpl-expr-node.h \
tmpl-expr-parser-private.h \
tmpl-expr-parser.y \
tmpl-expr-private.h \
tmpl-expr-scanner.l \
tmpl-expr.c \
tmpl-gi-private.h \
tmpl-gi.c \
tmpl-iter-node.c \
tmpl-iter-node.h \
tmpl-iterator.c \
tmpl-iterator.h \
tmpl-lexer.c \
tmpl-lexer.h \
tmpl-node.c \
tmpl-node.h \
tmpl-parser.c \
tmpl-parser.h \
tmpl-scope.c \
tmpl-symbol.c \
tmpl-template-locator.c \
tmpl-template.c \
tmpl-text-node.c \
tmpl-text-node.h \
tmpl-token-input-stream.c \
tmpl-token-input-stream.h \
tmpl-token.c \
tmpl-token.h \
tmpl-util-private.h \
tmpl-util.c \
$(NULL)
glib_enum_h = tmpl-enums.h
glib_enum_c = tmpl-enums.c
glib_enum_headers = \
tmpl-error.h \
tmpl-expr-types.h \
$(NULL)
include $(top_srcdir)/build/autotools/Makefile.am.enums
if HAVE_INTROSPECTION
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
introspection_sources = \
tmpl-enums.c \
tmpl-enums.h \
tmpl-error.h \
tmpl-expr.c \
tmpl-expr.h \
tmpl-expr-types.h \
tmpl-scope.c \
tmpl-scope.h \
tmpl-symbol.c \
tmpl-symbol.h \
tmpl-template-locator.c \
tmpl-template-locator.h \
tmpl-template.c \
tmpl-template.h \
$(NULL)
Template-1.0.gir: libtemplate-glib-1.0.la
Template_1_0_gir_INCLUDES = Gio-2.0
Template_1_0_gir_CFLAGS = $(libtemplate_glib_1_0_la_CFLAGS)
Template_1_0_gir_LIBS = libtemplate-glib-1.0.la
Template_1_0_gir_FILES = $(introspection_sources)
Template_1_0_gir_SCANNERFLAGS = \
-n Template \
--identifier-prefix Tmpl \
--symbol-prefix tmpl \
-DTMPL_GLIB_COMPILATION \
$(NULL)
INTROSPECTION_GIRS += Template-1.0.gir
pkggirdir = $(datadir)/gnome-builder/gir-1.0
pkggir_DATA = $(INTROSPECTION_GIRS)
pkgtypelibdir = $(libdir)/gnome-builder/girepository-1.0
pkgtypelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
CLEANFILES += $(gir_DATA) $(typelib_DATA)
endif
if ENABLE_VAPIGEN
-include $(VAPIGEN_MAKEFILE)
template-glib-1.0.vapi: Template-1.0.gir Template-1.0.metadata
VAPIGEN_VAPIS = template-glib-1.0.vapi
template_glib_1_0_vapi_DEPS = gio-2.0
template_glib_1_0_vapi_METADATADIRS = $(srcdir)
template_glib_1_0_vapi_FILES = Template-1.0.gir
template-glib-1.0.deps: Makefile
$(AM_V_GEN) echo $(template_glib_1_0_vapi_DEPS) | tr ' ' '\n' > $@
vapidir = $(datadir)/gnome-builder/vapi
vapi_DATA = $(VAPIGEN_VAPIS) $(VAPIGEN_VAPIS:.vapi=.deps)
EXTRA_DIST += template-glib-1.0.deps
DISTCLEANFILES += $(vapi_DATA)
endif
GITIGNOREFILES = \
tmpl-expr-parser.c \
tmpl-expr-parser.h \
tmpl-expr-scanner.c \
tmpl-expr-scanner.h \
tmpl-debug.h \
*.typelib \
*.gir \
lex.*
-include $(top_srcdir)/git.mk
Template name="Template"
* cheader_filename="tmpl-glib.h"
AC_PREREQ([{{autoconf_required_version}}])
dnl ***********************************************************************
dnl Define Versioning Information
dnl ***********************************************************************
m4_define([major_version],[{{version_major}}])
m4_define([minor_version],[{{version_minor}}])
m4_define([micro_version],[{{version_micro}}])
m4_define([version],[major_version.minor_version.micro_version])
m4_define([interface_age],[0])
m4_define([bugreport_url],[{{bugreport_url}}])
m4_define([debug_default],[m4_if(m4_eval(minor_version % 2),[1],[yes],[minimum])])
dnl ***********************************************************************
dnl Initialize Autoconf
dnl ***********************************************************************
AC_INIT([{{name}}],[version],[bugreport_url])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_MACRO_DIR([build-aux])
AC_CONFIG_AUX_DIR([build-aux])
AC_SUBST(ACLOCAL_AMFLAGS, "-I build-aux")
AC_CANONICAL_HOST
dnl ***********************************************************************
dnl Export version information
dnl ***********************************************************************
MAJOR_VERSION=major_version
MINOR_VERSION=minor_version
MICRO_VERSION=micro_version
AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)
AC_SUBST(MICRO_VERSION)
dnl ***********************************************************************
dnl Initialize Automake
dnl ***********************************************************************
AM_SILENT_RULES([yes])
AM_INIT_AUTOMAKE([1.11 foreign subdir-objects tar-ustar no-dist-gzip dist-xz])
AM_MAINTAINER_MODE([enable])
dnl ***********************************************************************
dnl Internationalization
dnl ***********************************************************************
IT_PROG_INTLTOOL([0.50.1])
GETTEXT_PACKAGE=AC_PACKAGE_TARNAME
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"], [GETTEXT package name])
AM_GLIB_GNU_GETTEXT
dnl ***********************************************************************
dnl Check for Required Programs
dnl ***********************************************************************
AC_PROG_CC
{{if enable_cplusplus}}
AC_PROG_CXX
{{end}}
AC_PROG_INSTALL
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
AC_PATH_PROG([GLIB_COMPILE_RESOURCES], [glib-compile-resources])
GLIB_GSETTINGS
PKG_PROG_PKG_CONFIG([0.22])
{{if enable_gobject_introspection}}
GOBJECT_INTROSPECTION_CHECK([1.42.0])
{{end}}
{{if enable_vala}}
AM_PROG_VALAC
VAPIGEN_CHECK
{{end}}
{{if enable_appstream}}
APPSTREAM_XML
{{end}}
{{if enable_c11}}
dnl ***********************************************************************
dnl Ensure C11 is Supported
dnl ***********************************************************************
AX_CHECK_COMPILE_FLAG([-std=gnu11],
[CFLAGS="$CFLAGS -std=gnu11"],
[AC_MSG_ERROR([C compiler cannot compile GNU C11 code])])
{{end}}
dnl ***********************************************************************
dnl Setup Debug and Tracing Support
dnl ***********************************************************************
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug=@<:@no/minimum/yes@:>@],
[turn on debugging @<:@default=debug_default@:>@]),
,
enable_debug=debug_default)
AS_CASE(["$enable_debug"],
[yes],[
DEBUG_CFLAGS="$DEBUG_CFLAGS -O0"
DEBUG_CFLAGS="$DEBUG_CFLAGS -g"
],
[minimum],[
DEBUG_CFLAGS="$DEBUG_CFLAGS -DG_DISABLE_CAST_CHECKS"
],
[no],[
DEBUG_CFLAGS="$DEBUG_CFLAGS -DG_DISABLE_ASSERT"
DEBUG_CFLAGS="$DEBUG_CFLAGS -DG_DISABLE_CHECKS"
DEBUG_CFLAGS="$DEBUG_CFLAGS -DG_DISABLE_CAST_CHECKS"
],
[])
AC_SUBST(DEBUG_CFLAGS)
dnl ***********************************************************************
dnl Check for Required Packages
dnl ***********************************************************************
m4_define([glib_required_version],[{{glib_required_version}}])
PKG_CHECK_MODULES({{NAME}}, [
gobject-2.0 >= glib_required_version
gio-2.0 >= glib_required_version
])
dnl ***********************************************************************
dnl Initialize Libtool
dnl ***********************************************************************
LT_PREREQ([2.2])
LT_INIT
{{if enable_compiler_flags}}
dnl ***********************************************************************
dnl Additional C Compiler Flags
dnl ***********************************************************************
AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option], [
ax_compiler_flags_test="-Werror=unknown-warning-option"
], [
ax_compiler_flags_test=""
])
AX_APPEND_COMPILE_FLAGS([ \
-Wall \
-Wcast-align \
-Wdeclaration-after-statement \
-Wempty-body \
-Werror=format-security \
-Werror=format=2 \
-Wextra \
-Wformat \
-Wformat-nonliteral \
-Wformat-security \
-Winit-self \
-Wmisleading-indentation \
-Wmissing-include-dirs \
-Wshift-negative-value \
-Wnested-externs \
-Wno-missing-field-initializers \
-Wno-sign-compare \
-Wno-strict-aliasing \
-Wno-uninitialized \
-Wno-unused-parameter \
-Wpointer-arith \
-Wredundant-decls \
-Wreturn-type \
-Wshadow \
-Wswitch-default \
-Wswitch-enum \
-Wundef \
-Wuninitialized \
], [], [$ax_compiler_flags_test])
AC_C_CONST
{{end}}
{{if enable_gtk_doc}}
dnl ***********************************************************************
dnl Support for gtk-doc Documentation Engine
dnl ***********************************************************************
GTK_DOC_CHECK([1.11],[--flavour no-tmpl])
AM_CONDITIONAL(ENABLE_GTK_DOC, test "x$enable_gtk_doc" = "xyes")
AC_ARG_ENABLE(doc-cross-references,
AS_HELP_STRING([--disable-doc-cross-references],
[cross reference symbols from other libraries @<:@default=yes@:>@]),
enable_doc_cross_references=$enableval,
enable_doc_cross_references=yes)
AM_CONDITIONAL(ENABLE_DOC_CROSS_REFERENCES, test x$enable_doc_cross_references != xno)
{{end}}
dnl ***********************************************************************
dnl Process .in Files
dnl ***********************************************************************
AC_CONFIG_FILES([
Makefile
])
AC_OUTPUT
echo ""
echo " ${PACKAGE} - ${VERSION}"
echo ""
/* tmpl-branch-node.c
*
* Copyright (C) 2016 Christian Hergert <chergert@redhat.com>
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define G_LOG_DOMAIN "tmpl-branch-node"
#include "tmpl-branch-node.h"
#include "tmpl-condition-node.h"
#include "tmpl-debug.h"
#include "tmpl-error.h"
#include "tmpl-util-private.h"
struct _TmplBranchNode
{
TmplNode parent_instance;
TmplNode *if_branch;
GPtrArray *children;
};
G_DEFINE_TYPE (TmplBranchNode, tmpl_branch_node, TMPL_TYPE_NODE)
static gboolean
tmpl_branch_node_accept (TmplNode *node,
TmplLexer *lexer,
GCancellable *cancellable,
GError **error)
{
TmplBranchNode *self = (TmplBranchNode *)node;
TMPL_ENTRY;
g_assert (TMPL_IS_BRANCH_NODE (self));
g_assert (self->if_branch != NULL);
g_assert (lexer != NULL);
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
if (!tmpl_node_accept (self->if_branch, lexer, cancellable, error))
TMPL_RETURN (FALSE);
/*
* At this point, the if branch should have everything, so we are
* looking for ELSE_IF, ELSE, or END. Everything else is a syntax
* error.
*/
while (TRUE)
{
TmplToken *token = NULL;
if (!tmpl_lexer_next (lexer, &token, cancellable, error))
TMPL_RETURN (FALSE);
switch (tmpl_token_type (token))
{
case TMPL_TOKEN_EOF:
g_set_error (error,
TMPL_ERROR,
TMPL_ERROR_SYNTAX_ERROR,
"Unexpected end-of-file reached");
TMPL_RETURN (FALSE);
case TMPL_TOKEN_END:
tmpl_token_free (token);
TMPL_RETURN (TRUE);
case TMPL_TOKEN_ELSE:
case TMPL_TOKEN_ELSE_IF:
{
TmplNode *child;
TmplExpr *expr = NULL;
if (tmpl_token_type (token) != TMPL_TOKEN_ELSE)
{
const gchar *exprstr;
exprstr = tmpl_token_get_text (token);
expr = tmpl_expr_from_string (exprstr, error);
}
else
expr = tmpl_expr_new_boolean (TRUE);
tmpl_token_free (token);
if (expr == NULL)
TMPL_RETURN (FALSE);
child = tmpl_condition_node_new (expr);
if (self->children == NULL)
self->children = g_ptr_array_new_with_free_func (g_object_unref);
g_ptr_array_add (self->children, child);
if (!tmpl_node_accept (child, lexer, cancellable, error))
TMPL_RETURN (FALSE);
}
break;
case TMPL_TOKEN_TEXT:
case TMPL_TOKEN_IF:
case TMPL_TOKEN_EXPRESSION:
case TMPL_TOKEN_FOR:
case TMPL_TOKEN_INCLUDE:
default:
tmpl_token_free (token);
g_set_error (error,
TMPL_ERROR,
TMPL_ERROR_SYNTAX_ERROR,
"Invalid token, expected else if, else, or end.");
TMPL_RETURN (FALSE);
}
}
}
static void
tmpl_branch_node_visit_children (TmplNode *node,
TmplNodeVisitor visitor,
gpointer user_data)
{
TmplBranchNode *self = (TmplBranchNode *)node;
g_assert (TMPL_IS_NODE (node));
g_assert (visitor != NULL);
if (self->if_branch)
visitor (self->if_branch, user_data);
if (self->children != NULL)
{
gint i;
for (i = 0; i < self->children->len; i++)
{
TmplNode *child = g_ptr_array_index (self->children, i);
visitor (child, user_data);
}
}
}
static void
tmpl_branch_node_finalize (GObject *object)
{
TmplBranchNode *self = (TmplBranchNode *)object;
g_clear_pointer (&self->children, g_ptr_array_unref);
g_clear_object (&self->if_branch);
G_OBJECT_CLASS (tmpl_branch_node_parent_class)->finalize (object);
}
static void
tmpl_branch_node_class_init (TmplBranchNodeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
TmplNodeClass *node_class = TMPL_NODE_CLASS (klass);
object_class->finalize = tmpl_branch_node_finalize;
node_class->accept = tmpl_branch_node_accept;
node_class->visit_children = tmpl_branch_node_visit_children;
}
static void
tmpl_branch_node_init (TmplBranchNode *self)
{
}
/**
* tmpl_branch_node_new:
* @expr: (transfer full): A TmplExpr
*
* Creates a new branch (if, else if, else) using @expr for the (if)
* branch.
*
* Returns: (transfer full): A #TmplBranchNode.
*/
TmplNode *
tmpl_branch_node_new (TmplExpr *condition)
{
TmplBranchNode *self;
self = g_object_new (TMPL_TYPE_BRANCH_NODE, NULL);
self->if_branch = tmpl_condition_node_new (condition);
return TMPL_NODE (self);
}
static gboolean
condition_matches (TmplNode *condition,
TmplScope *scope,
GError **error)
{
TmplExpr *expr;
GValue value = G_VALUE_INIT;
gboolean ret;
g_assert (TMPL_IS_CONDITION_NODE (condition));
if (!(expr = tmpl_condition_node_get_condition (TMPL_CONDITION_NODE (condition))))
return FALSE;
if (!tmpl_expr_eval (expr, scope, &value, error))
return FALSE;
ret = tmpl_value_as_boolean (&value);
TMPL_CLEAR_VALUE (&value);
return ret;
}