Commit e3abdb69 authored by coppro's avatar coppro

(sorry for making this all one commit)

Fiddled with the backbone for scripts some more.
VCS are now suppported in sets but configuration/non-svn-systems missing
Linux build now uses precompiled headers (build time--)
A couple warning fixes too.
parent a5ee2b69
rm Makefile.am; rm Makefile.am;
echo " echo '
#+----------------------------------------------------------------------------+ #+----------------------------------------------------------------------------+
#| Description: Magic Set Editor - Program to make Magic (tm) cards | #| Description: Magic Set Editor - Program to make Magic (tm) cards |
#| Copyright: (C) 2001 - 2008 Twan van Laarhoven and \"coppro\" | #| Copyright: (C) 2001 - 2008 Twan van Laarhoven and "coppro" |
#| License: GNU General Public License 2 or later (see file COPYING) | #| License: GNU General Public License 2 or later (see file COPYING) |
#+----------------------------------------------------------------------------+ #+----------------------------------------------------------------------------+
...@@ -12,13 +12,30 @@ echo " ...@@ -12,13 +12,30 @@ echo "
AUTOMAKE_OPTIONS = subdir-objects 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) AM_LDFLAGS = @WX_LIBS@ $(BOOST_LDFLAGS)
magicseteditor_LDADD = \$(BOOST_REGEX_LIB) .hpp.gch:
target=`echo $@ | sed "s|.gch$$|.hpp|"`;\
depbase=`echo $$target | sed "s|[^/]*\$$|$(DEPDIR)/&|;s|\\.hpp\$$||"`;\
$(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpch -c $$target &&\
$(am__mv) $$depbase.Tpch $$depbase.Pch
touch $@
.gch.o:
gcc -x c - -c -o $@ <<<""
magicseteditor_SOURCES = magicseteditor_LDADD = $(BOOST_REGEX_LIB)
magicseteditor_CXXFLAGS = -fpch-deps $(AM_CXXFLAGS)
magicseteditor_SOURCES =
# The script used to generate is MakeAM.sh " > Makefile.am; if GLIBCPP_BUILD_PCH
clean-local:
rm -f ./src/util/prec.hpp.gch
rm -f ./src/util/prec.gch
include ./src/util/$(DEPDIR)/prec.Pch
magicseteditor_SOURCES += ./src/util/prec.gch
endif
# The script used to generate is MakeAM.sh' > Makefile.am;
find . -name *.cpp | sed "s/\./magicseteditor_SOURCES += ./" >> Makefile.am; find . -name *.cpp | sed "s/\./magicseteditor_SOURCES += ./" >> Makefile.am;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -598,6 +598,8 @@ LIBOBJS ...@@ -598,6 +598,8 @@ LIBOBJS
EGREP EGREP
GREP GREP
CPP CPP
GLIBCPP_BUILD_PCH_FALSE
GLIBCPP_BUILD_PCH_TRUE
WX_RESCOMP WX_RESCOMP
WX_VERSION WX_VERSION
WX_LIBS_STATIC WX_LIBS_STATIC
...@@ -4910,6 +4912,17 @@ if test "${HAVE_WX}" != 1; then ...@@ -4910,6 +4912,17 @@ if test "${HAVE_WX}" != 1; then
" "$LINENO" 5 " "$LINENO" 5
fi fi
# Check for precompiled headers
# TODO: Deal with braindead GCC and actually check
if test "x$CXX" = "xg++"; then
GLIBCPP_BUILD_PCH_TRUE=
GLIBCPP_BUILD_PCH_FALSE='#'
else
GLIBCPP_BUILD_PCH_TRUE='#'
GLIBCPP_BUILD_PCH_FALSE=
fi
# Checks for header files. # Checks for header files.
# Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics.
...@@ -5813,6 +5826,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then ...@@ -5813,6 +5826,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
as_fn_error "conditional \"am__fastdepCC\" was never defined. as_fn_error "conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5 Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi fi
if test -z "${GLIBCPP_BUILD_PCH_TRUE}" && test -z "${GLIBCPP_BUILD_PCH_FALSE}"; then
as_fn_error "conditional \"GLIBCPP_BUILD_PCH\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
: ${CONFIG_STATUS=./config.status} : ${CONFIG_STATUS=./config.status}
ac_write_fail=0 ac_write_fail=0
......
...@@ -11,7 +11,7 @@ AC_CONFIG_SRCDIR([src/main.cpp]) ...@@ -11,7 +11,7 @@ AC_CONFIG_SRCDIR([src/main.cpp])
# TODO: Actually use the config header # TODO: Actually use the config header
AC_CONFIG_HEADER([src/config.h]) AC_CONFIG_HEADER([src/config.h])
AM_INIT_AUTOMAKE([-Wall foreign]) AM_INIT_AUTOMAKE([foreign])
# Checks for programs. # Checks for programs.
if test -n "${CXXFLAGS}"; then if test -n "${CXXFLAGS}"; then
...@@ -56,6 +56,10 @@ if test "${HAVE_WX}" != 1; then ...@@ -56,6 +56,10 @@ if test "${HAVE_WX}" != 1; then
]) ])
fi fi
# Check for precompiled headers
# TODO: Deal with braindead GCC and actually check
AM_CONDITIONAL(GLIBCPP_BUILD_PCH, test "x$CXX" = "xg++")
# Checks for header files. # Checks for header files.
# Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics.
......
...@@ -79,6 +79,9 @@ ...@@ -79,6 +79,9 @@
/* Define to the one symbol short name of this package. */ /* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME #undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */ /* Define to the version of this package. */
#undef PACKAGE_VERSION #undef PACKAGE_VERSION
......
...@@ -29,11 +29,13 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA ValueP>); ...@@ -29,11 +29,13 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA ValueP>);
Set::Set() Set::Set()
: script_manager(new SetScriptManager(*this)) : script_manager(new SetScriptManager(*this))
, vcs (new_intrusive<VCS>())
{} {}
Set::Set(const GameP& game) Set::Set(const GameP& game)
: game(game) : game(game)
, script_manager(new SetScriptManager(*this)) , script_manager(new SetScriptManager(*this))
, vcs (new_intrusive<VCS>())
{ {
data.init(game->set_fields); data.init(game->set_fields);
} }
...@@ -42,6 +44,7 @@ Set::Set(const StyleSheetP& stylesheet) ...@@ -42,6 +44,7 @@ Set::Set(const StyleSheetP& stylesheet)
: game(stylesheet->game) : game(stylesheet->game)
, stylesheet(stylesheet) , stylesheet(stylesheet)
, script_manager(new SetScriptManager(*this)) , script_manager(new SetScriptManager(*this))
, vcs (new_intrusive<VCS>())
{ {
data.init(game->set_fields); data.init(game->set_fields);
} }
...@@ -186,6 +189,7 @@ IMPLEMENT_REFLECTION(Set) { ...@@ -186,6 +189,7 @@ IMPLEMENT_REFLECTION(Set) {
REFLECT(pack_types); REFLECT(pack_types);
} }
reflect_set_info_get_member(tag,data); reflect_set_info_get_member(tag,data);
REFLECT_NO_SCRIPT_N("version control", vcs);
REFLECT(apprentice_code); REFLECT(apprentice_code);
} }
...@@ -206,7 +210,7 @@ void Set::reflect_cards<Writer> (Writer& tag) { ...@@ -206,7 +210,7 @@ void Set::reflect_cards<Writer> (Writer& tag) {
int i = 0; int i = 0;
while (used.find(full_name) != used.end()) { while (used.find(full_name) != used.end()) {
full_name = filename << _(".") << ++i; full_name = String(filename) << _(".") << ++i;
} }
used.insert(full_name); used.insert(full_name);
......
...@@ -61,6 +61,7 @@ class Set : public Packaged { ...@@ -61,6 +61,7 @@ class Set : public Packaged {
ActionStack actions; ///< Actions performed on this set and the cards in it ActionStack actions; ///< Actions performed on this set and the cards in it
KeywordDatabase keyword_db; ///< Database for matching keywords, must be cleared when keywords change KeywordDatabase keyword_db; ///< Database for matching keywords, must be cleared when keywords change
VCSP vcs; ///< The version control system to use
/// A context for performing scripts /// A context for performing scripts
/** Should only be used from the main thread! */ /** Should only be used from the main thread! */
...@@ -119,6 +120,11 @@ class Set : public Packaged { ...@@ -119,6 +120,11 @@ class Set : public Packaged {
Version fileVersion() const; Version fileVersion() const;
/// Validate that the set is correctly loaded /// Validate that the set is correctly loaded
virtual void validate(Version = app_version); virtual void validate(Version = app_version);
protected:
virtual VCSP getVCS() {
return vcs;
}
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
......
...@@ -193,7 +193,7 @@ class SetCombineImage : public SimpleFilterImage { ...@@ -193,7 +193,7 @@ class SetCombineImage : public SimpleFilterImage {
/// Saturate/desaturate an image /// Saturate/desaturate an image
class SaturateImage : public SimpleFilterImage { class SaturateImage : public SimpleFilterImage {
public: public:
inline SaturateImage(const GeneratedImageP& image, double alpha) inline SaturateImage(const GeneratedImageP& image, double amount)
: SimpleFilterImage(image), amount(amount) : SimpleFilterImage(image), amount(amount)
{} {}
virtual Image generate(const Options& opt) const; virtual Image generate(const Options& opt) const;
......
...@@ -51,7 +51,7 @@ ScriptValueP Context::eval(const Script& script, bool useScope) { ...@@ -51,7 +51,7 @@ ScriptValueP Context::eval(const Script& script, bool useScope) {
// Evaluate the current instruction // Evaluate the current instruction
Instruction i = *instr++; Instruction i = *instr++;
// If a scope is created, destroy it at end of block. // If a scope is created, destroy it at end of block.
scoped_ptr<LocalScope> scope; scoped_ptr<LocalScope> new_scope;
switch (i.instr) { switch (i.instr) {
case I_NOP: break; case I_NOP: break;
...@@ -126,7 +126,7 @@ ScriptValueP Context::eval(const Script& script, bool useScope) { ...@@ -126,7 +126,7 @@ ScriptValueP Context::eval(const Script& script, bool useScope) {
} }
// Function call // Function call
case I_CALL: scope.reset(new LocalScope(*this)); //new scope case I_CALL: new_scope.reset(new LocalScope(*this)); //new scope
case I_TAILCALL: { case I_TAILCALL: {
// prepare arguments // prepare arguments
for (unsigned int j = 0 ; j < i.data ; ++j) { for (unsigned int j = 0 ; j < i.data ; ++j) {
...@@ -144,7 +144,7 @@ ScriptValueP Context::eval(const Script& script, bool useScope) { ...@@ -144,7 +144,7 @@ ScriptValueP Context::eval(const Script& script, bool useScope) {
Profiler prof(timer, function); Profiler prof(timer, function);
#endif #endif
// get function and call // get function and call
stack.back() = stack.back()->eval(*this); stack.back() = stack.back()->eval(*this, false);
// finish profiling // finish profiling
#if USE_SCRIPT_PROFILING #if USE_SCRIPT_PROFILING
//profile_add(function, timer.time()); //profile_add(function, timer.time());
...@@ -366,7 +366,14 @@ class ScriptCompose : public ScriptValue { ...@@ -366,7 +366,14 @@ class ScriptCompose : public ScriptValue {
virtual ScriptType type() const { return SCRIPT_FUNCTION; } virtual ScriptType type() const { return SCRIPT_FUNCTION; }
virtual String typeName() const { return _("function composition"); } virtual String typeName() const { return _("function composition"); }
virtual ScriptValueP eval(Context& ctx) const {
virtual ScriptValueP dependencies(Context& ctx, const Dependency& dep) const {
ctx.setVariable(SCRIPT_VAR_input, a->dependencies(ctx, dep));
return b->dependencies(ctx, dep);
}
protected:
virtual ScriptValueP do_eval(Context& ctx, bool openScope) const {
#if USE_SCRIPT_PROFILING #if USE_SCRIPT_PROFILING
Timer timer; Timer timer;
{ {
...@@ -382,14 +389,13 @@ class ScriptCompose : public ScriptValue { ...@@ -382,14 +389,13 @@ class ScriptCompose : public ScriptValue {
return b->eval(ctx); return b->eval(ctx);
} }
#else #else
// Always open a scope for a; variables it makes need to be
// cleared for b's call.
ctx.setVariable(SCRIPT_VAR_input, a->eval(ctx)); ctx.setVariable(SCRIPT_VAR_input, a->eval(ctx));
return b->eval(ctx); return b->eval(ctx, openScope);
#endif #endif
} }
virtual ScriptValueP dependencies(Context& ctx, const Dependency& dep) const {
ctx.setVariable(SCRIPT_VAR_input, a->dependencies(ctx, dep));
return b->dependencies(ctx, dep);
}
private: private:
ScriptValueP a,b; ScriptValueP a,b;
}; };
......
...@@ -173,8 +173,6 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script) ...@@ -173,8 +173,6 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
// Analyze the current instruction // Analyze the current instruction
Instruction i = *instr++; Instruction i = *instr++;
// If a scope is created, destroy it at end of block.
scoped_ptr<LocalScope> scope;
switch (i.instr) { switch (i.instr) {
case I_NOP: break; case I_NOP: break;
// Push a constant (as normal) // Push a constant (as normal)
...@@ -263,8 +261,10 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script) ...@@ -263,8 +261,10 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
} }
// Function call (as normal) // Function call (as normal)
case I_CALL: scope.reset(new LocalScope(*this)); //new scope // Don't optimize tail calls; we may not jump as we normally do
case I_TAILCALL: { case I_CALL: case I_TAILCALL: {
// open a new scope
LocalScope new_scope(*this);
// prepare arguments // prepare arguments
for (unsigned int j = 0 ; j < i.data ; ++j) { for (unsigned int j = 0 ; j < i.data ; ++j) {
setVariable((Variable)instr[i.data - j - 1].data, stack.back()); setVariable((Variable)instr[i.data - j - 1].data, stack.back());
......
...@@ -59,10 +59,10 @@ ...@@ -59,10 +59,10 @@
{ return SCRIPT_FUNCTION; } \ { return SCRIPT_FUNCTION; } \
virtual String typeName() const \ virtual String typeName() const \
{ return _("built-in function '") _(#name) _("'"); } \ { return _("built-in function '") _(#name) _("'"); } \
virtual ScriptValueP eval(Context&) const; \ virtual ScriptValueP do_eval(Context&, bool) const; \
}; \ }; \
ScriptValueP script_##name(new ScriptBuiltIn_##name); \ ScriptValueP script_##name(new ScriptBuiltIn_##name); \
ScriptValueP ScriptBuiltIn_##name::eval(Context& ctx) const ScriptValueP ScriptBuiltIn_##name::do_eval(Context& ctx, bool) const
/// Return a value from a SCRIPT_FUNCTION /// Return a value from a SCRIPT_FUNCTION
#define SCRIPT_RETURN(value) return to_script(value) #define SCRIPT_RETURN(value) return to_script(value)
...@@ -160,7 +160,8 @@ inline Type from_script(const ScriptValueP& v, Variable var) { ...@@ -160,7 +160,8 @@ inline Type from_script(const ScriptValueP& v, Variable var) {
inline ScriptRule_##funname(const type1& name1) : name1(name1) {} \ inline ScriptRule_##funname(const type1& name1) : name1(name1) {} \
virtual ScriptType type() const { return SCRIPT_FUNCTION; } \ virtual ScriptType type() const { return SCRIPT_FUNCTION; } \
virtual String typeName() const { return _(#funname)_("_rule"); } \ virtual String typeName() const { return _(#funname)_("_rule"); } \
virtual ScriptValueP eval(Context& ctx) const; \ protected: \
virtual ScriptValueP do_eval(Context& ctx, bool) const; \
private: \ private: \
type1 name1; \ type1 name1; \
}; \ }; \
...@@ -172,7 +173,7 @@ inline Type from_script(const ScriptValueP& v, Variable var) { ...@@ -172,7 +173,7 @@ inline Type from_script(const ScriptValueP& v, Variable var) {
SCRIPT_PARAM_N(type1, str1, name1); \ SCRIPT_PARAM_N(type1, str1, name1); \
return ScriptRule_##funname(name1).eval(ctx); \ return ScriptRule_##funname(name1).eval(ctx); \
} \ } \
ScriptValueP ScriptRule_##funname::eval(Context& ctx) const ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const
/// Utility for defining a script rule with two parameters /// Utility for defining a script rule with two parameters
#define SCRIPT_RULE_2(funname, type1, name1, type2, name2) \ #define SCRIPT_RULE_2(funname, type1, name1, type2, name2) \
...@@ -199,8 +200,9 @@ inline Type from_script(const ScriptValueP& v, Variable var) { ...@@ -199,8 +200,9 @@ inline Type from_script(const ScriptValueP& v, Variable var) {
: name1(name1), name2(name2) {} \ : name1(name1), name2(name2) {} \
virtual ScriptType type() const { return SCRIPT_FUNCTION; } \ virtual ScriptType type() const { return SCRIPT_FUNCTION; } \
virtual String typeName() const { return _(#funname)_("_rule"); } \ virtual String typeName() const { return _(#funname)_("_rule"); } \
virtual ScriptValueP eval(Context& ctx) const; \
dep \ dep \
protected: \
virtual ScriptValueP do_eval(Context& ctx, bool) const; \
private: \ private: \
type1 name1; \ type1 name1; \
type2 name2; \ type2 name2; \
...@@ -216,7 +218,7 @@ inline Type from_script(const ScriptValueP& v, Variable var) { ...@@ -216,7 +218,7 @@ inline Type from_script(const ScriptValueP& v, Variable var) {
return ScriptRule_##funname(name1, name2).eval(ctx); \ return ScriptRule_##funname(name1, name2).eval(ctx); \
} \ } \
more \ more \
ScriptValueP ScriptRule_##funname::eval(Context& ctx) const ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const
#define SCRIPT_RULE_2_DEPENDENCIES(name) \ #define SCRIPT_RULE_2_DEPENDENCIES(name) \
ScriptValueP ScriptRule_##name::dependencies(Context& ctx, const Dependency& dep) const ScriptValueP ScriptRule_##name::dependencies(Context& ctx, const Dependency& dep) const
......
...@@ -89,8 +89,8 @@ ScriptType Script::type() const { ...@@ -89,8 +89,8 @@ ScriptType Script::type() const {
String Script::typeName() const { String Script::typeName() const {
return _("function"); return _("function");
} }
ScriptValueP Script::eval(Context& ctx) const { ScriptValueP Script::do_eval(Context& ctx, bool openScope) const {
return ctx.eval(*this); return ctx.eval(*this, openScope);
} }
ScriptValueP Script::dependencies(Context& ctx, const Dependency& dep) const { ScriptValueP Script::dependencies(Context& ctx, const Dependency& dep) const {
return ctx.dependencies(dep, *this); return ctx.dependencies(dep, *this);
...@@ -239,11 +239,12 @@ String Script::dumpInstr(unsigned int pos, Instruction i) const { ...@@ -239,11 +239,12 @@ String Script::dumpInstr(unsigned int pos, Instruction i) const {
const Instruction* Script::backtraceSkip(const Instruction* instr, int to_skip) const { const Instruction* Script::backtraceSkip(const Instruction* instr, int to_skip) const {
unsigned int initial = instr - &instructions[0]; unsigned int initial = instr - &instructions[0];
for (;instr >= &instructions[0] && for (;instr >= &instructions[0] &&
(to_skip || // we have something to skip (to_skip || (// we have something to skip
instr >= &instructions[1] && ( instr >= &instructions[1] && (
(instr-1)->instr == I_JUMP // always look inside a jump (instr-1)->instr == I_JUMP // always look inside a jump
|| (instr-1)->instr == I_NOP // and skip nops || (instr-1)->instr == I_NOP // and skip nops
) )
)
) ; --instr) { ) ; --instr) {
// skip an instruction // skip an instruction
switch (instr->instr) { switch (instr->instr) {
...@@ -317,7 +318,7 @@ const Instruction* Script::backtraceSkip(const Instruction* instr, int to_skip) ...@@ -317,7 +318,7 @@ const Instruction* Script::backtraceSkip(const Instruction* instr, int to_skip)
} }
String Script::instructionName(const Instruction* instr) const { String Script::instructionName(const Instruction* instr) const {
if (instr < &instructions[0] || instr >= &instructions[instructions.size()]) return _("??\?"); if (instr < &instructions[0] || instr >= &instructions[0] + instructions.size()) return _("??\?");
if (instr->instr == I_GET_VAR) { if (instr->instr == I_GET_VAR) {
return variable_to_string((Variable)instr->data); return variable_to_string((Variable)instr->data);
} else if (instr->instr == I_MEMBER_C) { } else if (instr->instr == I_MEMBER_C) {
......
...@@ -165,7 +165,6 @@ class Script : public ScriptValue { ...@@ -165,7 +165,6 @@ class Script : public ScriptValue {
virtual ScriptType type() const; virtual ScriptType type() const;
virtual String typeName() const; virtual String typeName() const;
virtual ScriptValueP eval(Context& ctx) const;
virtual ScriptValueP dependencies(Context& ctx, const Dependency&) const; virtual ScriptValueP dependencies(Context& ctx, const Dependency&) const;
/// Add a jump instruction, later comeFrom should be called on the returned value /// Add a jump instruction, later comeFrom should be called on the returned value
...@@ -194,7 +193,10 @@ class Script : public ScriptValue { ...@@ -194,7 +193,10 @@ class Script : public ScriptValue {
String dumpScript() const; String dumpScript() const;
/// Output an instruction in a human readable format /// Output an instruction in a human readable format
String dumpInstr(unsigned int pos, Instruction i) const; String dumpInstr(unsigned int pos, Instruction i) const;
protected:
virtual ScriptValueP do_eval(Context& ctx, bool openScope) const;
private: private:
/// Data of the instructions that make up this script /// Data of the instructions that make up this script
vector<Instruction> instructions; vector<Instruction> instructions;
......
...@@ -84,9 +84,12 @@ class ScriptDelayedError : public ScriptValue { ...@@ -84,9 +84,12 @@ class ScriptDelayedError : public ScriptValue {
// these can propagate the error // these can propagate the error
virtual ScriptValueP getMember(const String& name) const; virtual ScriptValueP getMember(const String& name) const;
virtual ScriptValueP dependencyMember(const String& name, const Dependency&) const; virtual ScriptValueP dependencyMember(const String& name, const Dependency&) const;
virtual ScriptValueP eval(Context&) const;
virtual ScriptValueP dependencies(Context&, const Dependency&) const; virtual ScriptValueP dependencies(Context&, const Dependency&) const;
virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const; virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const;
protected:
virtual ScriptValueP do_eval(Context&, bool openScope) const;
private: private:
ScriptError error; // the error message ScriptError error; // the error message
}; };
...@@ -349,7 +352,6 @@ class ScriptClosure : public ScriptValue { ...@@ -349,7 +352,6 @@ class ScriptClosure : public ScriptValue {
virtual ScriptType type() const; virtual ScriptType type() const;
virtual String typeName() const; virtual String typeName() 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
...@@ -365,6 +367,9 @@ class ScriptClosure : public ScriptValue { ...@@ -365,6 +367,9 @@ class ScriptClosure : public ScriptValue {
/// The default argument bindings /// The default argument bindings
vector<pair<Variable,ScriptValueP> > bindings; vector<pair<Variable,ScriptValueP> > bindings;
protected:
virtual ScriptValueP do_eval(Context& ctx, bool openScope) const;
private: private:
/// Apply the bindings in a context /// Apply the bindings in a context
void applyBindings(Context& ctx) const; void applyBindings(Context& ctx) const;
...@@ -376,7 +381,10 @@ class ScriptRule : public ScriptValue { ...@@ -376,7 +381,10 @@ class ScriptRule : public ScriptValue {
inline ScriptRule(const ScriptValueP& fun) : fun(fun) {} inline ScriptRule(const 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;
protected:
virtual ScriptValueP do_eval(Context& ctx, bool openScope) const;
private: private:
ScriptValueP fun; ScriptValueP fun;
}; };
......
...@@ -25,7 +25,7 @@ ScriptValue::operator bool() const { throw Script ...@@ -25,7 +25,7 @@ ScriptValue::operator bool() const { throw Script
ScriptValue::operator double() const { throw ScriptErrorConversion(typeName(), _TYPE_("double" )); } ScriptValue::operator double() const { throw ScriptErrorConversion(typeName(), _TYPE_("double" )); }
ScriptValue::operator AColor() const { throw ScriptErrorConversion(typeName(), _TYPE_("color" )); } ScriptValue::operator AColor() const { throw ScriptErrorConversion(typeName(), _TYPE_("color" )); }
ScriptValue::operator wxDateTime() const { throw ScriptErrorConversion(typeName(), _TYPE_("date" )); } ScriptValue::operator wxDateTime() const { throw ScriptErrorConversion(typeName(), _TYPE_("date" )); }
ScriptValueP ScriptValue::eval(Context&) const { return delay_error(ScriptErrorConversion(typeName(), _TYPE_("function"))); } ScriptValueP ScriptValue::do_eval(Context&, bool) const { return delay_error(ScriptErrorConversion(typeName(), _TYPE_("function"))); }
ScriptValueP ScriptValue::next(ScriptValueP* key_out) { throw InternalError(_("Can't convert from ")+typeName()+_(" to iterator")); } ScriptValueP ScriptValue::next(ScriptValueP* key_out) { throw InternalError(_("Can't convert from ")+typeName()+_(" to iterator")); }
ScriptValueP ScriptValue::makeIterator(const ScriptValueP&) const { return delay_error(ScriptErrorConversion(typeName(), _TYPE_("collection"))); } ScriptValueP ScriptValue::makeIterator(const ScriptValueP&) const { return delay_error(ScriptErrorConversion(typeName(), _TYPE_("collection"))); }
int ScriptValue::itemCount() const { throw ScriptErrorConversion(typeName(), _TYPE_("collection")); } int ScriptValue::itemCount() const { throw ScriptErrorConversion(typeName(), _TYPE_("collection")); }
...@@ -113,7 +113,7 @@ int ScriptDelayedError::itemCount() const { throw error; } ...@@ -113,7 +113,7 @@ int ScriptDelayedError::itemCount() const { throw error; }
CompareWhat ScriptDelayedError::compareAs(String&, void const*&) const { throw error; } CompareWhat ScriptDelayedError::compareAs(String&, void const*&) const { throw error; }
ScriptValueP ScriptDelayedError::getMember(const String&) const { return new_intrusive1<ScriptDelayedError>(error); } ScriptValueP ScriptDelayedError::getMember(const String&) const { return new_intrusive1<ScriptDelayedError>(error); }
ScriptValueP ScriptDelayedError::dependencyMember(const String&, const Dependency&) const { return new_intrusive1<ScriptDelayedError>(error); } ScriptValueP ScriptDelayedError::dependencyMember(const String&, const Dependency&) const { return new_intrusive1<ScriptDelayedError>(error); }
ScriptValueP ScriptDelayedError::eval(Context&) const { return new_intrusive1<ScriptDelayedError>(error); } ScriptValueP ScriptDelayedError::do_eval(Context&, bool) const { return new_intrusive1<ScriptDelayedError>(error); }
ScriptValueP ScriptDelayedError::dependencies(Context&, const Dependency&) const { return new_intrusive1<ScriptDelayedError>(error); } ScriptValueP ScriptDelayedError::dependencies(Context&, const Dependency&) const { return new_intrusive1<ScriptDelayedError>(error); }
ScriptValueP ScriptDelayedError::makeIterator(const ScriptValueP& thisP) const { return thisP; } ScriptValueP ScriptDelayedError::makeIterator(const ScriptValueP& thisP) const { return thisP; }
...@@ -370,7 +370,9 @@ class ScriptNil : public ScriptValue { ...@@ -370,7 +370,9 @@ class ScriptNil : public ScriptValue {
virtual GeneratedImageP toImage(const ScriptValueP&) const { virtual GeneratedImageP toImage(const ScriptValueP&) const {
return new_intrusive<BlankImage>(); return new_intrusive<BlankImage>();
} }
virtual ScriptValueP eval(Context& ctx) const {
protected:
virtual ScriptValueP do_eval(Context& ctx, bool) const {
// nil(input) == input // nil(input) == input
return ctx.getVariable(SCRIPT_VAR_input); return ctx.getVariable(SCRIPT_VAR_input);
} }
...@@ -513,10 +515,10 @@ ScriptValueP ScriptClosure::simplify() { ...@@ -513,10 +515,10 @@ ScriptValueP ScriptClosure::simplify() {
return fun->simplifyClosure(*this); return fun->simplifyClosure(*this);
} }
ScriptValueP ScriptClosure::eval(Context& ctx) const { ScriptValueP ScriptClosure::do_eval(Context& ctx, bool openScope) const {
LocalScope scope(ctx); scoped_ptr<LocalScope> scope(openScope ? new LocalScope(ctx) : nullptr);
applyBindings(ctx); applyBindings(ctx);
return fun->eval(ctx); return fun->eval(ctx, openScope);
} }
ScriptValueP ScriptClosure::dependencies(Context& ctx, const Dependency& dep) const { ScriptValueP ScriptClosure::dependencies(Context& ctx, const Dependency& dep) const {
LocalScope scope(ctx); LocalScope scope(ctx);
...@@ -534,6 +536,6 @@ void ScriptClosure::applyBindings(Context& ctx) const { ...@@ -534,6 +536,6 @@ void ScriptClosure::applyBindings(Context& ctx) const {
ScriptType ScriptRule::type() const { return SCRIPT_FUNCTION; } ScriptType ScriptRule::type() const { return SCRIPT_FUNCTION; }
String ScriptRule::typeName() const { return fun->typeName() + _(" rule"); } String ScriptRule::typeName() const { return fun->typeName() + _(" rule"); }
ScriptValueP ScriptRule::eval(Context& ctx) const { ScriptValueP ScriptRule::do_eval(Context& ctx, bool openScope) const {
return ctx.makeClosure(fun); return ctx.makeClosure(fun);
} }
...@@ -97,7 +97,9 @@ class ScriptValue : public IntrusivePtrBaseWithDelete { ...@@ -97,7 +97,9 @@ class ScriptValue : public IntrusivePtrBaseWithDelete {
virtual ScriptValueP dependencyName(const ScriptValue& container, const Dependency&) const; virtual ScriptValueP dependencyName(const ScriptValue& container, const Dependency&) const;
/// Evaluate this value (if it is a function) /// Evaluate this value (if it is a function)
virtual ScriptValueP eval(Context&) const; ScriptValueP eval(Context& ctx, bool openScope = true) const {
return do_eval(ctx, openScope);
}
/// Mark the scripts that this function depends on /// Mark the scripts that this function depends on
/** Return value is an abstract version of the return value of eval */ /** Return value is an abstract version of the return value of eval */
virtual ScriptValueP dependencies(Context&, const Dependency&) const; virtual ScriptValueP dependencies(Context&, const Dependency&) const;
...@@ -117,6 +119,9 @@ class ScriptValue : public IntrusivePtrBaseWithDelete { ...@@ -117,6 +119,9 @@ class ScriptValue : public IntrusivePtrBaseWithDelete {
virtual int itemCount() const; virtual int itemCount() const;
/// Get a member at the given index /// Get a member at the given index
virtual ScriptValueP getIndex(int index) const; virtual ScriptValueP getIndex(int index) const;
protected:
virtual ScriptValueP do_eval(Context& ctx, bool openScope) const;
}; };
extern ScriptValueP script_nil; ///< The preallocated nil value extern ScriptValueP script_nil; ///< The preallocated nil value
......
...@@ -513,7 +513,6 @@ IMPLEMENT_REFLECTION(Packaged) { ...@@ -513,7 +513,6 @@ IMPLEMENT_REFLECTION(Packaged) {
Packaged::Packaged() Packaged::Packaged()
: position_hint(100000) : position_hint(100000)
, fully_loaded(true) , fully_loaded(true)
, vcs(nullptr)
{} {}
InputStreamP Packaged::openIconFile() { InputStreamP Packaged::openIconFile() {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <util/dynamic_arg.hpp> #include <util/dynamic_arg.hpp>
#include <util/error.hpp> #include <util/error.hpp>
#include <util/file_utils.hpp> #include <util/file_utils.hpp>
#include <util/io/vcs.hpp> #include <util/vcs.hpp>
class Package; class Package;
class wxFileInputStream; class wxFileInputStream;
...@@ -143,7 +143,7 @@ class Package : public IntrusivePtrVirtualBase { ...@@ -143,7 +143,7 @@ class Package : public IntrusivePtrVirtualBase {
} }
protected: protected:
// TODO: I dislike this very much. There ought to be a better way. // TODO: I dislike putting this here very much. There ought to be a better way.
virtual VCSP getVCS() { return new_intrusive<VCS>(); } virtual VCSP getVCS() { return new_intrusive<VCS>(); }
// --------------------------------------------------- : Private stuff // --------------------------------------------------- : Private stuff
...@@ -219,7 +219,6 @@ class Packaged : public Package { ...@@ -219,7 +219,6 @@ class Packaged : public Package {
String icon_filename; ///< Filename of icon to use in package lists String icon_filename; ///< Filename of icon to use in package lists
vector<PackageDependencyP> dependencies; ///< Dependencies of this package vector<PackageDependencyP> dependencies; ///< Dependencies of this package
int position_hint; ///< A hint for the package list int position_hint; ///< A hint for the package list
VCSP vcs; ///< The version control system to use
/// Get an input stream for the package icon, if there is any /// Get an input stream for the package icon, if there is any
InputStreamP openIconFile(); InputStreamP openIconFile();
...@@ -243,10 +242,6 @@ class Packaged : public Package { ...@@ -243,10 +242,6 @@ class Packaged : public Package {
} }
protected: protected:
virtual VCSP getVCS() {
return vcs;
}
/// filename of the data file, and extension of the package file /// filename of the data file, and extension of the package file
virtual String typeName() const = 0; virtual String typeName() const = 0;
/// Can be overloaded to do validation after loading /// Can be overloaded to do validation after loading
......
...@@ -20,7 +20,7 @@ void Regex::assign(const String& code) { ...@@ -20,7 +20,7 @@ void Regex::assign(const String& code) {
} catch (const boost::regex_error& e) { } catch (const boost::regex_error& e) {
/// TODO: be more precise /// TODO: be more precise
throw ScriptError(String::Format(_("Error while compiling regular expression: '%s'\nAt position: %d\n%s"), throw ScriptError(String::Format(_("Error while compiling regular expression: '%s'\nAt position: %d\n%s"),
code.c_str(), e.position(), String(e.what(), IF_UNICODE(wxConvUTF8,String::npos)))); code.c_str(), e.position(), String(e.what(), IF_UNICODE(wxConvUTF8,String::npos)).c_str()));
} }
} }
......
...@@ -12,11 +12,13 @@ case $UID in ...@@ -12,11 +12,13 @@ case $UID in
0) 0)
INSTALL_DIR='/usr/local/share/magicseteditor/'; INSTALL_DIR='/usr/local/share/magicseteditor/';
EXEC_SYMLINK='/usr/local/bin/magicseteditor'; EXEC_SYMLINK='/usr/local/bin/magicseteditor';
FONTS_DIR='/usr/local/share/fonts/';; FONTS_DIR='/usr/local/share/fonts/';
CHMOD='chmod +x';;
*) *)
INSTALL_DIR='$HOME/.magicseteditor/'; INSTALL_DIR='$HOME/.magicseteditor/';
EXEC_SYMLINK='$HOME/bin/magicseteditor'; EXEC_SYMLINK='$HOME/bin/magicseteditor';
FONTS_DIR='$HOME/.fonts/';; FONTS_DIR='$HOME/.fonts/';
CHMOD='chmod u+x';;
esac esac
if [ "$MSE_INSTALL_DIR" != "" ]; then if [ "$MSE_INSTALL_DIR" != "" ]; then
...@@ -49,5 +51,6 @@ echo "Installing..."; ...@@ -49,5 +51,6 @@ echo "Installing...";
mkdir "$INSTALL_DIR"; mkdir "$INSTALL_DIR";
cp -r program/* "$INSTALL_DIR"; cp -r program/* "$INSTALL_DIR";
$CHMOD "$INSTALL_DIR/magicseteditor";
cp fonts/* "$FONTS_DIR"; cp fonts/* "$FONTS_DIR";
ln -s "$INSTALL_DIR/magicseteditor" "$EXEC_SYMLINK" ln -s "$INSTALL_DIR/magicseteditor" "$EXEC_SYMLINK"
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