-
Notifications
You must be signed in to change notification settings - Fork 1
/
Context.h
34 lines (22 loc) · 868 Bytes
/
Context.h
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
#ifndef __JS_INTERNAL_CONTEXT_H__
#define __JS_INTERNAL_CONTEXT_H__
#include "v8.h"
#include <functional>
namespace JSMySQL
{
class Context
{
public:
Context(v8::Isolate* );
~Context();
void LoadScript(const std::string& script_path);
void BindNativeFunction(const std::string& name,std::function<void(const v8::FunctionCallbackInfo<v8::Value>&)>& inFunction);
bool ExecuteFunction(const std::string& name, std::vector<v8::Local<v8::Value> >& arguments, std::string& result);
private:
v8::Persistent<v8::Context> m_v8Context;
v8::Isolate* m_isolate;
static void ReadFile(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Require(const v8::FunctionCallbackInfo<v8::Value>& args);
};
}
#endif