C Python extension to export an Function
Ganesh Pal
ganesh1pal at gmail.com
Thu Sep 1 02:37:24 EDT 2016
Hi Team,
Iam on python 2.7 and Linux.
Iam pretty new to C Python extension , I was able to export few simple
modules to python and it look like the cool thing to do , but Iam stuck
for with a problem now , Iam not able to figure out how to export
fun_addr_from_addr()
to Python. I would need some suggestion on how to develop a C Python
API for the below piece of code.
1. The end goal is to export fun_addr_from_addr(baddr, *baddr) to Python.
Perhaps by creating a python wrapper for fun_bh_toblkoff() would help me ?
Here is the sample example code.
fun_toblkoff(dda_locn_t *locn,
struct ifs_baddr *baddr, int *poff, int *psize)
{
if (dda_locnparm_get(locn) != OK)
return FAIL;
/* fill in baddr */
*baddr = dda_index_to_baddr(locn->idx);
if (locn->flags & DLFLAG)
locn->xoff = fun_addr_from_addr(baddr, *baddr);
*poff = 0;
*psize = _BSIZE;
return OK;
}
So the primary challenge when writing a wrapper for a single
function is figuring out how to get the arguments from
Python form to C form, and how to get the result back to Python form.
Regards,
Ganesh
More information about the Python-list
mailing list