-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathJSStringProxy.cc
More file actions
29 lines (23 loc) · 996 Bytes
/
JSStringProxy.cc
File metadata and controls
29 lines (23 loc) · 996 Bytes
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
/**
* @file JSStringProxy.cc
* @author Caleb Aikens (caleb@distributive.network) and Philippe Laporte (plaporte@distributive.network)
* @brief JSStringProxy is a custom C-implemented python type that derives from str. It acts as a proxy for JSStrings from Spidermonkey, and behaves like a str would.
* @date 2024-05-15
*
* @copyright Copyright (c) 2024 Distributive Corp.
*
*/
#include "include/JSStringProxy.hh"
#include "include/StrType.hh"
std::unordered_set<JSStringProxy *> jsStringProxies;
extern JSContext *GLOBAL_CX;
void JSStringProxyMethodDefinitions::JSStringProxy_dealloc(JSStringProxy *self)
{
jsStringProxies.erase(self);
delete self->jsString;
}
PyObject *JSStringProxyMethodDefinitions::JSStringProxy_copy_method(JSStringProxy *self) {
JS::RootedString selfString(GLOBAL_CX, ((JSStringProxy *)self)->jsString->toString());
JS::RootedValue selfStringValue(GLOBAL_CX, JS::StringValue(selfString));
return StrType::proxifyString(GLOBAL_CX, selfStringValue);
}