You've already forked gnatstudio
mirror of
https://github.com/AdaCore/gnatstudio.git
synced 2026-02-12 12:42:33 -08:00
(ada_pyfunction_check, ada_pyfunction_get_globals, ada_pyfunction_get_code,
ada_pyfunction_get_closure, ada_pyfunction_get_defaults, ada_PyEval_EvalCodeEx): New subprograms git-svn-id: svn+ssh://svn.eu/Dev/importfromcvs/trunk@85809 936e1b1b-40f2-da11-902a-00137254ae57
This commit is contained in:
@@ -1,3 +1,23 @@
|
||||
/*-------------------------------------------------------------------
|
||||
G P S --
|
||||
--
|
||||
Copyright (C) 2003 --
|
||||
ACT-Europe --
|
||||
--
|
||||
GPS is free software; you can redistribute it and/or modify it --
|
||||
under the terms of the GNU General Public License as published by --
|
||||
the Free Software Foundation; either version 2 of the License, or --
|
||||
(at your option) any later version. --
|
||||
--
|
||||
This program is distributed in the hope that it will be useful, --
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of --
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
|
||||
General Public License for more details. You should have received --
|
||||
a copy of the GNU General Public License along with this library; --
|
||||
if not, write to the Free Software Foundation, Inc., 59 Temple --
|
||||
Place - Suite 330, Boston, MA 02111-1307, USA. --
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
void ada_py_incref (PyObject* obj) {
|
||||
@@ -24,6 +44,77 @@ int ada_pyint_check (PyObject* obj) {
|
||||
return PyInt_Check (obj);
|
||||
}
|
||||
|
||||
int ada_pyfunction_check (PyObject* obj) {
|
||||
return PyFunction_Check (obj);
|
||||
}
|
||||
|
||||
PyObject* ada_pyfunction_get_globals (PyObject* obj) {
|
||||
return PyFunction_GET_GLOBALS (obj);
|
||||
}
|
||||
|
||||
PyObject* ada_pyfunction_get_code (PyObject* obj) {
|
||||
return PyFunction_GET_CODE (obj);
|
||||
}
|
||||
|
||||
PyObject* ada_pyfunction_get_closure (PyObject* obj) {
|
||||
return PyFunction_GET_CLOSURE (obj);
|
||||
}
|
||||
|
||||
PyObject* ada_pyfunction_get_defaults (PyObject* obj) {
|
||||
return PyFunction_GET_DEFAULTS (obj);
|
||||
}
|
||||
|
||||
PyObject* ada_PyEval_EvalCodeEx
|
||||
(PyObject *co,
|
||||
PyObject *globals,
|
||||
PyObject *locals,
|
||||
PyObject *args,
|
||||
PyObject *kwds,
|
||||
PyObject *defs,
|
||||
PyObject *closure)
|
||||
{
|
||||
PyObject **k, **d;
|
||||
PyObject* result;
|
||||
int nk, nd;
|
||||
|
||||
if (defs != NULL && PyTuple_Check(defs)) {
|
||||
d = &PyTuple_GET_ITEM((PyTupleObject *)defs, 0);
|
||||
nd = PyTuple_Size(defs);
|
||||
} else {
|
||||
d = NULL;
|
||||
nd = 0;
|
||||
}
|
||||
|
||||
if (kwds != NULL && PyDict_Check(kwds)) {
|
||||
int pos, i;
|
||||
nk = PyDict_Size(kwds);
|
||||
k = PyMem_NEW(PyObject *, 2*nk);
|
||||
if (k == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
pos = i = 0;
|
||||
while (PyDict_Next(kwds, &pos, &k[i], &k[i+1]))
|
||||
i += 2;
|
||||
nk = i/2;
|
||||
/* XXX This is broken if the caller deletes dict items! */
|
||||
} else {
|
||||
k = NULL;
|
||||
nk = 0;
|
||||
}
|
||||
|
||||
result = (PyObject*) PyEval_EvalCodeEx
|
||||
(co, globals, locals,
|
||||
&PyTuple_GET_ITEM (args, 0), PyTuple_Size (args), k, nk, d, nd, closure);
|
||||
|
||||
if (k != NULL) {
|
||||
PyMem_DEL (k);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int ada_pycobject_check (PyObject* obj) {
|
||||
return PyCObject_Check (obj);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user