2
This file is part of the Grantlee template system.
4
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either version
9
2 of the Licence, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef SCRIPTABLE_NODE_H
22
#define SCRIPTABLE_NODE_H
24
#include <QtScript/QScriptValue>
26
#include <QtCore/QSharedPointer>
39
typedef QSharedPointer<QScriptEngine> ScriptEnginePointer;
41
using namespace Grantlee;
43
Q_DECLARE_METATYPE( Grantlee::Node* )
45
QScriptValue ScriptableNodeConstructor( QScriptContext *context,
46
QScriptEngine *engine );
49
QScriptValue nodeToScriptValue( QScriptEngine *engine, Node* const &node );
51
void nodeFromScriptValue( const QScriptValue &object, Node* &out );
53
class ScriptableNode : public Node
57
ScriptableNode( QObject* parent = 0 );
58
void setScriptEngine( QScriptEngine* engine );
59
void init( const QScriptValue &concreteNode,
60
const QScriptValue &renderMethod );
62
QScriptEngine* engine();
64
void render( OutputStream *stream, Context *c );
67
QScriptEngine* m_scriptEngine;
68
QScriptValue m_concreteNode;
69
QScriptValue m_renderMethod;
72
void setNodeList( const QString &name, QObjectList );
76
class ScriptableNodeFactory : public AbstractNodeFactory
80
ScriptableNodeFactory( QObject* parent = 0 );
81
void setScriptEngine( QScriptEngine *engine );
83
/* reimp */ void setEngine( Grantlee::Engine *engine );
84
void setFactory( QScriptValue factoryMethod );
86
Node* getNode( const QString &tagContent, Parser *p = 0 ) const;
89
QScriptEngine* m_scriptEngine;
90
QScriptValue m_factoryMethod;