FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PythonMonkey/src/JSObjectItemsProxy.cc at main · TeamCFML-In/PythonMonkey · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
TeamCFML-In
/
PythonMonkey
Public
forked from
Distributive-Network/PythonMonkey
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PythonMonkey
/
src
/
JSObjectItemsProxy.cc
Copy path
More file actions
More file actions
Latest commit
History
History
History
115 lines (96 loc) · 3.54 KB
Breadcrumbs
PythonMonkey
/
src
/
JSObjectItemsProxy.cc
Copy path
File metadata and controls
115 lines (96 loc) · 3.54 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
*
* @file JSObjectItemsProxy.cc
* @author Philippe Laporte (philippe@distributive.network)
* @brief JSObjectItemsProxy is a custom C-implemented python type that derives from dict keys
* @date 2024-01-19
*
* @copyright Copyright (c) 2024 Distributive Corp.
*
*/
#
include
"
include/JSObjectItemsProxy.hh
"
#
include
"
include/JSObjectIterProxy.hh
"
#
include
"
include/JSObjectProxy.hh
"
#
include
"
include/JSArrayProxy.hh
"
#
include
"
include/modules/pythonmonkey/pythonmonkey.hh
"
#
include
"
include/jsTypeFactory.hh
"
#
include
"
include/PyBaseProxyHandler.hh
"
#
include
<
jsapi.h
>
#
include
<
jsfriendapi.h
>
#
include
<
Python.h
>
void
JSObjectItemsProxyMethodDefinitions::JSObjectItemsProxy_dealloc
(JSObjectItemsProxy *self)
{
PyObject_GC_UnTrack
(self);
Py_XDECREF
(self->
dv
.
dv_dict
);
PyObject_GC_Del
(self);
}
Py_ssize_t
JSObjectItemsProxyMethodDefinitions::JSObjectItemsProxy_length
(JSObjectItemsProxy *self)
{
if
(self->
dv
.
dv_dict
==
NULL
) {
return
0
;
}
return
JSObjectProxyMethodDefinitions::JSObjectProxy_length
((JSObjectProxy *)self->
dv
.
dv_dict
);
}
int
JSObjectItemsProxyMethodDefinitions::JSObjectItemsProxy_traverse
(JSObjectItemsProxy *self, visitproc visit,
void
*arg) {
Py_VISIT
(self->
dv
.
dv_dict
);
return
0
;
}
int
JSObjectItemsProxyMethodDefinitions::JSObjectItemsProxy_clear
(JSObjectItemsProxy *self) {
Py_CLEAR
(self->
dv
.
dv_dict
);
return
0
;
}
PyObject *
JSObjectItemsProxyMethodDefinitions::JSObjectItemsProxy_iter
(JSObjectItemsProxy *self) {
JSObjectIterProxy *iterator =
PyObject_GC_New
(JSObjectIterProxy, &JSObjectIterProxyType);
if
(iterator ==
NULL
) {
return
NULL
;
}
iterator->
it
.
reversed
=
false
;
iterator->
it
.
it_index
=
0
;
iterator->
it
.
kind
=
KIND_ITEMS
;
Py_INCREF
(self->
dv
.
dv_dict
);
iterator->
it
.
di_dict
= self->
dv
.
dv_dict
;
iterator->
it
.
props
=
new
JS::PersistentRootedIdVector
(
GLOBAL_CX
);
//
Get **enumerable** own properties
if
(!
js::GetPropertyKeys
(
GLOBAL_CX
, *(((JSObjectProxy *)(self->
dv
.
dv_dict
))->
jsObject
),
JSITER_OWNONLY
, iterator->
it
.
props
)) {
return
NULL
;
}
PyObject_GC_Track
(iterator);
return
(PyObject *)iterator;
}
PyObject *
JSObjectItemsProxyMethodDefinitions::JSObjectItemsProxy_iter_reverse
(JSObjectItemsProxy *self) {
JSObjectIterProxy *iterator =
PyObject_GC_New
(JSObjectIterProxy, &JSObjectIterProxyType);
if
(iterator ==
NULL
) {
return
NULL
;
}
iterator->
it
.
reversed
=
true
;
iterator->
it
.
it_index
=
JSObjectItemsProxyMethodDefinitions::JSObjectItemsProxy_length
(self) -
1
;
iterator->
it
.
kind
=
KIND_ITEMS
;
Py_INCREF
(self->
dv
.
dv_dict
);
iterator->
it
.
di_dict
= self->
dv
.
dv_dict
;
iterator->
it
.
props
=
new
JS::PersistentRootedIdVector
(
GLOBAL_CX
);
//
Get **enumerable** own properties
if
(!
js::GetPropertyKeys
(
GLOBAL_CX
, *(((JSObjectProxy *)(self->
dv
.
dv_dict
))->
jsObject
),
JSITER_OWNONLY
, iterator->
it
.
props
)) {
return
NULL
;
}
PyObject_GC_Track
(iterator);
return
(PyObject *)iterator;
}
PyObject *
JSObjectItemsProxyMethodDefinitions::JSObjectItemsProxy_repr
(JSObjectItemsProxy *self) {
PyObject *seq;
PyObject *result =
NULL
;
Py_ssize_t rc =
Py_ReprEnter
((PyObject *)self);
if
(rc !=
0
) {
return
rc >
0
?
PyUnicode_FromString
(
"
...
"
) :
NULL
;
}
seq =
PySequence_List
((PyObject *)self);
if
(seq ==
NULL
) {
goto
Done;
}
result =
PyUnicode_FromFormat
(
"
%s(%R)
"
, PyDictItems_Type.
tp_name
, seq);
Py_DECREF
(seq);
Done:
Py_ReprLeave
((PyObject *)self);
return
result;
}
PyObject *
JSObjectItemsProxyMethodDefinitions::JSObjectItemsProxy_mapping
(PyObject *self,
void
*
Py_UNUSED
(ignored)) {
return
PyDictProxy_New
((PyObject *)((_PyDictViewObject *)self)->
dv_dict
);
}
Back
|
FazBrowse Home
|
New Git URL