summaryrefslogtreecommitdiff
path: root/plugins/Skins/SkinLib/V8Script.h
blob: b7e1f3f2a6d90c590a68e894980a8e10fef869eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef __V8_SCRIPT_H__
# define __V8_SCRIPT_H__

#include <v8.h>
#include <utility>
#include "V8Wrappers.h"


typedef void (*ExceptionCallback)(void *param, const TCHAR *err);


class V8Script
{
public:
	static void initializeEngine();


	V8Script();
	~V8Script();

	bool compile(const TCHAR *source, Dialog *dlg);
	void dispose();

	bool isValid();

	std::pair<SkinOptions *,DialogState *> configure(Dialog *dlg);

	bool run(DialogState * state, SkinOptions *opts, DialogInfo *info);

	void setExceptionCallback(ExceptionCallback cb, void *param = NULL);

private:
	v8::Persistent<v8::Context> context;
	v8::Persistent<v8::Function> configureFunction;
	v8::Persistent<v8::Function> drawFunction;

	ExceptionCallback exceptionCallback;
	void *exceptionCallbackParam;

	void reportException(v8::TryCatch *try_catch);
	void fillWrappers(DialogState *state, SkinOptions *opts, DialogInfo *info, bool configure);
};



#endif // __V8_SCRIPT_H__