Commit 4db2960c authored by coppro's avatar coppro

Compatibility updates; Boost Regex is now statically linked, changed to <hunspell/hunspell.hxx>

parent 2112c8df
...@@ -13,9 +13,11 @@ AUTOMAKE_OPTIONS = subdir-objects ...@@ -13,9 +13,11 @@ AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = magicseteditor bin_PROGRAMS = magicseteditor
AM_CXXFLAGS = @WX_CXXFLAGS@ \$(BOOST_CXXFLAGS) -DUNICODE -I . -Wall AM_CXXFLAGS = @WX_CXXFLAGS@ \$(BOOST_CXXFLAGS) -DUNICODE -I . -Wall
AM_LDFLAGS = @WX_LIBS@ \$(BOOST_LDFLAGS) \$(BOOST_REGEX_LIB) AM_LDFLAGS = @WX_LIBS@ \$(BOOST_LDFLAGS)
magicseteditor_SOURCES = magicseteditor_LDADD = \$(BOOST_REGEX_LIB)
magicseteditor_SOURCES =
# The script used to generate is MakeAM.sh " > Makefile.am; # The script used to generate is MakeAM.sh " > Makefile.am;
......
...@@ -205,7 +205,8 @@ am_magicseteditor_OBJECTS = ./src/util/version.$(OBJEXT) \ ...@@ -205,7 +205,8 @@ am_magicseteditor_OBJECTS = ./src/util/version.$(OBJEXT) \
./src/cli/text_io_handler.$(OBJEXT) \ ./src/cli/text_io_handler.$(OBJEXT) \
./src/code_template.$(OBJEXT) ./src/code_template.$(OBJEXT)
magicseteditor_OBJECTS = $(am_magicseteditor_OBJECTS) magicseteditor_OBJECTS = $(am_magicseteditor_OBJECTS)
magicseteditor_LDADD = $(LDADD) am__DEPENDENCIES_1 =
magicseteditor_DEPENDENCIES = $(am__DEPENDENCIES_1)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles am__depfiles_maybe = depfiles
...@@ -334,9 +335,10 @@ top_srcdir = @top_srcdir@ ...@@ -334,9 +335,10 @@ top_srcdir = @top_srcdir@
# This flag allows us to use subdirectories: # This flag allows us to use subdirectories:
AUTOMAKE_OPTIONS = subdir-objects AUTOMAKE_OPTIONS = subdir-objects
AM_CXXFLAGS = @WX_CXXFLAGS@ $(BOOST_CXXFLAGS) -DUNICODE -I . -Wall AM_CXXFLAGS = @WX_CXXFLAGS@ $(BOOST_CXXFLAGS) -DUNICODE -I . -Wall
AM_LDFLAGS = @WX_LIBS@ $(BOOST_LDFLAGS) $(BOOST_REGEX_LIB) AM_LDFLAGS = @WX_LIBS@ $(BOOST_LDFLAGS)
magicseteditor_LDADD = $(BOOST_REGEX_LIB)
# The script used to generate is MakeAM.sh # The script used to generate is MakeAM.sh
magicseteditor_SOURCES = ./src/util/version.cpp \ magicseteditor_SOURCES = ./src/util/version.cpp \
./src/util/alignment.cpp ./src/util/rotation.cpp \ ./src/util/alignment.cpp ./src/util/rotation.cpp \
./src/util/tagged_string.cpp ./src/util/spell_checker.cpp \ ./src/util/tagged_string.cpp ./src/util/spell_checker.cpp \
......
This diff is collapsed.
...@@ -18,10 +18,12 @@ AC_PROG_CXX ...@@ -18,10 +18,12 @@ AC_PROG_CXX
# Do not pass -O2, because that causes failures for now. # Do not pass -O2, because that causes failures for now.
CXXFLAGS=-g CXXFLAGS=-g
# Checks for libraries. # Checks for libraries.
AC_CHECK_LIB([hunspell],[Hunspell_create])
# Check for Boost # Check for Boost
AX_BOOST_BASE([1.36.0]) AX_BOOST_BASE([1.37.0])
AX_BOOST_REGEX AX_BOOST_REGEX
BOOST_REGEX_LIB="-Wl,-Bstatic $BOOST_REGEX_LIB -Wl,-Bdynamic"
# Check for wxWidgets # Check for wxWidgets
AM_OPTIONS_WXCONFIG AM_OPTIONS_WXCONFIG
......
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
#include <script/script.hpp> #include <script/script.hpp>
#include <script/context.hpp> #include <script/context.hpp>
#ifndef USE_SCRIPT_PROFILING
#define USE_SCRIPT_PROFILING 1 #define USE_SCRIPT_PROFILING 1
#endif
#if USE_SCRIPT_PROFILING #if USE_SCRIPT_PROFILING
...@@ -23,7 +25,7 @@ DECLARE_POINTER_TYPE(FunctionProfile); ...@@ -23,7 +25,7 @@ DECLARE_POINTER_TYPE(FunctionProfile);
#ifdef WIN32 #ifdef WIN32
typedef LONGLONG ProfileTime; typedef LONGLONG ProfileTime;
inline ProfileTime timer_now() { inline ProfileTime timer_now() {
LARGE_INTEGER i; LARGE_INTEGER i;
QueryPerformanceCounter(&i); QueryPerformanceCounter(&i);
...@@ -34,17 +36,25 @@ DECLARE_POINTER_TYPE(FunctionProfile); ...@@ -34,17 +36,25 @@ DECLARE_POINTER_TYPE(FunctionProfile);
QueryPerformanceFrequency(&i); QueryPerformanceFrequency(&i);
return i.QuadPart; return i.QuadPart;
} }
inline const char * mangled_name(const type_info& t) {
return t.raw_name();
}
#else #else
// clock() has nanosecond resolution on Linux // clock() has nanosecond resolution on Linux
// on any other platform, stil the best way. // on any other platform, stil the best way.
typedef clock_t ProfileTime; typedef clock_t ProfileTime;
inline ProfileTime timer_now() { inline ProfileTime timer_now() {
return clock(); return clock();
} }
inline ProfileTime timer_resolution() { inline ProfileTime timer_resolution() {
return CLOCKS_PER_SEC; return CLOCKS_PER_SEC;
} }
inline const char * mangled_name(const type_info& t) {
return t.name();
}
#endif #endif
/// Simple execution timer /// Simple execution timer
...@@ -66,17 +76,17 @@ class Timer { ...@@ -66,17 +76,17 @@ class Timer {
class FunctionProfile : public IntrusivePtrBase<FunctionProfile> { class FunctionProfile : public IntrusivePtrBase<FunctionProfile> {
public: public:
FunctionProfile(const String& name) : name(name), time_ticks(0), calls(0) {} FunctionProfile(const String& name) : name(name), time_ticks(0), calls(0) {}
String name; String name;
ProfileTime time_ticks; ProfileTime time_ticks;
UInt calls; UInt calls;
/// for each id, called children /// for each id, called children
/** we (ab)use the fact that all pointers are even to store both pointers and ids */ /** we (ab)use the fact that all pointers are even to store both pointers and ids */
map<size_t,FunctionProfileP> children; map<size_t,FunctionProfileP> children;
/// The children, sorted by time /// The children, sorted by time
void get_children(vector<FunctionProfileP>& out) const; void get_children(vector<FunctionProfileP>& out) const;
/// Time in seconds /// Time in seconds
inline double time() const { return time_ticks / (double)timer_resolution(); } inline double time() const { return time_ticks / (double)timer_resolution(); }
inline double avg_time() const { return time() / calls; } inline double avg_time() const { return time() / calls; }
......
...@@ -69,9 +69,9 @@ template <typename T> inline String to_code(const intrusive_ptr<T>& p) { ...@@ -69,9 +69,9 @@ template <typename T> inline String to_code(const intrusive_ptr<T>& p) {
class ScriptDelayedError : public ScriptValue { class ScriptDelayedError : public ScriptValue {
public: public:
inline ScriptDelayedError(const ScriptError& error) : error(error) {} inline ScriptDelayedError(const ScriptError& error) : error(error) {}
virtual ScriptType type() const;// { return SCRIPT_ERROR; } virtual ScriptType type() const;// { return SCRIPT_ERROR; }
// all of these throw // all of these throw
virtual String typeName() const; virtual String typeName() const;
virtual operator String() const; virtual operator String() const;
...@@ -105,7 +105,7 @@ struct ScriptIterator : public ScriptValue { ...@@ -105,7 +105,7 @@ struct ScriptIterator : public ScriptValue {
virtual ScriptType type() const;// { return SCRIPT_ITERATOR; } virtual ScriptType type() const;// { return SCRIPT_ITERATOR; }
virtual String typeName() const;// { return "iterator"; } virtual String typeName() const;// { return "iterator"; }
virtual CompareWhat compareAs(String&, void const*&) const; // { return COMPARE_NO; } virtual CompareWhat compareAs(String&, void const*&) const; // { return COMPARE_NO; }
/// Return the next item for this iterator, or ScriptValueP() if there is no such item /// Return the next item for this iterator, or ScriptValueP() if there is no such item
virtual ScriptValueP next(ScriptValueP* key_out = nullptr) = 0; virtual ScriptValueP next(ScriptValueP* key_out = nullptr) = 0;
virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const; virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const;
...@@ -128,7 +128,7 @@ class ScriptCollectionBase : public ScriptValue { ...@@ -128,7 +128,7 @@ class ScriptCollectionBase : public ScriptValue {
// Iterator over a collection // Iterator over a collection
template <typename Collection> template <typename Collection>
class ScriptCollectionIterator : public ScriptIterator { class ScriptCollectionIterator : public ScriptIterator {
public: public:
ScriptCollectionIterator(const Collection* col) : pos(0), col(col) {} ScriptCollectionIterator(const Collection* col) : pos(0), col(col) {}
virtual ScriptValueP next(ScriptValueP* key_out) { virtual ScriptValueP next(ScriptValueP* key_out) {
if (pos < col->size()) { if (pos < col->size()) {
...@@ -231,7 +231,7 @@ class ScriptCustomCollection : public ScriptCollectionBase { ...@@ -231,7 +231,7 @@ class ScriptCustomCollection : public ScriptCollectionBase {
compare_ptr = this; compare_ptr = this;
return COMPARE_AS_POINTER; return COMPARE_AS_POINTER;
} }
/// The collection as a list (contains only the values that don't have a key) /// The collection as a list (contains only the values that don't have a key)
vector<ScriptValueP> value; vector<ScriptValueP> value;
/// The collection as a map (contains only the values that have a key) /// The collection as a map (contains only the values that have a key)
...@@ -255,7 +255,7 @@ class ScriptConcatCollection : public ScriptCollectionBase { ...@@ -255,7 +255,7 @@ class ScriptConcatCollection : public ScriptCollectionBase {
compare_ptr = this; compare_ptr = this;
return COMPARE_AS_POINTER; return COMPARE_AS_POINTER;
} }
private: private:
ScriptValueP a,b; ScriptValueP a,b;
friend class ScriptConcatCollectionIterator; friend class ScriptConcatCollectionIterator;
...@@ -282,7 +282,7 @@ class ScriptObject : public ScriptValue { ...@@ -282,7 +282,7 @@ class ScriptObject : public ScriptValue {
virtual ScriptValueP getMember(const String& name) const { virtual ScriptValueP getMember(const String& name) const {
#if USE_SCRIPT_PROFILING #if USE_SCRIPT_PROFILING
Timer t; Timer t;
Profiler prof(t, (void*)typeid(T).raw_name(), _("get member of ") + type_name(*value)); Profiler prof(t, (void*)mangled_name(typeid(T)), _("get member of ") + type_name(*value));
#endif #endif
GetMember gm(name); GetMember gm(name);
gm.handle(*value); gm.handle(*value);
...@@ -346,25 +346,25 @@ class ScriptObject : public ScriptValue { ...@@ -346,25 +346,25 @@ class ScriptObject : public ScriptValue {
class ScriptClosure : public ScriptValue { class ScriptClosure : public ScriptValue {
public: public:
ScriptClosure(ScriptValueP fun) : fun(fun) {} ScriptClosure(ScriptValueP fun) : fun(fun) {}
virtual ScriptType type() const; virtual ScriptType type() const;
virtual String typeName() const; virtual String typeName() const;
virtual ScriptValueP eval(Context& ctx) const; virtual ScriptValueP eval(Context& ctx) const;
virtual ScriptValueP dependencies(Context& ctx, const Dependency& dep) const; virtual ScriptValueP dependencies(Context& ctx, const Dependency& dep) const;
/// Add a binding /// Add a binding
void addBinding(Variable v, const ScriptValueP& value); void addBinding(Variable v, const ScriptValueP& value);
/// Is there a binding for the given variable? If so, retrieve it /// Is there a binding for the given variable? If so, retrieve it
ScriptValueP getBinding(Variable v) const; ScriptValueP getBinding(Variable v) const;
/// Try to simplify this closure, returns a value if successful /// Try to simplify this closure, returns a value if successful
ScriptValueP simplify(); ScriptValueP simplify();
/// The wrapped function /// The wrapped function
ScriptValueP fun; ScriptValueP fun;
/// The default argument bindings /// The default argument bindings
vector<pair<Variable,ScriptValueP> > bindings; vector<pair<Variable,ScriptValueP> > bindings;
private: private:
/// Apply the bindings in a context /// Apply the bindings in a context
void applyBindings(Context& ctx) const; void applyBindings(Context& ctx) const;
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
//| License: GNU General Public License 2 or later (see file COPYING) | //| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+ //+----------------------------------------------------------------------------+
#ifndef HEADER_UTIL_SPELL_CHECKER #ifndef HEADER_UTIL_SPELL_CHECKER
#define HEADER_UTIL_SPELL_CHECKER #define HEADER_UTIL_SPELL_CHECKER
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp> #include <util/prec.hpp>
#include "hunspell.hxx" #include "hunspell/hunspell.hxx"
DECLARE_POINTER_TYPE(SpellChecker); DECLARE_POINTER_TYPE(SpellChecker);
...@@ -33,20 +33,20 @@ class SpellChecker : public Hunspell, public IntrusivePtrBase<SpellChecker> { ...@@ -33,20 +33,20 @@ class SpellChecker : public Hunspell, public IntrusivePtrBase<SpellChecker> {
static SpellChecker& get(const String& filename, const String& language); static SpellChecker& get(const String& filename, const String& language);
/// Destroy all cached SpellChecker objects /// Destroy all cached SpellChecker objects
static void destroyAll(); static void destroyAll();
/// Check the spelling of a single word /// Check the spelling of a single word
bool spell(const String& word); bool spell(const String& word);
/// Check the spelling of a single word, ignore punctuation /// Check the spelling of a single word, ignore punctuation
bool spell_with_punctuation(const String& word); bool spell_with_punctuation(const String& word);
/// Give spelling suggestions /// Give spelling suggestions
void suggest(const String& word, vector<String>& suggestions_out); void suggest(const String& word, vector<String>& suggestions_out);
private: private:
/// Convert between String and dictionary encoding /// Convert between String and dictionary encoding
wxCSConv encoding; wxCSConv encoding;
bool convert_encoding(const String& word, CharBuffer& out); bool convert_encoding(const String& word, CharBuffer& out);
SpellChecker(const char* aff_path, const char* dic_path); SpellChecker(const char* aff_path, const char* dic_path);
static map<String,SpellCheckerP> spellers; //< Cached checkers for each language static map<String,SpellCheckerP> spellers; //< Cached checkers for each language
}; };
......
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