Commit b167437f authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Glib-mkenums

parent 99b619f5
Pipeline #32562 passed with stage
in 1 minute and 22 seconds
......@@ -3,7 +3,7 @@
(eval
. (setq company-clang-arguments
(split-string
"-I@abs_top_srcdir@ -I@abs_top_builddir@ -I@abs_top_srcdir@/lib -I@abs_top_builddir@/lib -I@abs_top_srcdir@/src -I@abs_top_builddir@/src -I@abs_top_srcdir@/src/core -I@abs_top_builddir@/src/core -I@abs_top_srcdir@/src/lang -I@abs_top_builddir@/src/lang @CFLAGS@ @CPPFLAGS@ @OPENMP_CFLAGS@ @ASAN_CFLAGS@"
"-I@abs_top_srcdir@ -I@abs_top_builddir@ -I@abs_top_srcdir@/lib -I@abs_top_builddir@/lib -I@abs_top_srcdir@/src -I@abs_top_builddir@/src -I@abs_top_srcdir@/src/core -I@abs_top_builddir@/src/core -I@abs_top_srcdir@/src/lang -I@abs_top_builddir@/src/lang @CFLAGS@ @CPPFLAGS@ @OPENMP_CFLAGS@ @ASAN_CFLAGS@ @GOBJECT_CFLAGS@"
)
)
)
......
......@@ -133,6 +133,8 @@ src/lang/_tarot_parser.c
src/lang/_tarot_parser.h
src/lang/check_lexer
src/lang/tarot-parrot
src/tarot-gobject/tarot_gobject.h
src/tarot-gobject/tarot_gobject_enums.c
src/tarot-status
stamp-h1
tarot-*.tar.gz
......
......@@ -10,6 +10,7 @@ noinst_LTLIBRARIES =
include_HEADERS =
INDENTED_FILES =
TESTS =
BUILT_SOURCES =
ACLOCAL_AMFLAGS = -I m4
......@@ -49,6 +50,9 @@ AM_CFLAGS = \
$(ASAN_CFLAGS) \
$(GCOV_CFLAGS)
# Needed to build and distribute the .h
AM_YFLAGS = -d
AM_LIBS = \
$(ASAN_LIBS) \
$(OPENMP_LIBS) \
......@@ -75,6 +79,9 @@ include $(srcdir)/games/games.am
include $(srcdir)/games/pass/pass.am
include $(srcdir)/games/fail/fail.am
include $(srcdir)/test-tarot-status.am
## THE ORDER IS IMPORTANT, THE GENERATED FILES SHOULD BE INDENTED
## AFTER tarot.h
include $(srcdir)/src/tarot-gobject/tarot-gobject.am
INDENTED_FILES += $(include_HEADERS)
......
......@@ -7,10 +7,6 @@ cd $SRCDIR || exit 1
mkdir -p lib || exit 1
echo "" > lib/Makefile.am
echo "Bison..."
(cd src/lang && \
bison --report=all -o _tarot_parser.c _tarot_parser.y) \
|| exit 1
echo "gettext.h..."
cp /usr/share/gettext/gettext.h src/
touch po/POTFILES.in
......
......@@ -9,7 +9,7 @@ AC_DEFUN([AX_GOBJECT], [
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0], [
GOBJECT_PKG_FOUND="yes"
], [
AC_MSG_ERROR([The requested feature gobject cannot be built.])
AC_MSG_FAILURE([The requested feature gobject cannot be built.])
])
AS_IF([test "x$GOBJECT_PKG_FOUND" != "xno"], [
ORIGINAL_CFLAGS="$CFLAGS"
......@@ -19,11 +19,23 @@ AC_DEFUN([AX_GOBJECT], [
AC_CHECK_FUNC([g_once_init_enter], [
AM_CONDITIONAL([HAVE_GOBJECT], [true])
], [
AC_MSG_ERROR([
AC_MSG_FAILURE([
You have gobject-2.0 installed, but it cannot be linked.])
])
CFLAGS="$ORIGINAL_CFLAGS"
LIBS="$ORIGINAL_LIBS"
])
])
AC_ARG_ENABLE([mkenums],
[AS_HELP_STRING([--enable-mkenums],
[use the glib-mkenums program (default: if available)])])
AC_ARG_VAR([GLIB_MKENUMS],
[glib-mkenums program (optional, but needed to build from git,
pass 'no' to disable the check)])
AS_IF([test "x$GLIB_MKENUMS" != "xno"], [
AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums], [no])
])
AM_CONDITIONAL([HAVE_GLIB_MKENUMS], [test "x$GLIB_MKENUMS" != "xno"])
AS_IF([test "x$enable_mkenums" = "xyes" && test "x$GLIB_MKENUMS" = "xno"],
AC_MSG_FAILURE([Requested glib-mkenums program not found.]))
])
......@@ -8,11 +8,8 @@ AC_DEFUN([AX_INDENT], [
recommended for contributors, default: search for 'indent',
pass 'no' to disable the check)])
AS_IF([test "x$INDENT" != "xno"], [
AC_PATH_PROG([INDENT], [indent], [no])
AC_PATH_PROG([INDENT], [indent], [indent])
])
AM_CONDITIONAL([HAVE_INDENT], [test "x$INDENT" != "xno"])
AS_IF([test "x$enable_indent" = "xyes" && test "x$INDENT" = "xno"],
AC_MSG_FAILURE([Requested indent program not found.]))
AC_SUBST([INDENT_RULES], [['## Rules for indent
indent.stamp: $(INDENTED_FILES)
(cd $(abs_srcdir) && \
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tarot devel\n"
"Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n"
"POT-Creation-Date: 2017-12-16 13:31+0100\n"
"POT-Creation-Date: 2017-12-16 17:29+0100\n"
"PO-Revision-Date: 2017-12-12 23:22+0100\n"
"Last-Translator: Vivien Kraus <vivien@planete-kraus.eu\n"
"Language-Team: FRENCH (contact me directly)\n"
......@@ -20,7 +20,7 @@ msgstr ""
msgid "no errors"
msgstr "pas d'erreur"
#: src/core/tarot_strerror.c:31 src/lang/_tarot_parser.y:529
#: src/core/tarot_strerror.c:31 src/lang/_tarot_parser.y:528
msgid "not a card"
msgstr "pas une carte"
......@@ -32,38 +32,38 @@ msgstr "ne peut dcomposer l'excuse"
msgid "unknown error"
msgstr "erreur inconnue"
#: src/lang/_tarot_parser.y:75 src/lang/_tarot_parser.y:653
#: src/lang/_tarot_parser.y:75 src/lang/_tarot_parser.y:652
#: src/lang/tarot_parser_pull.c:76 src/lang/tarot_game_builder_callbacks.c:85
#: src/lang/tarot_game_builder_callbacks.c:103
#: src/lang/tarot_game_builder_callbacks.c:300
msgid "Dynamic memory exhausted"
msgstr "Plus de mémoire dynamique"
#: src/lang/_tarot_parser.y:244
#: src/lang/_tarot_parser.y:243
msgid "expected 78 players"
msgstr "attendu : 78 joueurs"
#: src/lang/_tarot_parser.y:495
#: src/lang/_tarot_parser.y:494
msgid "expected a trump number"
msgstr "numéro d'atout attendu"
#: src/lang/_tarot_parser.y:501
#: src/lang/_tarot_parser.y:500
msgid "expected a minor number"
msgstr "numéro non atout attendu"
#: src/lang/_tarot_parser.y:506 src/lang/_tarot_parser.y:569
#: src/lang/_tarot_parser.y:505 src/lang/_tarot_parser.y:568
msgid "wrong number / suit"
msgstr "mauvaise numéro / couleur"
#: src/lang/_tarot_parser.y:551
#: src/lang/_tarot_parser.y:550
msgid "expected a list of trump numbers"
msgstr "liste de numéros d'atout attendue"
#: src/lang/_tarot_parser.y:558
#: src/lang/_tarot_parser.y:557
msgid "expected a list of minor numbers"
msgstr "liste de numéros non atout attendue"
#: src/lang/_tarot_parser.y:624
#: src/lang/_tarot_parser.y:623
msgid "should be at least 1 and at most 21"
msgstr "devrait être au moins 1 et au plus 21"
......
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tarot devel\n"
"Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n"
"POT-Creation-Date: 2017-12-16 13:31+0100\n"
"POT-Creation-Date: 2017-12-16 17:29+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -21,7 +21,7 @@ msgstr ""
msgid "no errors"
msgstr ""
#: src/core/tarot_strerror.c:31 src/lang/_tarot_parser.y:529
#: src/core/tarot_strerror.c:31 src/lang/_tarot_parser.y:528
msgid "not a card"
msgstr ""
......@@ -33,38 +33,38 @@ msgstr ""
msgid "unknown error"
msgstr ""
#: src/lang/_tarot_parser.y:75 src/lang/_tarot_parser.y:653
#: src/lang/_tarot_parser.y:75 src/lang/_tarot_parser.y:652
#: src/lang/tarot_parser_pull.c:76 src/lang/tarot_game_builder_callbacks.c:85
#: src/lang/tarot_game_builder_callbacks.c:103
#: src/lang/tarot_game_builder_callbacks.c:300
msgid "Dynamic memory exhausted"
msgstr ""
#: src/lang/_tarot_parser.y:244
#: src/lang/_tarot_parser.y:243
msgid "expected 78 players"
msgstr ""
#: src/lang/_tarot_parser.y:495
#: src/lang/_tarot_parser.y:494
msgid "expected a trump number"
msgstr ""
#: src/lang/_tarot_parser.y:501
#: src/lang/_tarot_parser.y:500
msgid "expected a minor number"
msgstr ""
#: src/lang/_tarot_parser.y:506 src/lang/_tarot_parser.y:569
#: src/lang/_tarot_parser.y:505 src/lang/_tarot_parser.y:568
msgid "wrong number / suit"
msgstr ""
#: src/lang/_tarot_parser.y:551
#: src/lang/_tarot_parser.y:550
msgid "expected a list of trump numbers"
msgstr ""
#: src/lang/_tarot_parser.y:558
#: src/lang/_tarot_parser.y:557
msgid "expected a list of minor numbers"
msgstr ""
#: src/lang/_tarot_parser.y:624
#: src/lang/_tarot_parser.y:623
msgid "should be at least 1 and at most 21"
msgstr ""
......
......@@ -91,7 +91,6 @@
%locations
%define api.prefix {_tarot_parser_}
%define api.token.prefix {_TAROT_TOKEN_}
%defines "_tarot_parser.h"
%parse-param {TarotParser *parser}
%token ERROR
......
noinst_LTLIBRARIES += %reldir%/libtarot-lang.la
# It is in the top-level directory
BUILT_SOURCES += %reldir%/_tarot_parser.h
# This is set in the root Makefile.am, so no need to add it here.
# AM_YFLAGS = -d
%canon_reldir%_libtarot_lang_la_SOURCES = \
%reldir%/tarot_lang.h \
%reldir%/tarot_lang_private.h \
......@@ -27,6 +33,3 @@ noinst_LTLIBRARIES += %reldir%/libtarot-lang.la
INDENTED_FILES += \
$(%canon_reldir%_libtarot_lang_la_SOURCES)
%reldir%/_tarot_parser.h: %reldir%/_tarot_parser.y
$(MAKE) -W %reldir%/_tarot_parser.y %reldir%/_tarot_parser.c
/**
* \file tarot_atomic_lexer.h
*
* Copyright (C) 2017 Vivien Kraus <vivien@planete-kraus.eu>
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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
* 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/>.
*/
#ifndef H_TAROT_ATOMIC_LEXER_INCLUDED
#define H_TAROT_ATOMIC_LEXER_INCLUDED
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
struct _TarotAtomicLexer;
typedef struct _TarotAtomicLexer _TarotAtomicLexer;
size_t _tarot_atomic_lexer_init_line (size_t available, char *mem);
size_t _tarot_atomic_lexer_init_whitespace (size_t available, char *mem);
size_t _tarot_atomic_lexer_init_number (size_t available, char *mem);
size_t _tarot_atomic_lexer_init_token (const char *token, size_t available, char *mem);
void _tarot_atomic_lexer_push (_TarotAtomicLexer *lexer, char c);
void _tarot_atomic_lexer_eof (_TarotAtomicLexer *lexer);
void _tarot_atomic_lexer_restart (_TarotAtomicLexer *lexer);
void _tarot_atomic_lexer_status (const _TarotAtomicLexer *lexer, int *can_be, int *finished, unsigned int *size, unsigned int *value);
#ifdef __cplusplus
}
#include <tarot.hpp>
#endif /* cplusplus */
#endif /* not H_TAROT_ATOMIC_LEXER_INCLUDED */
if HAVE_GOBJECT
BUILT_SOURCES += \
%reldir%/tarot_gobject_enums.c \
%reldir%/tarot_gobject.h
EXTRA_DIST += \
%reldir%/tarot_gobject_enums.c \
%reldir%/tarot_gobject.h \
%reldir%/tarot_gobject_enums.template \
%reldir%/tarot_gobject.template
if HAVE_GLIB_MKENUMS
%reldir%/tarot_gobject.h: \
%reldir%/tarot_gobject.template \
src/core/tarot.h
$(GLIB_MKENUMS) \
--template $(srcdir)/%reldir%/tarot_gobject.template \
$(srcdir)/%reldir%/tarot_gobject.h \
> $(srcdir)/%reldir%/tarot_gobject.h
%reldir%/tarot_gobject_enums.c: \
%reldir%/tarot_gobject_enums.template \
src/core/tarot.h
$(GLIB_MKENUMS) \
--template $(srcdir)/%reldir%/tarot_gobject.template \
$(srcdir)/%reldir%/tarot_gobject.h \
> $(srcdir)/%reldir%/tarot_gobject_enums.c
else # not HAVE_GLIB_MKENUMS
%reldir%/tarot_gobject.h: \
%reldir%/tarot_gobject.template \
src/core/tarot.h
@ >&2 echo "You need glib-mkenums installed."
exit 1
%reldir%/tarot_gobject_enums.c: \
%reldir%/tarot_gobject_enums.template \
src/core/tarot.h
@ >&2 echo "You need glib-mkenums installed."
exit 1
endif # not HAVE_GLIB_MKENUMS
if HAVE_GOBJECT
lib_LTLIBRARIES += %reldir%/libtarot-gobject.la
include_HEADERS += %reldir%/tarot_gobject.h
%canon_reldir%_libtarot_gobject_la_SOURCES = \
%reldir%/tarot_suit_get_type.c
%reldir%/tarot_gobject_enums.c
%canon_reldir%_libtarot_gobject_la_LDFLAGS = \
-no-undefined \
......@@ -17,7 +56,10 @@ include_HEADERS += %reldir%/tarot_gobject.h
%canon_reldir%_libtarot_gobject_la_CFLAGS = \
$(AM_CFLAGS) $(GOBJECT_CFLAGS)
## THE ORDER IS IMPORTANT, THE GENERATED FILES SHOULD BE INDENTED
## AFTER tarot.h
INDENTED_FILES += \
$(%canon_reldir%_libtarot_gobject_la_SOURCES)
$(%canon_reldir%_libtarot_gobject_la_SOURCES) \
$(include_HEADERS)
endif # HAVE_GOBJECT
/*** BEGIN file-header ***/
/**
* \file tarot_gobject.h Libtarot bindings for the GObject type system
*
......@@ -30,10 +32,23 @@
extern "C"
{
#endif /* __cplusplus */
G_BEGIN_DECLS
#define TAROT_TYPE_SUIT (tarot_suit_get_type ())
GType tarot_suit_get_type (void) G_GNUC_CONST;
/*** END file-header ***/
/*** BEGIN file-production ***/
/* Enumerations in file "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
#define @ENUM_PREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
GType @enum_name@_get_type (void) G_GNUC_CONST;
/*** END value-header ***/
/*** BEGIN file-tail ***/
G_END_DECLS
#ifdef __cplusplus
}
......@@ -42,3 +57,9 @@ extern "C"
#endif /* cplusplus */
#endif /* not H_TAROT_GOBJECT_INCLUDED */
/* Local Variables: */
/* mode: c */
/* End: */
/*** END file-tail ***/
/*** BEGIN file-header ***/
/**
* \file tarot_suit_get_type.c
* \file tarot_gobject_enums.c
*
* Copyright (C) 2017 Vivien Kraus <vivien@planete-kraus.eu>
*
......@@ -18,25 +20,46 @@
* <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include "tarot_gobject.h"
/*** END file-header ***/
/*** BEGIN file-production ***/
/* Enumerations in file "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
tarot_suit_get_type ()
@enum_name@_get_type ()
{
static volatile gsize tarot_suit_type_id__volatile = 0;
if (g_once_init_enter (&tarot_suit_type_id__volatile))
static volatile gsize g_@type@_type_id__volatile = 0;
if (g_once_init_enter (&g_define_type_id__volatile))
{
static const GEnumValue values[] = {
{TAROT_HEARTS, "TAROT_HEARTS", "hearts"},
{TAROT_CLUBS, "TAROT_CLUBS", "clubs"},
{TAROT_DIAMONDS, "TAROT_DIAMONDS", "diamonds"},
{TAROT_SPADES, "TAROT_SPADES", "spades"},
{TAROT_TRUMPS, "TAROT_TRUMPS", "trumps"},
{0, NULL, NULL}
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType tarot_suit_type_id;
tarot_suit_type_id = g_enum_register_static ("TarotSuit", values);
g_once_init_leave (&tarot_suit_type_id__volatile, tarot_suit_type_id);
GType g_@type@_type_id =
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_once_init_leave (&g_@type@_type_id__volatile, g_@type@_type_id);
}
return tarot_suit_type_id__volatile;
return g_@type@_type_id__volatile;
}
/*** END value-tail ***/
/*** BEGIN file-tail ***/
/*** END file-tail ***/
/* Local Variables: */
/* mode: c */
/* End: */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment