Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Philippe/fix/176 plus #204

Merged
merged 62 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
2101281
Merge branch 'philippe/fix/176' into philippe/fix/176-plus
philippedistributive Dec 18, 2023
4acb707
Merge branch 'philippe/fix/176' into philippe/fix/176-plus
philippedistributive Dec 19, 2023
789b4e5
Several List to Array conversion methods done
philippedistributive Dec 20, 2023
e95d51e
Merge branch 'main' into philippe/fix/176-plus
philippedistributive Dec 20, 2023
0cf389a
comment
philippedistributive Dec 20, 2023
2239514
All Python List Proxy methods in except for iterator-based ones
philippedistributive Dec 20, 2023
3760ac5
fix leak introduced in philippe/176
philippedistributive Dec 21, 2023
ae060ae
better naming
philippedistributive Dec 21, 2023
c4c9675
improved naming
philippedistributive Dec 21, 2023
e926e9f
implemented valueOf
philippedistributive Dec 21, 2023
aa35a20
Additional Python List to JS Array conversion functionality
philippedistributive Dec 22, 2023
c7e0f1c
finalize outline
philippedistributive Dec 22, 2023
1745017
cleanup
philippedistributive Dec 22, 2023
4e94f70
comments
philippedistributive Dec 22, 2023
44fd194
cleanup
philippedistributive Dec 22, 2023
7553c83
Added Symbol.iterator as a defined property
philippedistributive Jan 3, 2024
88de8bb
Update tests/python/test_arrays.py
philippedistributive Jan 3, 2024
3b9b6b7
keys back in, better tests, reverse fix
philippedistributive Jan 3, 2024
138a84d
All copying methods replaced with non-copying ones
philippedistributive Jan 11, 2024
694c1e6
improved docs
philippedistributive Jan 11, 2024
3ddc130
cleanup
philippedistributive Jan 11, 2024
c6b82ee
improved naming
philippedistributive Jan 11, 2024
519beab
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
79c830e
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
c541f5a
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
b05ae54
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
5d1bb31
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
ae2ac52
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
558b39b
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
b78d156
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
05610a9
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
ff80136
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
5444f7d
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
7022759
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
72a5025
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
58c736d
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
5a6a033
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
e088b35
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
132bba8
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
66a4cc8
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
0df2e1f
Update tests/python/test_arrays.py
philippedistributive Jan 11, 2024
15063d7
fixes and improved tests
philippedistributive Jan 11, 2024
2b61ec3
improved tests
philippedistributive Jan 11, 2024
9cf3306
use latest spider monkey esr
philippedistributive Jan 11, 2024
72d3e77
added node license
philippedistributive Jan 11, 2024
390f3da
test fix
philippedistributive Jan 11, 2024
0a78d75
restore firefox version
philippedistributive Jan 11, 2024
056419f
improved mem usage in flatX methods
philippedistributive Jan 11, 2024
b6963cb
fix memory issue bad rootedobject usage
philippedistributive Jan 12, 2024
11dc2d6
improved test
philippedistributive Jan 12, 2024
1015419
fix memory usage, cleanup
philippedistributive Jan 12, 2024
a3efcd8
sort done for lists as arrays
philippedistributive Jan 12, 2024
d489be8
cleanup
philippedistributive Jan 12, 2024
931e772
logic cleanup
philippedistributive Jan 12, 2024
e82e3de
cleanup
philippedistributive Jan 12, 2024
ff84e70
improvements: instanceof Array now works on Python Lists,
philippedistributive Jan 15, 2024
46046c9
added getBuiltInClass for Dirt proxy
philippedistributive Jan 15, 2024
5020a5e
should have been part of previous commit
philippedistributive Jan 15, 2024
dfa5368
Merge branch 'main' into philippe/fix/176-plus
philippedistributive Jan 23, 2024
4757085
remove unused variable
philippedistributive Jan 24, 2024
ab460ca
proper way to turn on iterator helpers
philippedistributive Jan 24, 2024
84f8412
enhanced tests
philippedistributive Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,51 @@ products or services of Licensee, or any third party.

8. By copying, installing or otherwise using Python, Licensee
agrees to be bound by the terms and conditions of this License
Agreement.
Agreement.

-------------------------------------------------------------------------------

Copyright Node.js contributors. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""

This license applies to parts of Node.js originating from the
https://github.com/joyent/node repository:

"""
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ js_eval("console.log")('hello, world')
- Python host environment supplies basic subsets of NodeJS's fs, path, process, etc, modules; as-needed by dcp-client (other project?)
- [done] Python TypedArrays coerce to JS TypeArrays
- [done] JS TypedArrays coerce to Python TypeArrays
- [done] Python List coerce to JS Arrays
- [done] JS Arrays coerce to Python Lists, providing all List methods implemented on Arrays
- [done] Python List coerce to JS Arrays, providing all Array methods implemented on Lists

## Build Instructions

Expand Down
2 changes: 1 addition & 1 deletion include/JSArrayProxy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
typedef struct {
PyListObject list;
JS::RootedObject jsObject;
JS::RootedObject jsArray;
} JSArrayProxy;

/**
Expand Down
30 changes: 25 additions & 5 deletions include/PyProxyHandler.hh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @file PyProxy.hh
* @author Caleb Aikens (caleb@distributive.network)
* @brief Struct for creating JS proxy objects. Used by DictType for object coercion
* @file PyProxyHandler.hh
* @author Caleb Aikens (caleb@distributive.network) and Philippe Laporte (philippe@distributive.network)
* @brief Structs for creating JS proxy objects. Used by DictType for object coercion and by ListType for List coercion
* @version 0.1
* @date 2023-04-20
*
* Copyright (c) 2023 Distributive Corp.
* Copyright (c) 2023-2024 Distributive Corp.
*
*/

Expand All @@ -30,6 +30,14 @@ public:
bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible) const override final;
};

enum ProxySlots {PyObjectSlot};

typedef struct {
const char *name; /* The name of the method */
JSNative call; /* The C function that implements it */
uint16_t nargs; /* The argument count for the method */
} JSMethodDef;

/**
* @brief This struct is the ProxyHandler for JS Proxy Objects pythonmonkey creates to handle coercion from python dicts to JS Objects
*
Expand Down Expand Up @@ -157,17 +165,27 @@ public:
JS::HandleId id,
JS::Handle<JS::PropertyDescriptor> desc,
JS::ObjectOpResult &result) const override;

bool getBuiltinClass(JSContext *cx, JS::HandleObject proxy, js::ESClass *cls) const override;
};

/**
* @brief This struct is the ProxyHandler for JS Proxy Objects pythonmonkey creates
* to handle coercion from python lists to JS Array-like objects
* to handle coercion from python lists to JS Array objects
*/
struct PyListProxyHandler : public PyBaseProxyHandler {
public:
PyListProxyHandler(PyObject *pyObj) : PyBaseProxyHandler(pyObj, &family) {};
static const char family;

/**
* @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;

bool getOwnPropertyDescriptor(
JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> desc
Expand All @@ -180,6 +198,8 @@ public:

bool ownPropertyKeys(JSContext *cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const override;
bool delete_(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult &result) const override;
bool isArray(JSContext *cx, JS::HandleObject proxy, JS::IsArrayAnswer *answer) const override;
bool getBuiltinClass(JSContext *cx, JS::HandleObject proxy, js::ESClass *cls) const override;
};

/**
Expand Down
Loading
Loading