-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathDictType.cc
More file actions
29 lines (23 loc) · 826 Bytes
/
DictType.cc
File metadata and controls
29 lines (23 loc) · 826 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 DictType.cc
* @author Caleb Aikens (caleb@distributive.network), Giovanni Tedesco (giovanni@distributive.network) and Philippe Laporte (philippe@distributive.network)
* @brief Struct representing python dictionaries
* @date 2022-08-10
*
* @copyright Copyright (c) 2022,2024 Distributive Corp.
*
*/
#include "include/DictType.hh"
#include "include/JSObjectProxy.hh"
#include <jsapi.h>
PyObject *DictType::getPyObject(JSContext *cx, JS::Handle<JS::Value> jsObject) {
JSObjectProxy *proxy = (JSObjectProxy *)PyObject_CallObject((PyObject *)&JSObjectProxyType, NULL);
if (proxy != NULL) {
JS::RootedObject obj(cx);
JS_ValueToObject(cx, jsObject, &obj);
proxy->jsObject = new JS::PersistentRootedObject(cx);
proxy->jsObject->set(obj);
return (PyObject *)proxy;
}
return NULL;
}