yaze_py rename src and header, add boost::python

This commit is contained in:
scawful
2024-08-07 01:08:13 -04:00
parent 3631a962bc
commit 2a1509b311
3 changed files with 30 additions and 6 deletions

33
src/py/yaze_py.cc Normal file
View File

@@ -0,0 +1,33 @@
#include "yaze_py.h"
#include <Python.h>
#include <boost/python.hpp>
#include "yaze.h"
BOOST_PYTHON_MODULE(yaze) {
using namespace boost::python;
def("yaze_init", yaze_init);
class_<Rom>("Rom")
.def_readonly("filename", &Rom::filename)
.def_readonly("data", &Rom::data)
.def_readonly("size", &Rom::size)
.def_readonly("impl", &Rom::impl);
}
static PyObject *SpamError;
static PyObject *yaze_init(PyObject *self, PyObject *args) {
const char *command;
int sts;
if (!PyArg_ParseTuple(args, "s", &command)) return NULL;
sts = system(command);
if (sts < 0) {
PyErr_SetString(SpamError, "System command failed");
return NULL;
}
return PyLong_FromLong(sts);
}