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

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1286 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
coppro
2009-01-02 21:52:08 +00:00
parent ab5ea48a9d
commit 46dda0ef30
7 changed files with 397 additions and 309 deletions
+15 -5
View File
@@ -13,7 +13,9 @@
#include <script/script.hpp>
#include <script/context.hpp>
#ifndef USE_SCRIPT_PROFILING
#define USE_SCRIPT_PROFILING 1
#endif
#if USE_SCRIPT_PROFILING
@@ -23,7 +25,7 @@ DECLARE_POINTER_TYPE(FunctionProfile);
#ifdef WIN32
typedef LONGLONG ProfileTime;
inline ProfileTime timer_now() {
LARGE_INTEGER i;
QueryPerformanceCounter(&i);
@@ -34,17 +36,25 @@ DECLARE_POINTER_TYPE(FunctionProfile);
QueryPerformanceFrequency(&i);
return i.QuadPart;
}
inline const char * mangled_name(const type_info& t) {
return t.raw_name();
}
#else
// clock() has nanosecond resolution on Linux
// on any other platform, stil the best way.
typedef clock_t ProfileTime;
inline ProfileTime timer_now() {
return clock();
}
inline ProfileTime timer_resolution() {
return CLOCKS_PER_SEC;
}
inline const char * mangled_name(const type_info& t) {
return t.name();
}
#endif
/// Simple execution timer
@@ -66,17 +76,17 @@ class Timer {
class FunctionProfile : public IntrusivePtrBase<FunctionProfile> {
public:
FunctionProfile(const String& name) : name(name), time_ticks(0), calls(0) {}
String name;
ProfileTime time_ticks;
UInt calls;
/// for each id, called children
/** we (ab)use the fact that all pointers are even to store both pointers and ids */
map<size_t,FunctionProfileP> children;
/// The children, sorted by time
void get_children(vector<FunctionProfileP>& out) const;
/// Time in seconds
inline double time() const { return time_ticks / (double)timer_resolution(); }
inline double avg_time() const { return time() / calls; }
+12 -12
View File
@@ -69,9 +69,9 @@ template <typename T> inline String to_code(const intrusive_ptr<T>& p) {
class ScriptDelayedError : public ScriptValue {
public:
inline ScriptDelayedError(const ScriptError& error) : error(error) {}
virtual ScriptType type() const;// { return SCRIPT_ERROR; }
// all of these throw
virtual String typeName() const;
virtual operator String() const;
@@ -105,7 +105,7 @@ struct ScriptIterator : public ScriptValue {
virtual ScriptType type() const;// { return SCRIPT_ITERATOR; }
virtual String typeName() const;// { return "iterator"; }
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
virtual ScriptValueP next(ScriptValueP* key_out = nullptr) = 0;
virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const;
@@ -128,7 +128,7 @@ class ScriptCollectionBase : public ScriptValue {
// Iterator over a collection
template <typename Collection>
class ScriptCollectionIterator : public ScriptIterator {
public:
public:
ScriptCollectionIterator(const Collection* col) : pos(0), col(col) {}
virtual ScriptValueP next(ScriptValueP* key_out) {
if (pos < col->size()) {
@@ -231,7 +231,7 @@ class ScriptCustomCollection : public ScriptCollectionBase {
compare_ptr = this;
return COMPARE_AS_POINTER;
}
/// The collection as a list (contains only the values that don't have a key)
vector<ScriptValueP> value;
/// The collection as a map (contains only the values that have a key)
@@ -255,7 +255,7 @@ class ScriptConcatCollection : public ScriptCollectionBase {
compare_ptr = this;
return COMPARE_AS_POINTER;
}
private:
ScriptValueP a,b;
friend class ScriptConcatCollectionIterator;
@@ -282,7 +282,7 @@ class ScriptObject : public ScriptValue {
virtual ScriptValueP getMember(const String& name) const {
#if USE_SCRIPT_PROFILING
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
GetMember gm(name);
gm.handle(*value);
@@ -346,25 +346,25 @@ class ScriptObject : public ScriptValue {
class ScriptClosure : public ScriptValue {
public:
ScriptClosure(ScriptValueP fun) : fun(fun) {}
virtual ScriptType type() const;
virtual String typeName() const;
virtual ScriptValueP eval(Context& ctx) const;
virtual ScriptValueP dependencies(Context& ctx, const Dependency& dep) const;
/// Add a binding
void addBinding(Variable v, const ScriptValueP& value);
/// Is there a binding for the given variable? If so, retrieve it
ScriptValueP getBinding(Variable v) const;
/// Try to simplify this closure, returns a value if successful
ScriptValueP simplify();
/// The wrapped function
ScriptValueP fun;
/// The default argument bindings
vector<pair<Variable,ScriptValueP> > bindings;
private:
/// Apply the bindings in a context
void applyBindings(Context& ctx) const;