Fixed some old PyInt usage, drastically reduced compile-time warnings
This commit is contained in:
parent
2c42b82799
commit
46a9a86085
6 changed files with 27 additions and 36 deletions
19
llvm/_core.c
19
llvm/_core.c
|
|
@ -32,10 +32,7 @@
|
||||||
#include "wrap.h"
|
#include "wrap.h"
|
||||||
#include "extra.h"
|
#include "extra.h"
|
||||||
|
|
||||||
/* Project-wide setting */
|
|
||||||
#if (PY_MAJOR_VERSION >= 3)
|
|
||||||
#define LLVM_PY_USE_PYCAPSULE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Python include
|
// Python include
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
|
@ -55,6 +52,10 @@
|
||||||
typedef int Py_ssize_t;
|
typedef int Py_ssize_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Project-wide setting */
|
||||||
|
#if (PY_MAJOR_VERSION >= 3)
|
||||||
|
#define LLVM_PY_USE_PYCAPSULE
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
/* Modules */
|
/* Modules */
|
||||||
|
|
@ -66,7 +67,7 @@ _wLLVMModuleCreateWithName(PyObject *self, PyObject *args)
|
||||||
const char *s;
|
const char *s;
|
||||||
LLVMModuleRef module;
|
LLVMModuleRef module;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "y#", &s))
|
if (!PyArg_ParseTuple(args, "s", &s))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
module = LLVMModuleCreateWithName(s);
|
module = LLVMModuleCreateWithName(s);
|
||||||
|
|
@ -430,7 +431,7 @@ _wLLVMConstString(PyObject *self, PyObject *args)
|
||||||
int dont_null_terminate;
|
int dont_null_terminate;
|
||||||
LLVMValueRef val;
|
LLVMValueRef val;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "y#i", &s, &dont_null_terminate))
|
if (!PyArg_ParseTuple(args, "si", &s, &dont_null_terminate))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
val = LLVMConstString(s, strlen(s), dont_null_terminate);
|
val = LLVMConstString(s, strlen(s), dont_null_terminate);
|
||||||
|
|
@ -647,7 +648,7 @@ _wLLVMBuildInvoke(PyObject *self, PyObject *args)
|
||||||
LLVMBasicBlockRef then_blk, catch_blk;
|
LLVMBasicBlockRef then_blk, catch_blk;
|
||||||
LLVMValueRef inst;
|
LLVMValueRef inst;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "OOOOOy#", &obj1, &obj2, &obj3, &obj4, &obj5, &name))
|
if (!PyArg_ParseTuple(args, "OOOOOs", &obj1, &obj2, &obj3, &obj4, &obj5, &name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef LLVM_PY_USE_PYCAPSULE
|
#ifdef LLVM_PY_USE_PYCAPSULE
|
||||||
|
|
@ -763,7 +764,7 @@ _wLLVMCreateMemoryBufferWithContentsOfFile(PyObject *self, PyObject *args)
|
||||||
char *outmsg;
|
char *outmsg;
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "y#", &path))
|
if (!PyArg_ParseTuple(args, "s", &path))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!LLVMCreateMemoryBufferWithContentsOfFile(path, &ref, &outmsg)) {
|
if (!LLVMCreateMemoryBufferWithContentsOfFile(path, &ref, &outmsg)) {
|
||||||
|
|
@ -1221,7 +1222,7 @@ _wLLVMLoadLibraryPermanently(PyObject *self, PyObject *args)
|
||||||
char *outmsg;
|
char *outmsg;
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "y#", &filename)) {
|
if (!PyArg_ParseTuple(args, "s", &filename)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,6 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Project-wide setting */
|
|
||||||
#if (PY_MAJOR_VERSION >= 3)
|
|
||||||
#define LLVM_PY_USE_PYCAPSULE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These are some "extra" functions not available in the standard LLVM-C
|
* These are some "extra" functions not available in the standard LLVM-C
|
||||||
* bindings, but are required / good-to-have inorder to implement the
|
* bindings, but are required / good-to-have inorder to implement the
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,6 @@
|
||||||
#ifndef LLVM_PY_EXTRA_H
|
#ifndef LLVM_PY_EXTRA_H
|
||||||
#define LLVM_PY_EXTRA_H
|
#define LLVM_PY_EXTRA_H
|
||||||
|
|
||||||
/* Project-wide setting */
|
|
||||||
#if (PY_MAJOR_VERSION >= 3)
|
|
||||||
#define LLVM_PY_USE_PYCAPSULE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ _define_std_ctor(LLVMGenericValueRef)
|
||||||
|
|
||||||
PyObject *ctor_int(int i)
|
PyObject *ctor_int(int i)
|
||||||
{
|
{
|
||||||
return PyInt_FromLong(i);
|
return PyLong_FromLong((long)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *ctor_llvmwrap_ull(llvmwrap_ull ull)
|
PyObject *ctor_llvmwrap_ull(llvmwrap_ull ull)
|
||||||
|
|
|
||||||
30
llvm/wrap.h
30
llvm/wrap.h
|
|
@ -35,10 +35,6 @@
|
||||||
#ifndef LLVM_PY_WRAP_H
|
#ifndef LLVM_PY_WRAP_H
|
||||||
#define LLVM_PY_WRAP_H
|
#define LLVM_PY_WRAP_H
|
||||||
|
|
||||||
/* Project-wide setting */
|
|
||||||
#if PY_MAJOR_VERSION >= 3
|
|
||||||
#define LLVM_PY_USE_PYCAPSULE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* python includes */
|
/* python includes */
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
@ -50,6 +46,11 @@
|
||||||
#include "llvm-c/ExecutionEngine.h"
|
#include "llvm-c/ExecutionEngine.h"
|
||||||
#include "llvm-c/Target.h"
|
#include "llvm-c/Target.h"
|
||||||
|
|
||||||
|
/* Project-wide setting */
|
||||||
|
#if PY_MAJOR_VERSION >= 3
|
||||||
|
#define LLVM_PY_USE_PYCAPSULE
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
/* Typedefs */
|
/* Typedefs */
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
|
@ -135,7 +136,6 @@ PyObject *make_list_from_LLVMValueRef_array(LLVMValueRef *p, unsigned n);
|
||||||
*** PyCapsule Calls
|
*** PyCapsule Calls
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#error "Capsule @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap LLVM functions of the type
|
* Wrap LLVM functions of the type
|
||||||
|
|
@ -330,7 +330,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
{ \
|
{ \
|
||||||
const char *arg1; \
|
const char *arg1; \
|
||||||
\
|
\
|
||||||
if (!PyArg_ParseTuple(args, "y#", &arg1)) \
|
if (!PyArg_ParseTuple(args, "s", &arg1)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1)); \
|
return ctor_ ## outtype ( func (arg1)); \
|
||||||
|
|
@ -395,7 +395,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
const char *arg2; \
|
const char *arg2; \
|
||||||
intype1 arg1; \
|
intype1 arg1; \
|
||||||
\
|
\
|
||||||
if (!PyArg_ParseTuple(args, "Oy#", &obj1, &arg2)) \
|
if (!PyArg_ParseTuple(args, "Os", &obj1, &arg2)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
||||||
|
|
@ -416,7 +416,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
const char *arg2; \
|
const char *arg2; \
|
||||||
intype1 arg1; \
|
intype1 arg1; \
|
||||||
\
|
\
|
||||||
if (!PyArg_ParseTuple(args, "Oy#", &obj1, &arg2)) \
|
if (!PyArg_ParseTuple(args, "Os", &obj1, &arg2)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
||||||
|
|
@ -479,7 +479,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
intype2 arg2; \
|
intype2 arg2; \
|
||||||
const char *arg3; \
|
const char *arg3; \
|
||||||
\
|
\
|
||||||
if (!PyArg_ParseTuple(args, "OOy#", &obj1, &obj2, &arg3)) \
|
if (!PyArg_ParseTuple(args, "OOs", &obj1, &obj2, &arg3)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
||||||
|
|
@ -588,7 +588,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
const char *arg2; \
|
const char *arg2; \
|
||||||
intype3 arg3; \
|
intype3 arg3; \
|
||||||
\
|
\
|
||||||
if (!PyArg_ParseTuple(args, "Oy#O", &obj1, &arg2, &obj3)) \
|
if (!PyArg_ParseTuple(args, "OsO", &obj1, &arg2, &obj3)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
||||||
|
|
@ -612,7 +612,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
int arg3; \
|
int arg3; \
|
||||||
const char *arg4; \
|
const char *arg4; \
|
||||||
\
|
\
|
||||||
if (!PyArg_ParseTuple(args, "OOiy#", &obj1, &obj2, &arg3, &arg4)) \
|
if (!PyArg_ParseTuple(args, "OOis", &obj1, &obj2, &arg3, &arg4)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
||||||
|
|
@ -635,7 +635,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
intype3 arg3; \
|
intype3 arg3; \
|
||||||
const char *arg4; \
|
const char *arg4; \
|
||||||
\
|
\
|
||||||
if (!PyArg_ParseTuple(args, "OOOy#", &obj1, &obj2, &obj3, &arg4)) \
|
if (!PyArg_ParseTuple(args, "OOOs", &obj1, &obj2, &obj3, &arg4)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
||||||
|
|
@ -709,7 +709,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
intype4 arg4; \
|
intype4 arg4; \
|
||||||
const char *arg5; \
|
const char *arg5; \
|
||||||
\
|
\
|
||||||
if (!PyArg_ParseTuple(args, "OOOOy#", &obj1, &obj2, &obj3, &obj4, &arg5)) \
|
if (!PyArg_ParseTuple(args, "OOOOs", &obj1, &obj2, &obj3, &obj4, &arg5)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
||||||
|
|
@ -735,7 +735,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
intype4 arg4; \
|
intype4 arg4; \
|
||||||
const char *arg5; \
|
const char *arg5; \
|
||||||
\
|
\
|
||||||
if (!PyArg_ParseTuple(args, "OiOOy#", &obj1, &arg2, &obj3, &obj4, &arg5)) \
|
if (!PyArg_ParseTuple(args, "OiOOs", &obj1, &arg2, &obj3, &obj4, &arg5)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
||||||
|
|
@ -931,7 +931,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
unsigned arg3n; \
|
unsigned arg3n; \
|
||||||
outtype ret; \
|
outtype ret; \
|
||||||
\
|
\
|
||||||
if (!PyArg_ParseTuple(args, "OOOy#", &obj1, &obj2, &obj3, &arg4))\
|
if (!PyArg_ParseTuple(args, "OOOs", &obj1, &obj2, &obj3, &arg4))\
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ from llvm.passes import *
|
||||||
|
|
||||||
ti = Type.int()
|
ti = Type.int()
|
||||||
|
|
||||||
|
|
||||||
def do_llvmexception():
|
def do_llvmexception():
|
||||||
print(" Testing class LLVMException")
|
print(" Testing class LLVMException")
|
||||||
e = LLVMException()
|
e = LLVMException()
|
||||||
|
|
@ -36,6 +35,7 @@ def do_misc():
|
||||||
except LLVMException:
|
except LLVMException:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
|
print(" ... second one now")
|
||||||
load_library_permanently("no*such*so")
|
load_library_permanently("no*such*so")
|
||||||
except LLVMException:
|
except LLVMException:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue