-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathphp_base.h
More file actions
90 lines (76 loc) · 1.59 KB
/
php_base.h
File metadata and controls
90 lines (76 loc) · 1.59 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* PhpBase.h
*
* Base class for objects inside v8 that are exposed to PHP space.
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2015 - 2025 Copernica B.V.
*/
/**
* Include guard
*/
#pragma once
/**
* Dependencies
*/
#include <phpcpp.h>
#include <v8.h>
/**
* Start namespace
*/
namespace JS {
/**
* Forward declarations
*/
class Core;
/**
* Class definition
*/
class PhpBase : public Php::Base
{
protected:
/**
* The core in which we operate (this is a shared pointer because for as long as the
* object lives in PHP space, we want to keep the core around (even when the PHP
* space JS\Context already fell out of scope)
* @var std::shared_ptr<Context>
*/
std::shared_ptr<Core> _core;
/**
* The underlying ecmascript object
* @var v8::Global<v8::Value>
*/
v8::Global<v8::Value> _object;
/**
* Constructor
* @param isolate The isolate
* @param object The ecmascript object
*/
PhpBase(v8::Isolate *isolate, const v8::Local<v8::Value> &object);
public:
/**
* No copying
* @param that
*/
PhpBase(const PhpBase &that) = delete;
/**
* Destructor
*/
virtual ~PhpBase();
/**
* Helper method to unwrap an object
* @param core
* @param value
* @return Php::Base
*/
static PhpBase *unwrap(const Core *core, const Php::Value &value);
/**
* Get the v8 handle
* @return v8::Local<v8::Value>
*/
v8::Local<v8::Value> handle();
};
/**
* End namespace
*/
}