Python: Reduce boilerplate in builder

This commit is contained in:
Vicki Pfau 2017-05-31 17:47:38 -07:00
parent 7b66a702cf
commit fe2854db79
4 changed files with 17 additions and 27 deletions

View File

@ -29,8 +29,11 @@ void free(void*);
#include <mgba/core/core.h> #include <mgba/core/core.h>
#include <mgba/core/tile-cache.h> #include <mgba/core/tile-cache.h>
#define PYEXPORT extern "Python+C"
#include "platform/python/vfs-py.h" #include "platform/python/vfs-py.h"
#include "platform/python/log.h" #include "platform/python/log.h"
#undef PYEXPORT
#ifdef USE_PNG #ifdef USE_PNG
#include <mgba-util/png-io.h> #include <mgba-util/png-io.h>

View File

@ -32,19 +32,10 @@ ffi.set_source("mgba._pylib", """
#include <mgba-util/png-io.h> #include <mgba-util/png-io.h>
#include <mgba-util/vfs.h> #include <mgba-util/vfs.h>
struct VFile* VFileFromPython(void* fileobj); #define PYEXPORT
#include "platform/python/log.h"
struct VFilePy { #include "platform/python/vfs-py.h"
struct VFile d; #undef PYEXPORT
void* fileobj;
};
struct mLogger* mLoggerPythonCreate(void* pyobj);
struct mLoggerPy {
struct mLogger d;
void* pyobj;
};
""", include_dirs=[incdir, srcdir], """, include_dirs=[incdir, srcdir],
extra_compile_args=cppflags, extra_compile_args=cppflags,
libraries=["mgba"], libraries=["mgba"],

View File

@ -12,4 +12,4 @@ struct mLoggerPy {
struct mLogger* mLoggerPythonCreate(void* pyobj); struct mLogger* mLoggerPythonCreate(void* pyobj);
extern "Python+C" void _pyLog(void* logger, int category, enum mLogLevel level, const char* message); PYEXPORT void _pyLog(void* logger, int category, enum mLogLevel level, const char* message);

View File

@ -13,16 +13,12 @@ struct VFilePy {
struct VFile* VFileFromPython(void* fileobj); struct VFile* VFileFromPython(void* fileobj);
extern "Python+C" { PYEXPORT bool _vfpClose(struct VFile* vf);
PYEXPORT off_t _vfpSeek(struct VFile* vf, off_t offset, int whence);
bool _vfpClose(struct VFile* vf); PYEXPORT ssize_t _vfpRead(struct VFile* vf, void* buffer, size_t size);
off_t _vfpSeek(struct VFile* vf, off_t offset, int whence); PYEXPORT ssize_t _vfpWrite(struct VFile* vf, const void* buffer, size_t size);
ssize_t _vfpRead(struct VFile* vf, void* buffer, size_t size); PYEXPORT void* _vfpMap(struct VFile* vf, size_t size, int flags);
ssize_t _vfpWrite(struct VFile* vf, const void* buffer, size_t size); PYEXPORT void _vfpUnmap(struct VFile* vf, void* memory, size_t size);
void* _vfpMap(struct VFile* vf, size_t size, int flags); PYEXPORT void _vfpTruncate(struct VFile* vf, size_t size);
void _vfpUnmap(struct VFile* vf, void* memory, size_t size); PYEXPORT ssize_t _vfpSize(struct VFile* vf);
void _vfpTruncate(struct VFile* vf, size_t size); PYEXPORT bool _vfpSync(struct VFile* vf, const void* buffer, size_t size);
ssize_t _vfpSize(struct VFile* vf);
bool _vfpSync(struct VFile* vf, const void* buffer, size_t size);
}