-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathPyBytesProxyHandler.hh
More file actions
57 lines (48 loc) · 1.73 KB
/
PyBytesProxyHandler.hh
File metadata and controls
57 lines (48 loc) · 1.73 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
/**
* @file PyBytesProxyHandler.hh
* @author Philippe Laporte (philippe@distributive.network)
* @brief Struct for creating JS Uint8Array-like proxy objects for immutable bytes objects
* @date 2024-07-23
*
* @copyright Copyright (c) 2024 Distributive Corp.
*
*/
#ifndef PythonMonkey_PyBytesProxy_
#define PythonMonkey_PyBytesProxy_
#include "include/PyObjectProxyHandler.hh"
/**
* @brief This struct is the ProxyHandler for JS Proxy Iterable pythonmonkey creates to handle coercion from python iterables to JS Objects
*
*/
struct PyBytesProxyHandler : public PyObjectProxyHandler {
public:
PyBytesProxyHandler() : PyObjectProxyHandler(&family) {};
static const char family;
/**
* @brief [[Set]]
*
* @param cx pointer to JSContext
* @param proxy The proxy object who's property we wish to set
* @param id Key of the property we wish to set
* @param v Value that we wish to set the property to
* @param receiver The `this` value to use when executing any code
* @param result whether or not the call succeeded
* @return true call succeed
* @return false call failed and an exception has been raised
*/
bool set(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
JS::HandleValue v, JS::HandleValue receiver,
JS::ObjectOpResult &result) const override;
bool getOwnPropertyDescriptor(
JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> desc
) const override;
/**
* @brief Handles python object reference count when JS Proxy object is finalized
*
* @param gcx pointer to JS::GCContext
* @param proxy the proxy object being finalized
*/
void finalize(JS::GCContext *gcx, JSObject *proxy) const override;
};
#endif