[dasher] These files came with "Refactor Mandarin changes to CAlphabetManager
- From: Patrick Welche <pwelche src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [dasher] These files came with "Refactor Mandarin changes to CAlphabetManager
- Date: Thu, 13 Aug 2009 18:13:30 +0000 (UTC)
commit 585d1a6bff41a3bbcc7f945c54f8e7453214938c
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Thu Aug 13 19:12:47 2009 +0100
These files came with "Refactor Mandarin changes to CAlphabetManager
into CMandarinAlphMgr subclass".
Src/DasherCore/MandarinAlphMgr.cpp | 91 +++++++++++++++++++++++++
Src/DasherCore/MandarinAlphMgr.h | 57 ++++++++++++++++
gnome-doc-utils.make | 14 ++---
m4/gnome-doc-utils.m4 | 3 +-
m4/intltool.m4 | 128 ++++++++++++++++++++---------------
5 files changed, 227 insertions(+), 66 deletions(-)
---
diff --git a/Src/DasherCore/MandarinAlphMgr.cpp b/Src/DasherCore/MandarinAlphMgr.cpp
new file mode 100644
index 0000000..5f37fc9
--- /dev/null
+++ b/Src/DasherCore/MandarinAlphMgr.cpp
@@ -0,0 +1,91 @@
+// MandarinAlphMgr.cpp
+//
+// Copyright (c) 2009 The Dasher Team
+//
+// This file is part of Dasher.
+//
+// Dasher 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 2 of the License, or
+// (at your option) any later version.
+//
+// Dasher 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 Dasher; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#include "../Common/Common.h"
+
+#include "MandarinAlphMgr.h"
+#include "ConversionManager.h"
+#include "DasherInterfaceBase.h"
+#include "DasherNode.h"
+#include "Event.h"
+#include "EventHandler.h"
+#include "NodeCreationManager.h"
+
+
+#include <vector>
+#include <sstream>
+#include <iostream>
+
+using namespace Dasher;
+
+// Track memory leaks on Windows to the line that new'd the memory
+#ifdef _WIN32
+#ifdef _DEBUG_MEMLEAKS
+#define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ )
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+#endif
+
+CMandarinAlphMgr::CMandarinAlphMgr(CDasherInterfaceBase *pInterface, CNodeCreationManager *pNCManager, CLanguageModel *pLanguageModel, CLanguageModel::Context iLearnContext)
+ : CAlphabetManager(pInterface, pNCManager, pLanguageModel, iLearnContext) {
+}
+
+CDasherNode *CMandarinAlphMgr::GetRoot(CDasherNode *pParent, int iLower, int iUpper, void *pUserData) {
+
+ CDasherNode *pNewNode = CAlphabetManager::GetRoot(pParent, iLower, iUpper, pUserData);
+ SAlphabetData *pNodeUserData = static_cast<SAlphabetData *>(pNewNode->m_pUserData);
+
+ //Override context for Mandarin Dasher
+ if (pParent){
+ CConversionManager::SConversionData *pParentConversionData = static_cast<CConversionManager::SConversionData *>(pParent->m_pUserData);
+ pNodeUserData->iContext = m_pLanguageModel->CloneContext(pParentConversionData->iContext);
+ }
+ else
+ pNodeUserData->iContext = m_pLanguageModel->CreateEmptyContext();
+
+ return pNewNode;
+}
+
+CDasherNode *CMandarinAlphMgr::CreateSymbolNode(CDasherNode *pParent, symbol iSymbol, unsigned int iLbnd, unsigned int iHbnd, symbol iExistingSymbol, CDasherNode *pExistingChild) {
+
+ if (iSymbol <= 1288) {
+ SAlphabetData *pParentData = static_cast<SAlphabetData *>(pParent->m_pUserData);
+
+ //Modified for Mandarin Dasher
+ //The following logic switch allows punctuation nodes in Mandarin to be treated in the same way as English (i.e. display and populate next round) instead of invoking a conversion node
+ CDasherNode *pNewNode = m_pNCManager->GetRoot(2, pParent, iLbnd, iHbnd, &(pParentData->iOffset));
+ static_cast<SAlphabetData *>(pNewNode->m_pUserData)->iSymbol = iSymbol;
+ return pNewNode;
+ }
+ return CAlphabetManager::CreateSymbolNode(pParent, iSymbol, iLbnd, iHbnd, iExistingSymbol, pExistingChild);
+}
+
+CLanguageModel::Context CMandarinAlphMgr::CreateSymbolContext(SAlphabetData *pParentData, symbol iSymbol)
+{
+ //Context carry-over. This code may worth looking at debug
+ return m_pLanguageModel->CloneContext(pParentData->iContext);
+}
+
+void CMandarinAlphMgr::SetFlag(CDasherNode *pNode, int iFlag, bool bValue) {
+ //disable learn-as-you-write for Mandarin Dasher
+ if (iFlag!=NF_COMMITTED) CAlphabetManager::SetFlag(pNode, iFlag, bValue);
+}
diff --git a/Src/DasherCore/MandarinAlphMgr.h b/Src/DasherCore/MandarinAlphMgr.h
new file mode 100644
index 0000000..29dab37
--- /dev/null
+++ b/Src/DasherCore/MandarinAlphMgr.h
@@ -0,0 +1,57 @@
+// MandarinAlphMgr.h
+//
+// Copyright (c) 2009 The Dasher Team
+//
+// This file is part of Dasher.
+//
+// Dasher 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 2 of the License, or
+// (at your option) any later version.
+//
+// Dasher 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 Dasher; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifndef __mandarinalphmgr_h__
+#define __mandarinalphmgr_h__
+
+#include "AlphabetManager.h"
+
+namespace Dasher {
+
+ class CDasherInterfaceBase;
+
+ /// \ingroup Model
+ /// @{
+
+ /// Overides methods of AlphabetManager for changes needed for Mandarin Dasher
+ ///
+ class CMandarinAlphMgr : public CAlphabetManager {
+ public:
+
+ CMandarinAlphMgr(CDasherInterfaceBase *pInterface, CNodeCreationManager *pNCManager, CLanguageModel *pLanguageModel, CLanguageModel::Context iLearnContext);
+
+ ///
+ /// Get a new root node owned by this manager
+ ///
+
+ virtual CDasherNode *GetRoot(CDasherNode *pParent, int iLower, int iUpper, void *pUserData);
+
+ virtual void SetFlag(CDasherNode *pNode, int iFlag, bool bValue);
+
+ protected:
+ virtual CDasherNode *CreateSymbolNode(CDasherNode *pParent, symbol iSymbol, unsigned int iLbnd, unsigned int iHbnd, symbol iExistingSymbol, CDasherNode *pExistingChild);
+ virtual CLanguageModel::Context CreateSymbolContext(SAlphabetData *pParentData, symbol iSymbol);
+ };
+ /// @}
+
+}
+
+
+#endif
diff --git a/gnome-doc-utils.make b/gnome-doc-utils.make
index b7ea210..147ab77 100644
--- a/gnome-doc-utils.make
+++ b/gnome-doc-utils.make
@@ -504,13 +504,14 @@ install-doc-docs:
install-doc-figs:
@list='$(patsubst C/%,%,$(_DOC_C_FIGURES))'; for fig in $$list; do \
for lc in C $(_DOC_REAL_LINGUAS); do \
- figsymlink=false; \
if test -f "$$lc/$$fig"; then \
figfile="$$lc/$$fig"; \
elif test -f "$(srcdir)/$$lc/$$fig"; then \
figfile="$(srcdir)/$$lc/$$fig"; \
+ elif test -f "C/$$fig"; then \
+ figfile="C/$$fig"; \
else \
- figsymlink=true; \
+ figfile="$(srcdir)/C/$$fig"; \
fi; \
figdir="$$lc/"`echo $$fig | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`; \
figdir="$(DESTDIR)$(HELP_DIR)/$(DOC_MODULE)/$$figdir"; \
@@ -519,13 +520,8 @@ install-doc-figs:
$(mkinstalldirs) "$$figdir"; \
fi; \
figbase=`echo $$fig | sed -e 's/^.*\///'`; \
- if $$figsymlink; then \
- echo "cd $$figdir && $(LN_S) -f ../../C/$$fig $$figbase"; \
- ( cd "$$figdir" && $(LN_S) -f "../../C/$$fig" "$$figbase" ); \
- else \
- echo "$(INSTALL_DATA) $$figfile $$figdir$$figbase"; \
- $(INSTALL_DATA) "$$figfile" "$$figdir$$figbase"; \
- fi; \
+ echo "$(INSTALL_DATA) $$figfile $$figdir$$figbase"; \
+ $(INSTALL_DATA) "$$figfile" "$$figdir$$figbase"; \
done; \
done
diff --git a/m4/gnome-doc-utils.m4 b/m4/gnome-doc-utils.m4
index 4aef712..04f79bb 100644
--- a/m4/gnome-doc-utils.m4
+++ b/m4/gnome-doc-utils.m4
@@ -36,8 +36,7 @@ AM_CONDITIONAL([HAVE_GNOME_DOC_UTILS],[test "$gdu_cv_have_gdu" = "yes"])
# GNOME_DOC_INIT ([MINIMUM-VERSION],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
#
AC_DEFUN([GNOME_DOC_INIT],
-[AC_REQUIRE([AC_PROG_LN_S])dnl
-
+[
ifelse([$1],,[gdu_cv_version_required=0.3.2],[gdu_cv_version_required=$1])
PKG_CHECK_EXISTS([gnome-doc-utils >= $gdu_cv_version_required],
diff --git a/m4/intltool.m4 b/m4/intltool.m4
index 122d773..f27ec0f 100644
--- a/m4/intltool.m4
+++ b/m4/intltool.m4
@@ -23,10 +23,9 @@
## the same distribution terms that you use for the rest of that program.
dnl IT_PROG_INTLTOOL([MINIMUM-VERSION], [no-xml])
-# serial 40 IT_PROG_INTLTOOL
-AC_DEFUN([IT_PROG_INTLTOOL], [
-AC_PREREQ([2.50])dnl
-AC_REQUIRE([AM_NLS])dnl
+# serial 36 IT_PROG_INTLTOOL
+AC_DEFUN([IT_PROG_INTLTOOL],
+[AC_PREREQ([2.50])dnl
case "$am__api_version" in
1.[01234])
@@ -40,21 +39,14 @@ if test -n "$1"; then
AC_MSG_CHECKING([for intltool >= $1])
INTLTOOL_REQUIRED_VERSION_AS_INT=`echo $1 | awk -F. '{ print $ 1 * 1000 + $ 2 * 100 + $ 3; }'`
- INTLTOOL_APPLIED_VERSION=`intltool-update --version | head -1 | cut -d" " -f3`
- [INTLTOOL_APPLIED_VERSION_AS_INT=`echo $INTLTOOL_APPLIED_VERSION | awk -F. '{ print $ 1 * 1000 + $ 2 * 100 + $ 3; }'`
+ INTLTOOL_APPLIED_VERSION=`awk -F\" '/\\$VERSION / { print $ 2; }' ${ac_aux_dir}/intltool-update.in`
+ [INTLTOOL_APPLIED_VERSION_AS_INT=`awk -F\" '/\\$VERSION / { split($ 2, VERSION, "."); print VERSION[1] * 1000 + VERSION[2] * 100 + VERSION[3];}' ${ac_aux_dir}/intltool-update.in`
]
AC_MSG_RESULT([$INTLTOOL_APPLIED_VERSION found])
test "$INTLTOOL_APPLIED_VERSION_AS_INT" -ge "$INTLTOOL_REQUIRED_VERSION_AS_INT" ||
AC_MSG_ERROR([Your intltool is too old. You need intltool $1 or later.])
fi
-AC_PATH_PROG(INTLTOOL_UPDATE, [intltool-update])
-AC_PATH_PROG(INTLTOOL_MERGE, [intltool-merge])
-AC_PATH_PROG(INTLTOOL_EXTRACT, [intltool-extract])
-if test -z "$INTLTOOL_UPDATE" -o -z "$INTLTOOL_MERGE" -o -z "$INTLTOOL_EXTRACT"; then
- AC_MSG_ERROR([The intltool scripts were not found. Please install intltool.])
-fi
-
INTLTOOL_DESKTOP_RULE='%.desktop: %.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
INTLTOOL_DIRECTORY_RULE='%.directory: %.directory.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
INTLTOOL_KEYS_RULE='%.keys: %.keys.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -k -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
@@ -75,31 +67,30 @@ INTLTOOL_SOUNDLIST_RULE='%.soundlist: %.soundlist.in $(INTLTOOL_MERGE) $(wildcar
INTLTOOL_SERVICE_RULE='%.service: %.service.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
INTLTOOL_POLICY_RULE='%.policy: %.policy.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
-_IT_SUBST(INTLTOOL_DESKTOP_RULE)
-_IT_SUBST(INTLTOOL_DIRECTORY_RULE)
-_IT_SUBST(INTLTOOL_KEYS_RULE)
-_IT_SUBST(INTLTOOL_PROP_RULE)
-_IT_SUBST(INTLTOOL_OAF_RULE)
-_IT_SUBST(INTLTOOL_PONG_RULE)
-_IT_SUBST(INTLTOOL_SERVER_RULE)
-_IT_SUBST(INTLTOOL_SHEET_RULE)
-_IT_SUBST(INTLTOOL_SOUNDLIST_RULE)
-_IT_SUBST(INTLTOOL_UI_RULE)
-_IT_SUBST(INTLTOOL_XAM_RULE)
-_IT_SUBST(INTLTOOL_KBD_RULE)
-_IT_SUBST(INTLTOOL_XML_RULE)
-_IT_SUBST(INTLTOOL_XML_NOMERGE_RULE)
-_IT_SUBST(INTLTOOL_CAVES_RULE)
-_IT_SUBST(INTLTOOL_SCHEMAS_RULE)
-_IT_SUBST(INTLTOOL_THEME_RULE)
-_IT_SUBST(INTLTOOL_SERVICE_RULE)
-_IT_SUBST(INTLTOOL_POLICY_RULE)
+AC_SUBST(INTLTOOL_DESKTOP_RULE)
+AC_SUBST(INTLTOOL_DIRECTORY_RULE)
+AC_SUBST(INTLTOOL_KEYS_RULE)
+AC_SUBST(INTLTOOL_PROP_RULE)
+AC_SUBST(INTLTOOL_OAF_RULE)
+AC_SUBST(INTLTOOL_PONG_RULE)
+AC_SUBST(INTLTOOL_SERVER_RULE)
+AC_SUBST(INTLTOOL_SHEET_RULE)
+AC_SUBST(INTLTOOL_SOUNDLIST_RULE)
+AC_SUBST(INTLTOOL_UI_RULE)
+AC_SUBST(INTLTOOL_XAM_RULE)
+AC_SUBST(INTLTOOL_KBD_RULE)
+AC_SUBST(INTLTOOL_XML_RULE)
+AC_SUBST(INTLTOOL_XML_NOMERGE_RULE)
+AC_SUBST(INTLTOOL_CAVES_RULE)
+AC_SUBST(INTLTOOL_SCHEMAS_RULE)
+AC_SUBST(INTLTOOL_THEME_RULE)
+AC_SUBST(INTLTOOL_SERVICE_RULE)
+AC_SUBST(INTLTOOL_POLICY_RULE)
# Check the gettext tools to make sure they are GNU
AC_PATH_PROG(XGETTEXT, xgettext)
AC_PATH_PROG(MSGMERGE, msgmerge)
AC_PATH_PROG(MSGFMT, msgfmt)
-AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
if test -z "$XGETTEXT" -o -z "$MSGMERGE" -o -z "$MSGFMT"; then
AC_MSG_ERROR([GNU gettext tools not found; required for intltool])
fi
@@ -110,17 +101,17 @@ if test -z "$xgversion" -o -z "$mmversion" -o -z "$mfversion"; then
AC_MSG_ERROR([GNU gettext tools not found; required for intltool])
fi
+# Use the tools built into the package, not the ones that are installed.
+AC_SUBST(INTLTOOL_EXTRACT, '$(top_builddir)/intltool-extract')
+AC_SUBST(INTLTOOL_MERGE, '$(top_builddir)/intltool-merge')
+AC_SUBST(INTLTOOL_UPDATE, '$(top_builddir)/intltool-update')
+
AC_PATH_PROG(INTLTOOL_PERL, perl)
if test -z "$INTLTOOL_PERL"; then
- AC_MSG_ERROR([perl not found])
+ AC_MSG_ERROR([perl not found; required for intltool])
fi
-AC_MSG_CHECKING([for perl >= 5.8.1])
-$INTLTOOL_PERL -e "use 5.8.1;" > /dev/null 2>&1
-if test $? -ne 0; then
- AC_MSG_ERROR([perl 5.8.1 is required for intltool])
-else
- IT_PERL_VERSION="`$INTLTOOL_PERL -e \"printf '%vd', $^V\"`"
- AC_MSG_RESULT([$IT_PERL_VERSION])
+if test -z "`$INTLTOOL_PERL -v | fgrep '5.' 2> /dev/null`"; then
+ AC_MSG_ERROR([perl 5.x required for intltool])
fi
if test "x$2" != "xno-xml"; then
AC_MSG_CHECKING([for XML::Parser])
@@ -161,6 +152,42 @@ AC_SUBST(DATADIRNAME)
IT_PO_SUBDIR([po])
+dnl The following is very similar to
+dnl
+dnl AC_CONFIG_FILES([intltool-extract intltool-merge intltool-update])
+dnl
+dnl with the following slight differences:
+dnl - the *.in files are in ac_aux_dir,
+dnl - if the file haven't changed upon reconfigure, it's not touched,
+dnl - the evaluation of the third parameter enables a hack which computes
+dnl the actual value of $libdir,
+dnl - the user sees "executing intltool commands", instead of
+dnl "creating intltool-extract" and such.
+dnl
+dnl Nothing crucial here, and we could use AC_CONFIG_FILES, if there were
+dnl a reason for it.
+
+AC_CONFIG_COMMANDS([intltool], [
+
+for file in intltool-extract intltool-merge intltool-update; do
+ sed -e "s|@INTLTOOL_EXTRACT@|`pwd`/intltool-extract|g" \
+ -e "s|@INTLTOOL_LIBDIR@|${INTLTOOL_LIBDIR}|g" \
+ -e "s|@INTLTOOL_PERL@|${INTLTOOL_PERL}|g" \
+ < ${ac_aux_dir}/${file}.in > ${file}.out
+ if cmp -s ${file} ${file}.out 2>/dev/null; then
+ rm -f ${file}.out
+ else
+ mv -f ${file}.out ${file}
+ fi
+ chmod ugo+x ${file}
+ chmod u+w ${file}
+done
+
+],
+[INTLTOOL_PERL='${INTLTOOL_PERL}' ac_aux_dir='${ac_aux_dir}'
+prefix="$prefix" exec_prefix="$exec_prefix" INTLTOOL_LIBDIR="$libdir"
+INTLTOOL_EXTRACT='${INTLTOOL_EXTRACT}'])
+
])
@@ -176,9 +203,6 @@ dnl The following CONFIG_COMMANDS should be exetuted at the very end
dnl of config.status.
AC_CONFIG_COMMANDS_PRE([
AC_CONFIG_COMMANDS([$1/stamp-it], [
- if [ ! grep "^# INTLTOOL_MAKEFILE$" "$1/Makefile.in" > /dev/null ]; then
- AC_MSG_ERROR([$1/Makefile.in.in was not created by intltoolize.])
- fi
rm -f "$1/stamp-it" "$1/stamp-it.tmp" "$1/POTFILES" "$1/Makefile.tmp"
>"$1/stamp-it.tmp"
[sed '/^#/d
@@ -187,27 +211,21 @@ AC_CONFIG_COMMANDS_PRE([
'"s|^| $ac_top_srcdir/|" \
"$srcdir/$1/POTFILES.in" | sed '$!s/$/ \\/' >"$1/POTFILES"
]
+ if test ! -f "$1/Makefile"; then
+ AC_MSG_ERROR([$1/Makefile is not ready.])
+ fi
+ mv "$1/Makefile" "$1/Makefile.tmp"
[sed '/^POTFILES =/,/[^\\]$/ {
/^POTFILES =/!d
r $1/POTFILES
}
- ' "$1/Makefile.in" >"$1/Makefile"]
+ ' "$1/Makefile.tmp" >"$1/Makefile"]
rm -f "$1/Makefile.tmp"
mv "$1/stamp-it.tmp" "$1/stamp-it"
])
])dnl
])
-# _IT_SUBST(VARIABLE)
-# -------------------
-# Abstract macro to do either _AM_SUBST_NOTMAKE or AC_SUBST
-#
-AC_DEFUN([_IT_SUBST],
-[
-AC_SUBST([$1])
-m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([$1])])
-]
-)
# deprecated macros
AU_ALIAS([AC_PROG_INTLTOOL], [IT_PROG_INTLTOOL])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]