Commit 0b492099 authored by Vivien Kraus's avatar Vivien Kraus

Merge branch '18-add-gobject-binding' into 'develop'

Resolve "Add GObject binding"

Closes #18

See merge request gugurumbe/tarot!16
parents 4610f714 2e0213ca
Pipeline #96743 passed with stages
in 3 minutes and 45 seconds
......@@ -56,7 +56,7 @@ dist_largeicons_DATA =
dist_mediumicons_DATA =
dist_smallicons_DATA =
applicationsdir = $(datadir)/applications
applications_DATA = %reldir%/tarot.desktop
applications_DATA = %reldir%/eu.planete_kraus.Tarot.desktop
INDENTED =
TANGLED =
SUFFIXES =
......@@ -67,6 +67,7 @@ dist_noinst_SCRIPTS = \
nodist_noinst_DATA =
VALGRIND_SUPPRESSION_FILE = \
valgrind.supp
ENUM_HEADER_FILES =
ACLOCAL_AMFLAGS = -I m4 -I lib-library/m4 -I lib-program/m4
EXTRA_DIST = \
......@@ -83,7 +84,9 @@ BUILT_SOURCES = \
$(top_srcdir)/.version
CLEANFILES =
AM_DISTCHECK_CONFIGURE_FLAGS = \
--enable-silent-rules=yes
--enable-silent-rules=yes \
--disable-introspection \
--disable-vapigen
AM_CPPFLAGS = \
-DLOCALEDIR="\"$(localedir)\"" \
-DSYSCONFDIR="\"$(sysconfdir)\"" \
......@@ -109,7 +112,8 @@ AM_TESTS_ENVIRONMENT += \
$(VALGRIND) --tool=memcheck \
--leak-check=full \
--error-exitcode=42 \
--suppressions=$(srcdir)/$(VALGRIND_SUPPRESSION_FILE)
--suppressions=$(srcdir)/$(VALGRIND_SUPPRESSION_FILE) \
--gen-suppressions=all
endif # HAVE_VALGRIND
TEST_EXTENSIONS = .tarot
......
......@@ -22,7 +22,8 @@ sh autogen.sh || exit 1
|| exit 1
make indent || exit 1
(cd lib-library && make -j 16) || exit 1
## Non parallel
(cd lib-program && make -j 16) || exit 1
# I don't know exactly which targets are not thread safe...
make dist || exit 1
make -j 16 distcheck \
|| (cat "$SOURCE_TOP/tarot-$(cat .version)/_build/sub/test-suite.log" ; exit 1) \
......
......@@ -38,6 +38,10 @@ AC_PROG_YACC
AM_MISSING_PROG([XSLTPROC], [xsltproc])
AM_MISSING_PROG([XMLLINT], [xmllint])
AM_MISSING_PROG([CONVERT], [convert])
GOBJECT_INTROSPECTION_CHECK([1.30.0])
PKG_CHECK_VAR([GLIB_MKENUMS], [glib-2.0], [glib_mkenums])
AM_PROG_VALAC
VAPIGEN_CHECK
# Checks for libraries.
gl_lib_INIT
......@@ -50,6 +54,16 @@ AC_SEARCH_LIBS([add_history], [history], [
AX_LIB_NETTLE([yes])
PKG_CHECK_MODULES([XML], [libxml-2.0])
LIBOPTS_CHECK
AC_ARG_WITH([gobject], AS_HELP_STRING([--without-gobject], [Do not build the GObject bindings]))
WITH_GOBJECT="no"
AS_IF([test "x$with_gobject" != "xno"], [
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0], [
WITH_GOBJECT="yes"
], [
AC_MSG_ERROR([GObject was not found. Please use --without-gobject.])
])
])
AM_CONDITIONAL([WITH_GOBJECT], [test "x$WITH_GOBJECT" != "xno"])
# Checks for header files.
AC_HEADER_STDBOOL
......@@ -74,7 +88,7 @@ AC_CONFIG_FILES([
AC_CONFIG_FILES([
src/tarot-self-train
pre-inst-env
tarot.desktop
eu.planete_kraus.Tarot.desktop
], [chmod +x src/tarot-self-train pre-inst-env])
AC_OUTPUT
This diff is collapsed.
......@@ -4,5 +4,5 @@ Encoding = UTF-8
Name = The Amazing Rules Of TAROT
Comment = Play the multi-player tarot game version @VERSION@
Exec = tarot
Icon = tarot.png
Icon = eu.planete_kraus.Tarot.png
Terminal = true
\ No newline at end of file
......@@ -13,6 +13,10 @@
"type": "archive",
"path": "upstream.tar.gz"
}
],
"config-opts": [
"--disable-introspection",
"--disable-vapigen"
]
}
]
......
......@@ -16,9 +16,9 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
dist_xlargeicons_DATA += %reldir%/256x256/tarot.png
dist_largeicons_DATA += %reldir%/48x48/tarot.png
dist_mediumicons_DATA += %reldir%/32x32/tarot.png
dist_smallicons_DATA += %reldir%/22x22/tarot.png
dist_xlargeicons_DATA += %reldir%/256x256/eu.planete_kraus.Tarot.png
dist_largeicons_DATA += %reldir%/48x48/eu.planete_kraus.Tarot.png
dist_mediumicons_DATA += %reldir%/32x32/eu.planete_kraus.Tarot.png
dist_smallicons_DATA += %reldir%/22x22/eu.planete_kraus.Tarot.png
dist_html_DATA += %reldir%/tarot.svg
......@@ -17,11 +17,19 @@
# <http://www.gnu.org/licenses/>.
lib_LTLIBRARIES += %reldir%/libtarot.la
bin_PROGRAMS += %reldir%/tarot
dist_man_MANS += %reldir%/tarot.6
EXTRA_DIST += %reldir%/tarot.1
EXTRA_DIST += %reldir%/tarot.1 %reldir%/tarot-gobject.h.in %reldir%/tarot-gobject.c.in \
%reldir%/Tarot-1.0.metadata
girdir = $(datadir)/gir-1.0
typelibdir = $(datadir)/girepository-1.0
vapidir = $(datadir)/vala/vapi
dist_gir_DATA = %reldir%/Tarot-1.0.gir
dist_typelib_DATA = %reldir%/Tarot-1.0.typelib
dist_vapi_DATA = %reldir%/tarot-1.0.vapi
INTROSPECTION_GIRS =
INTROSPECTION_SCANNER_ARGS = --warn-all
VAPIGEN_VAPIS =
LIBTAROT_VERSION_INFO=0:0:0
LIBTAROT_VERSION_INFO = 0:0:0
%canon_reldir%_libtarot_la_SOURCES =
%canon_reldir%_libtarot_la_CFLAGS = \
......@@ -42,25 +50,107 @@ LIBTAROT_VERSION_INFO=0:0:0
%reldir%/xml/libtarot-xml.la \
lib-library/libgnulibrary.la
if WITH_GOBJECT
include_HEADERS += %reldir%/tarot-gobject.h
lib_LTLIBRARIES += %reldir%/libtarot-gobject.la
%canon_reldir%_libtarot_gobject_la_SOURCES = \
%reldir%/tarot-gobject.c
%canon_reldir%_libtarot_gobject_la_CFLAGS = \
$(AM_CFLAGS) \
$(GOBJECT_CFLAGS)
%canon_reldir%_libtarot_gobject_la_LDFLAGS = \
-no-undefined -version-info $(LIBTAROT_VERSION_INFO) $(AM_LDADD) \
$(GOBJECT_LIBS)
%canon_reldir%_libtarot_gobject_la_LIBADD =
bin_PROGRAMS += %reldir%/tarot
dist_man_MANS += %reldir%/tarot.6
%canon_reldir%_tarot_SOURCES = \
%reldir%/main.c \
%reldir%/tarot-opts.c \
%reldir%/tarot-opts.h
%reldir%/tarot-opts.h \
%reldir%/application.vala \
%reldir%/tarot-1.0.vapi
%canon_reldir%_tarot_CFLAGS = \
$(AM_CFLAGS) \
$(LIBOPTS_CFLAGS) \
-include config.h
$(GOBJECT_CFLAGS) \
-w
%canon_reldir%_tarot_CXXFLAGS = \
$(AM_CXXFLAGS)
%canon_reldir%_tarot_CPPFLAGS = \
$(AM_CPPFLAGS)
$(AM_CPPFLAGS) \
-include config.h
%canon_reldir%_tarot_LDFLAGS = \
$(AM_LDADD)
%canon_reldir%_tarot_LDADD = \
%reldir%/libtarot.la \
%reldir%/libtarot-gobject.la \
lib-program/libgnulibrary.la \
$(LTLIBREADLINE) \
$(LIBOPTS_LDADD)
$(LIBOPTS_LDADD) \
$(GOBJECT_LIBS)
else # not WITH_GOBJECT
EXTRA_DIST += %reldir%/main.c \
%reldir%/tarot-opts.c \
%reldir%/tarot-opts.h \
%reldir%/application.c \
%reldir%/application.h \
%reldir%/application.vala \
%reldir%/tarot.6
endif # not WITH_GOBJECT
if HAVE_INTROSPECTION
introspection_sources = $(include_HEADERS) $(tarotinclude_HEADERS)
%reldir%/Tarot-1.0.gir: $(tarot_HEADERS) $(tarotinclude_HEADERS) \
%reldir%/libtarot.la %reldir%/libtarot-gobject.la
%canon_reldir%_Tarot_1_0_gir_NAMESPACE = Tarot
%canon_reldir%_Tarot_1_0_gir_VERSION = Tarot
%canon_reldir%_Tarot_1_0_gir_INCLUDES = GObject-2.0
%canon_reldir%_Tarot_1_0_gir_CFLAGS = $(AM_CPPFLAGS) $(AM_CFLAGS) -include "config.h"
%canon_reldir%_Tarot_1_0_gir_LIBS = %reldir%/libtarot.la %reldir%/libtarot-gobject.la
%canon_reldir%_Tarot_1_0_gir_FILES = $(include_HEADERS) $(tarotinclude_HEADERS)
INTROSPECTION_GIRS += %reldir%/Tarot-1.0.gir
%reldir%/tarot-gobject.h: %reldir%/tarot-gobject.h.in $(ENUM_HEADER_FILES)
$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) \
--template %reldir%/tarot-gobject.h.in \
$(ENUM_HEADER_FILES) \
> %reldir%/tarot-gobject.h)
%reldir%/tarot-gobject.c: %reldir%/tarot-gobject.c.in %reldir%/tarot-gobject.h
$(AM_V_GEN) $(GLIB_MKENUMS) \
--template %reldir%/tarot-gobject.c.in \
$(ENUM_HEADER_FILES) \
> %reldir%/tarot-gobject.c \
$(ENUM_HEADER_FILES)
include $(INTROSPECTION_MAKEFILE)
else # not HAVE_INTROSPECTION
%reldir%/Tarot-1.0.gir: $(include_HEADERS) $(tarotinclude_HEADERS)
@echo "The GobjectIntrospection repository needs to be rebuilt."
false
%reldir%/Tarot-1.0.typelib: %reldir%/Tarot-1.0.gir
@echo "The GobjectIntrospection repository needs to be rebuilt."
false
%reldir%/tarot-gobject.h: %reldir%/tarot-gobject.h.in $(ENUM_HEADER_FILES)
@echo "The enum bindings have to be rebuilt."
false
%reldir%/tarot-gobject.c: %reldir%/tarot-gobject.c.in %reldir%/tarot-gobject.h
@echo "The enum bindings have to be rebuilt."
false
endif # not HAVE_INTROSPECTION
if ENABLE_VAPIGEN
%reldir%/tarot-1.0.vapi: %reldir%/Tarot-1.0.gir
%canon_reldir%_tarot_1_0_vapi_FILES = %reldir%/Tarot-1.0.gir
%canon_reldir%_tarot_1_0_vapi_METADATADIRS = $(srcdir)
VAPIGEN_VAPIS += %reldir%/tarot-1.0.vapi
-include $(VAPIGEN_MAKEFILE)
else #not ENABLE_VAPIGEN
%reldir%/tarot-1.0.vapi: %reldir%/Tarot-1.0.gir
@echo "The Vala bindings need to be rebuilt."
false
endif #not ENABLE_VAPIGEN
$(%canon_reldir%_tarot_OBJECTS): %reldir%/tarot-opts.h
%reldir%/tarot-opts.h: %reldir%/tarot-opts.c
......@@ -74,6 +164,7 @@ doc/invoke-tarot.texi: %reldir%/tarot-opts.def
$(AM_V_GEN) (cd $(srcdir)/doc && $(AUTOGEN) --writable -Tagtexi-cmd.tpl $(abs_top_srcdir)/%reldir%/tarot-opts.def)
pkgconfig_DATA += %reldir%/libtarot.pc
INDENTED += %reldir%/tarot-gobject.h.in %reldir%/tarot-gobject.c.in
AM_CPPFLAGS += -I $(srcdir)/%reldir% -I %reldir%
......
Tarot cheader_filename="tarot-gobject.h"
\ No newline at end of file
......@@ -67,6 +67,7 @@ INDENTED += $(%canon_reldir%_libtarot_cards_la_SOURCES) \
%reldir%/tarot/cards_private_impl.tpl
LIBTAROT_CARDS_LA = %reldir%/libtarot-cards.la
ENUM_HEADER_FILES += %reldir%/tarot/cards.h
%reldir%/gen-cards-def: %reldir%/minor_suits.def %reldir%/minor_suits.tpl
$(AM_V_GEN) (cd $(srcdir)/%reldir% \
......
......@@ -21,6 +21,7 @@
#include <config.h>
#include <tarot/cards_private.h>
#include <stdlib.h>
#include <assert.h>
int
tarot_of (TarotNumber n, TarotSuit s, TarotCard * c)
......@@ -58,6 +59,20 @@ tarot_card_to_string (TarotCard c, size_t max, char *dest)
return card_to_string (c, max, dest);
}
char *
tarot_card_to_string_alloc (TarotCard c)
{
char *ret = malloc (4);
if (ret != NULL)
{
if (card_to_string (c, 4, ret) >= 4)
{
assert (0);
}
}
return ret;
}
TarotCardArray *
tarot_card_array_alloc ()
{
......@@ -70,6 +85,12 @@ tarot_card_array_free (TarotCardArray * array)
card_array_free (array);
}
TarotCardArray *
tarot_card_array_dup (const TarotCardArray * array)
{
return card_array_dup (array);
}
size_t
tarot_card_array_size (const TarotCardArray * array)
{
......
......@@ -89,7 +89,7 @@ extern "C"
*
* n: the number.
* s: the suit.
* c: set to the n of s.
* @c: (out): set to the n of s.
* Returns: whether there were an error.
*/
int tarot_of (TarotNumber n, TarotSuit s, TarotCard * c);
......@@ -101,8 +101,8 @@ extern "C"
* Cannot decompose the excuse.
*
* c: the card.
* n: set to the number of c.
* s: set to the suit of c.
* @n: (out): set to the number of c.
* @s: (out): set to the suit of c.
* Returns: whether there were an error.
*/
int tarot_decompose (TarotCard c, TarotNumber * n, TarotSuit * s);
......@@ -112,13 +112,25 @@ extern "C"
TarotCard tarot_card_parse (const char *text, char **end);
/**
* tarot_card_to_string: (skip):
*/
size_t tarot_card_to_string (TarotCard c, size_t max, char *dest);
/**
* tarot_card_to_string_alloc:
*/
char *tarot_card_to_string_alloc (TarotCard c);
struct TarotCardArray;
typedef struct TarotCardArray TarotCardArray;
/**
* tarot_card_array_alloc: (constructor):
*/
TarotCardArray *tarot_card_array_alloc ();
void tarot_card_array_free (TarotCardArray * array);
TarotCardArray *tarot_card_array_dup (const TarotCardArray * array);
size_t tarot_card_array_size (const TarotCardArray * array);
int tarot_card_array_resize (TarotCardArray * array, size_t new_size);
......
......@@ -56,6 +56,7 @@ extern "C"
static TarotCardArray *card_array_alloc ();
static void card_array_free (TarotCardArray * array);
static TarotCardArray *card_array_dup (const TarotCardArray * array);
static size_t card_array_size (const TarotCardArray * array);
static int card_array_resize (TarotCardArray * array, size_t new_size);
......
......@@ -148,6 +148,25 @@ card_array_free (TarotCardArray * array)
free (array);
}
static inline TarotCardArray *
card_array_dup (const TarotCardArray * array)
{
TarotCardArray *ret = card_array_alloc ();
if (ret != NULL)
{
if (card_array_resize (ret, array->n) != 0)
{
card_array_free (ret);
ret = NULL;
}
else
{
memcpy (ret->data, array->data, ret->n * sizeof (TarotCard));
}
}
return ret;
}
static inline size_t
card_array_size (const TarotCardArray * array)
{
......
......@@ -34,6 +34,13 @@ tarot_cli_free (TarotCli * cli)
cli_free (cli);
}
TarotCli *
tarot_cli_dup (const TarotCli * cli)
{
(void) cli;
return NULL;
}
int
tarot_cli_push (TarotCli * cli, const char *data, int eof)
{
......@@ -77,39 +84,63 @@ tarot_cli_is_license (const TarotCli * cli)
}
int
tarot_cli_is_error (const TarotCli * cli, char **error)
tarot_cli_is_error (const TarotCli * cli)
{
return cli_is_error (cli, error);
return cli_is_error (cli);
}
int
tarot_cli_is_status (const TarotCli * cli, int *with_imputation)
tarot_cli_is_status (const TarotCli * cli)
{
return cli_is_status (cli, with_imputation);
return cli_is_status (cli);
}
int
tarot_cli_is_load (const TarotCli * cli, char **filename)
tarot_cli_is_load (const TarotCli * cli)
{
return cli_is_load (cli, filename);
return cli_is_load (cli);
}
int
tarot_cli_is_save (const TarotCli * cli, char **filename)
tarot_cli_is_save (const TarotCli * cli)
{
return cli_is_save (cli, filename);
return cli_is_save (cli);
}
int
tarot_cli_is_check (const TarotCli * cli, TarotGameEvent ** event)
tarot_cli_is_check (const TarotCli * cli)
{
return cli_is_check (cli, event);
return cli_is_check (cli);
}
int
tarot_cli_is_event (const TarotCli * cli, TarotGameEvent ** event)
tarot_cli_is_event (const TarotCli * cli)
{
return cli_is_event (cli);
}
const char *
tarot_cli_get_error (const TarotCli * cli)
{
return cli_get_error (cli);
}
int
tarot_cli_get_with_imputation (const TarotCli * cli)
{
return cli_get_with_imputation (cli);
}
const char *
tarot_cli_get_filename (const TarotCli * cli)
{
return cli_get_filename (cli);
}
const TarotGameEvent *
tarot_cli_get_event (const TarotCli * cli)
{
return cli_is_event (cli, event);
return cli_get_event (cli);
}
#include <tarot/cli_private_impl.h>
......@@ -35,23 +35,99 @@ extern "C"
typedef struct TarotCli TarotCli;
TarotCli *tarot_cli_alloc ();
/**
* tarot_cli_free: (skip):
*/
void tarot_cli_free (TarotCli * cli);
/**
* tarot_cli_dup: (skip):
*
* This does NOT WORK yet! BUT a pointer to such a function is
* required for GObject introspection. DO NOT TRY TO COPY A CLI, A
* PARSER OR A LEXER INSTANCE!!!
*/
TarotCli *tarot_cli_dup (const TarotCli * cli);
int tarot_cli_push (TarotCli * cli, const char *data, int eof);
int tarot_cli_next (TarotCli * cli);
/**
* tarot_cli_has_command:
* Returns: (type boolean):
*/
int tarot_cli_has_command (const TarotCli * cli);
/**
* tarot_cli_is_continuation:
* Returns: (type boolean):
*/
int tarot_cli_is_continuation (const TarotCli * cli);
/**
* tarot_cli_is_help:
* Returns: (type boolean):
*/
int tarot_cli_is_help (const TarotCli * cli);
/**
* tarot_cli_is_version:
* Returns: (type boolean):
*/
int tarot_cli_is_version (const TarotCli * cli);
/**
* tarot_cli_is_license:
* Returns: (type boolean):
*/
int tarot_cli_is_license (const TarotCli * cli);
int tarot_cli_is_error (const TarotCli * cli, char **errorstr);
int tarot_cli_is_status (const TarotCli * cli, int *with_imputation);
int tarot_cli_is_load (const TarotCli * cli, char **filename);
int tarot_cli_is_save (const TarotCli * cli, char **filename);
int tarot_cli_is_check (const TarotCli * cli, TarotGameEvent ** event);
int tarot_cli_is_event (const TarotCli * cli, TarotGameEvent ** event);
/**
* tarot_cli_is_error:
* Returns: (type boolean):
*/
int tarot_cli_is_error (const TarotCli * cli);
const char *tarot_cli_get_error (const TarotCli * cli);
/**
* tarot_cli_is_status:
* Returns: (type boolean):
*/
int tarot_cli_is_status (const TarotCli * cli);
/**
* tarot_cli_get_with_imputation:
* Returns: (type boolean):
*/
int tarot_cli_get_with_imputation (const TarotCli * cli);
/**
* tarot_cli_is_load:
* Returns: (type boolean):
*/
int tarot_cli_is_load (const TarotCli * cli);
const char *tarot_cli_get_filename (const TarotCli * cli);
/**
* tarot_cli_is_save:
* Returns: (type boolean):
*/
int tarot_cli_is_save (const TarotCli * cli);
/**
* tarot_cli_is_check:
* Returns: (type boolean):
*/
int tarot_cli_is_check (const TarotCli * cli);
const TarotGameEvent *tarot_cli_get_event (const TarotCli * cli);
/**
* tarot_cli_is_event:
* Returns: (type boolean):
*/
int tarot_cli_is_event (const TarotCli * cli);
#ifdef __cplusplus
}
......
......@@ -48,12 +48,16 @@ extern "C"
static int cli_is_help (const TarotCli * cli);
static int cli_is_version (const TarotCli * cli);
static int cli_is_license (const TarotCli * cli);
static int cli_is_error (const TarotCli * cli, char **errorstr);
static int cli_is_status (const TarotCli * cli, int *with_imputation);
static int cli_is_load (const TarotCli * cli, char **filename);
static int cli_is_save (const TarotCli * cli, char **filename);
static int cli_is_check (const TarotCli * cli, TarotGameEvent ** event);
static int cli_is_event (const TarotCli * cli, TarotGameEvent ** event);
static int cli_is_error (const TarotCli * cli);
static int cli_is_status (const TarotCli * cli);
static int cli_is_load (const TarotCli * cli);
static int cli_is_save (const TarotCli * cli);
static int cli_is_check (const TarotCli * cli);
static int cli_is_event (const TarotCli * cli);
static const char *cli_get_error (const TarotCli * cli);
static int cli_get_with_imputation (const TarotCli * cli);
static const char *cli_get_filename (const TarotCli * cli);
static const TarotGameEvent *cli_get_event (const TarotCli * cli);
#ifdef __cplusplus
}
......
......@@ -60,7 +60,7 @@ cli_free (TarotCli * cli)
static int
cli_transfer (TarotCli * cli)
{
while (tarot_parser_get_type (cli->parser) < 0
while (tarot_parser_get_command_type (cli->parser) < 0
&& tarot_lexer_get_token_type (cli->lexer) >= 0)
{
int tt;
......@@ -197,7 +197,7 @@ cli_next (TarotCli * cli)
static inline int
cli_has_command (const TarotCli * cli)
{
return tarot_parser_get_type (cli->parser) >= 0;
return tarot_parser_get_command_type (cli->parser) >= 0;
}
static inline int
......@@ -209,87 +209,98 @@ cli_is_continuation (const TarotCli * cli)
static inline int
cli_is_help (const TarotCli * cli)
{
return tarot_parser_get_type (cli->parser) == tarot_parser_type_help ();
return tarot_parser_get_command_type (cli->parser) ==
tarot_parser_type_help ();
}
static inline int
cli_is_version (const TarotCli * cli)
{
return tarot_parser_get_type (cli->parser) == tarot_parser_type_version ();
return tarot_parser_get_command_type (cli->parser) ==
tarot_parser_type_version ();
}
static inline int
cli_is_license (const TarotCli * cli)
{
return tarot_parser_get_type (cli->parser) == tarot_parser_type_license ();
return tarot_parser_get_command_type (cli->parser) ==
tarot_parser_type_license ();
}
static inline int
cli_is_error (const TarotCli * cli, char **errorstr)
cli_is_error (const TarotCli * cli)
{
int ok =
(tarot_parser_get_type (cli->parser) == tarot_parser_type_error ());
if (ok)
{
*errorstr = (char *) tarot_parser_get_error (cli->parser);
}
(tarot_parser_get_command_type (cli->parser) ==
tarot_parser_type_error ());
return ok;
}
static inline int
cli_is_status (const TarotCli * cli, int *with_imputation)
cli_is_status (const TarotCli * cli)
{
int ok =
(tarot_parser_get_type (cli->parser) == tarot_parser_type_status ());
if (ok)
{
*with_imputation = tarot_parser_get_with_imputation (cli->parser);
}
(tarot_parser_get_command_type (cli->parser) ==
tarot_parser_type_status ());
return ok;
}
static inline int
cli_is_load (const TarotCli * cli, char **filename)
cli_is_load (const TarotCli * cli)
{
int ok = (tarot_parser_get_type (cli->parser) == tarot_parser_type_load ());
if (ok)
{
*filename = (char *) tarot_parser_get_filename (cli->parser);
}
int ok =
(tarot_parser_get_command_type (cli->parser) ==
tarot_parser_type_load ());
return ok;
}
static inline int
cli_is_save (const TarotCli * cli, char **filename)
cli_is_save (const TarotCli * cli)
{
int ok = (tarot_parser_get_type (cli->parser) == tarot_parser_type_save ());
if (ok)
{
*filename = (char *) tarot_parser_get_filename (cli->parser);
}
int ok =
(tarot_parser_get_command_type (cli->parser) ==
tarot_parser_type_save ());
return ok;
}
static inline int
cli_is_check (const TarotCli * cli, TarotGameEvent ** event)
cli_is_check (const TarotCli * cli)
{
int ok =
(tarot_parser_get_type (cli->parser) == tarot_parser_type_check ());
if (ok)
{
*event = (TarotGameEvent *) tarot_parser_get_event (cli->parser);
}
(tarot_parser_get_command_type (cli->parser) ==
tarot_parser_type_check ());
return ok;
}