-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7761a1
commit 1a80c4d
Showing
3 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from __future__ import annotations | ||
|
||
from setuptools import Extension, setup | ||
|
||
setup( | ||
ext_modules=[ | ||
Extension( | ||
name="basedtyping.type_alias_value_getter", sources=["c/type_alias_value_getter.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,45 @@ | ||
#define PY_SSIZE_T_CLEAN | ||
#include <Python.h> | ||
|
||
typedef struct { | ||
PyObject_HEAD | ||
PyObject *name; | ||
PyObject *type_params; | ||
PyObject *compute_value; | ||
PyObject *value; | ||
PyObject *module; | ||
} typealiasobject; | ||
|
||
static PyObject * | ||
foo_test(PyObject *self, PyObject *args) | ||
{ | ||
PyObject *alias; | ||
if (!PyArg_ParseTuple(args, "O", &alias)) | ||
return NULL; | ||
typealiasobject *ta = (typealiasobject *)alias; | ||
return Py_NewRef(ta->compute_value); | ||
} | ||
|
||
static PyMethodDef foo_methods[] = { | ||
/* The cast of the function is necessary since PyCFunction values | ||
* only take two PyObject* parameters, and keywdarg_parrot() takes | ||
* three. | ||
*/ | ||
{"test", (PyCFunction)(void(*)(void))foo_test, METH_VARARGS, | ||
"debug alias."}, | ||
{NULL, NULL, 0, NULL} /* sentinel */ | ||
}; | ||
|
||
static struct PyModuleDef foo = { | ||
PyModuleDef_HEAD_INIT, | ||
"foo", | ||
NULL, | ||
-1, | ||
foo_methods | ||
}; | ||
|
||
PyMODINIT_FUNC | ||
PyInit_foo(void) | ||
{ | ||
PyModule_Create(&foo); | ||
}; |
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