-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathphp_context.cpp
More file actions
64 lines (57 loc) · 1.38 KB
/
php_context.cpp
File metadata and controls
64 lines (57 loc) · 1.38 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* PhpContext.cpp
*
* Implementation file for the PhpContext class
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2025 Copernica BV
*/
/**
* Dependencies
*/
#include "php_context.h"
/**
* Begin of namespace
*/
namespace JS {
/**
* Constructor
*/
PhpContext::PhpContext() : _core(std::make_shared<Core>()) {}
/**
* Assign a variable to the javascript context
* @param params array of parameters:
* - string name of property to assign required
* - mixed property value to assign required
* - integer property attributes optional
*
* The property attributes can be one of the following values
*
* - ReadOnly
* - DontEnum
* - DontDelete
*
* If not specified, the property will be writable, enumerable and
* deletable.
*/
Php::Value PhpContext::assign(Php::Parameters ¶ms)
{
// pass on
return _core->assign(params[0], params[1], params.size() > 2 ? params[2] : Php::Value(v8::None));
}
/**
* Parse a piece of javascript code
*
* @param params array with one parameter: the code to execute
* @return Php::Value
* @throws Php::Exception
*/
Php::Value PhpContext::evaluate(Php::Parameters ¶ms)
{
// pass on
return _core->evaluate(params[0], params.size() > 1 ? params[1] : Php::Value(0));
}
/**
* End of namespace
*/
}