mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-17 18:12:04 +01:00
increment changes with the aim of improviing performance of variables
This commit is contained in:
parent
1919c27434
commit
3991f80eb2
5 changed files with 50 additions and 3 deletions
|
@ -27,6 +27,26 @@ protected:
|
||||||
} // declare
|
} // declare
|
||||||
}; // Param
|
}; // Param
|
||||||
|
|
||||||
|
|
||||||
|
class GlobalParam : public Variable_impl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GlobalParam(const std::string& name,
|
||||||
|
const Arabica::XPath::XPathExpressionPtr<std::string>& select,
|
||||||
|
const Precedence& precedence) :
|
||||||
|
Variable_impl(name, select, precedence)
|
||||||
|
{
|
||||||
|
} // GlobalParam
|
||||||
|
|
||||||
|
virtual ~GlobalParam() { }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void execute(const DOM::Node<std::string>& node, ExecutionContext& context) const
|
||||||
|
{
|
||||||
|
context.declareParam(node, *this);
|
||||||
|
} // declare
|
||||||
|
}; // GlobalParam
|
||||||
|
|
||||||
} // namespace XSLT
|
} // namespace XSLT
|
||||||
} // namespace Arabica
|
} // namespace Arabica
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -196,11 +196,11 @@ const ChildElement StylesheetHandler::allowedChildren[] =
|
||||||
{ "key", CreateHandler<KeyHandler>},
|
{ "key", CreateHandler<KeyHandler>},
|
||||||
{ "namespace-alias", CreateHandler<NamespaceAliasHandler>},
|
{ "namespace-alias", CreateHandler<NamespaceAliasHandler>},
|
||||||
{ "output", CreateHandler<OutputHandler>},
|
{ "output", CreateHandler<OutputHandler>},
|
||||||
{ "param", CreateHandler<TopLevelVariableHandler<Param> >},
|
{ "param", CreateHandler<TopLevelVariableHandler<GlobalParam> >},
|
||||||
{ "preserve-space", CreateHandler<NotImplementedYetHandler>},
|
{ "preserve-space", CreateHandler<NotImplementedYetHandler>},
|
||||||
{ "strip-space", CreateHandler<NotImplementedYetHandler>},
|
{ "strip-space", CreateHandler<NotImplementedYetHandler>},
|
||||||
{ "template", CreateHandler<TemplateHandler> },
|
{ "template", CreateHandler<TemplateHandler> },
|
||||||
{ "variable", CreateHandler<TopLevelVariableHandler<Variable> > },
|
{ "variable", CreateHandler<TopLevelVariableHandler<GlobalVariable> > },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
}; // StylesheetHandler::allowedChildren
|
}; // StylesheetHandler::allowedChildren
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,24 @@ public:
|
||||||
} // declare
|
} // declare
|
||||||
}; // Variable
|
}; // Variable
|
||||||
|
|
||||||
|
class GlobalVariable : public Variable_impl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GlobalVariable(const std::string& name,
|
||||||
|
const Arabica::XPath::XPathExpressionPtr<std::string>& select,
|
||||||
|
const Precedence precedence) :
|
||||||
|
Variable_impl(name, select, precedence)
|
||||||
|
{
|
||||||
|
} // Variable
|
||||||
|
|
||||||
|
virtual ~GlobalVariable() { }
|
||||||
|
|
||||||
|
virtual void execute(const DOM::Node<std::string>& node, ExecutionContext& context) const
|
||||||
|
{
|
||||||
|
context.declareVariable(node, *this);
|
||||||
|
} // declare
|
||||||
|
}; // class GlobalVariable
|
||||||
|
|
||||||
} // namespace XSLT
|
} // namespace XSLT
|
||||||
} // namespace Arabica
|
} // namespace Arabica
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace XSLT
|
||||||
{
|
{
|
||||||
|
|
||||||
class Variable_instance;
|
class Variable_instance;
|
||||||
typedef boost::shared_ptr<Variable_instance> Variable_instance_ptr;
|
typedef Variable_instance* Variable_instance_ptr;
|
||||||
typedef std::map<std::string, Variable_instance_ptr> Scope;
|
typedef std::map<std::string, Variable_instance_ptr> Scope;
|
||||||
|
|
||||||
class Variable_instance
|
class Variable_instance
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
Introduce GlobalVariable and GlobalParam.
|
||||||
|
Rename Variable_instance to DeclaredVariable.
|
||||||
|
Get rid of Variable_declaration. Variables should implement Variable_instance.
|
||||||
|
Normal variables don't bother with injectGlobalScope, GlobalVariables do.
|
||||||
|
Variables become their own closures. Forget all the ref counting nonsense, it is not necessary.
|
||||||
|
Normal variables resolve immediately and push themselves on the stack.
|
||||||
|
GlobalVariables resolve on demand.
|
||||||
|
|
||||||
|
====================================================
|
||||||
Elements test suite
|
Elements test suite
|
||||||
Errors test suite
|
Errors test suite
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue