-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GR-57635] Implement sq_repeat and nb_multiply CPython like slots.
PullRequest: graalpython/3478
- Loading branch information
Showing
42 changed files
with
657 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
graalpython/com.oracle.graal.python.test/src/tests/cpyext/fuzzer_test10.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* The Universal Permissive License (UPL), Version 1.0 | ||
* | ||
* Subject to the condition set forth below, permission is hereby granted to any | ||
* person obtaining a copy of this software, associated documentation and/or | ||
* data (collectively the "Software"), free of charge and under any and all | ||
* copyright rights in the Software, and any and all patent rights owned or | ||
* freely licensable by each licensor hereunder covering either (i) the | ||
* unmodified Software as contributed to or provided by such licensor, or (ii) | ||
* the Larger Works (as defined below), to deal in both | ||
* | ||
* (a) the Software, and | ||
* | ||
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if | ||
* one is included with the Software each a "Larger Work" to which the Software | ||
* is contributed by such licensors), | ||
* | ||
* without restriction, including without limitation the rights to copy, create | ||
* derivative works of, display, perform, and distribute the Software and make, | ||
* use, sell, offer for sale, import, export, have made, and have sold the | ||
* Software and the Larger Work(s), and to sublicense the foregoing rights on | ||
* either these or other terms. | ||
* | ||
* This license is subject to the following condition: | ||
* | ||
* The above copyright notice and either this complete permission notice or at a | ||
* minimum a reference to the UPL must 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. | ||
*/ | ||
// Generated by the slots_fuzzer.py | ||
#include <Python.h> | ||
|
||
PyObject *global_stash1; | ||
PyObject *global_stash2; | ||
|
||
int Native0_nb_bool(PyObject *self) { return 1; } | ||
PyObject *Native0_nb_add(PyObject *self, PyObject *other) { | ||
return Py_NewRef(self); | ||
} | ||
Py_ssize_t Native0_sq_length(PyObject *self) { return 1; } | ||
PyObject *Native0_sq_concat(PyObject *self, PyObject *other) { | ||
return PyLong_FromLong(10); | ||
} | ||
PyObject *Native0_sq_repeat(PyObject *self, Py_ssize_t count) { | ||
return PyLong_FromLong(count); | ||
} | ||
Py_ssize_t Native0_mp_length(PyObject *self) { return 42; } | ||
PyObject *Native0_tp_getattr(PyObject *self, char *name) { | ||
return Py_NewRef(self); | ||
} | ||
PyObject *Native0_tp_getattro(PyObject *self, PyObject *name) { | ||
return Py_NewRef(self); | ||
} | ||
PyObject *Native0_tp_descr_get(PyObject *self, PyObject *key, PyObject *type) { | ||
Py_RETURN_NONE; | ||
} | ||
int Native0_tp_descr_set(PyObject *self, PyObject *key, PyObject *value) { | ||
return 0; | ||
} | ||
|
||
PyNumberMethods Native0_tp_as_number = { | ||
.nb_bool = &Native0_nb_bool, | ||
.nb_add = &Native0_nb_add, | ||
}; | ||
PySequenceMethods Native0_tp_as_sequence = { | ||
.sq_length = &Native0_sq_length, | ||
.sq_concat = &Native0_sq_concat, | ||
.sq_repeat = &Native0_sq_repeat, | ||
}; | ||
PyMappingMethods Native0_tp_as_mapping = { | ||
.mp_length = &Native0_mp_length, | ||
}; | ||
|
||
static PyTypeObject CustomType_Native0 = { | ||
.ob_base = PyVarObject_HEAD_INIT(NULL, 0).tp_name = "test10.Native0", | ||
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, | ||
.tp_new = PyType_GenericNew, | ||
.tp_as_number = &Native0_tp_as_number, | ||
.tp_as_sequence = &Native0_tp_as_sequence, | ||
.tp_as_mapping = &Native0_tp_as_mapping, | ||
.tp_getattr = &Native0_tp_getattr, | ||
.tp_getattro = &Native0_tp_getattro, | ||
.tp_descr_get = &Native0_tp_descr_get, | ||
.tp_descr_set = &Native0_tp_descr_set, | ||
|
||
}; | ||
|
||
static PyObject *create_Native0(PyObject *module, PyObject *args) { | ||
if (PyType_Ready(&CustomType_Native0) < 0) | ||
return NULL; | ||
Py_INCREF(&CustomType_Native0); | ||
return (PyObject *)&CustomType_Native0; | ||
} | ||
|
||
static struct PyMethodDef test_module_methods[] = { | ||
{"create_Native0", (PyCFunction)create_Native0, METH_VARARGS, ""}, | ||
{NULL, NULL, 0, NULL}}; | ||
static PyModuleDef test_module = {PyModuleDef_HEAD_INIT, | ||
"fuzzer_test10", | ||
"", | ||
-1, | ||
test_module_methods, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL}; | ||
|
||
PyMODINIT_FUNC PyInit_fuzzer_test10(void) { | ||
return PyModule_Create(&test_module); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.