[pypy-commit] cffi cffi-1.0: more Windows fixes
arigo
noreply at buildbot.pypy.org
Thu Apr 30 01:02:15 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1887:596f69d5291c
Date: 2015-04-30 01:02 +0200
http://bitbucket.org/cffi/cffi/changeset/596f69d5291c/
Log: more Windows fixes
diff --git a/_cffi1/ffi_obj.c b/_cffi1/ffi_obj.c
--- a/_cffi1/ffi_obj.c
+++ b/_cffi1/ffi_obj.c
@@ -124,7 +124,7 @@
index = parse_c_type(&ffi->info, input_text);
if (index < 0) {
size_t num_spaces = ffi->info.error_location;
- char spaces[num_spaces + 1];
+ char *spaces = alloca(num_spaces + 1);
memset(spaces, ' ', num_spaces);
spaces[num_spaces] = '\0';
PyErr_Format(FFIError, "%s\n%s\n%s^", ffi->info.error_message,
@@ -447,16 +447,16 @@
static PyObject *ffi_getctype(FFIObject *self, PyObject *args)
{
- PyObject *cdecl, *res;
+ PyObject *c_decl, *res;
char *p, *replace_with = "";
int add_paren, add_space;
CTypeDescrObject *ct;
size_t replace_with_len;
- if (!PyArg_ParseTuple(args, "O|s:getctype", &cdecl, &replace_with))
+ if (!PyArg_ParseTuple(args, "O|s:getctype", &c_decl, &replace_with))
return NULL;
- ct = _ffi_type(self, cdecl, ACCEPT_STRING|ACCEPT_CTYPE);
+ ct = _ffi_type(self, c_decl, ACCEPT_STRING|ACCEPT_CTYPE);
if (ct == NULL)
return NULL;
@@ -603,20 +603,20 @@
static PyObject *ffi_callback(FFIObject *self, PyObject *args, PyObject *kwds)
{
- PyObject *cdecl, *python_callable = Py_None, *error = Py_None;
+ PyObject *c_decl, *python_callable = Py_None, *error = Py_None;
PyObject *res;
static char *keywords[] = {"cdecl", "python_callable", "error", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", keywords,
- &cdecl, &python_callable, &error))
+ &c_decl, &python_callable, &error))
return NULL;
- cdecl = (PyObject *)_ffi_type(self, cdecl, ACCEPT_STRING | ACCEPT_CTYPE |
- CONSIDER_FN_AS_FNPTR);
- if (cdecl == NULL)
+ c_decl = (PyObject *)_ffi_type(self, c_decl, ACCEPT_STRING | ACCEPT_CTYPE |
+ CONSIDER_FN_AS_FNPTR);
+ if (c_decl == NULL)
return NULL;
- args = Py_BuildValue("(OOO)", cdecl, python_callable, error);
+ args = Py_BuildValue("(OOO)", c_decl, python_callable, error);
if (args == NULL)
return NULL;
diff --git a/_cffi1/parse_c_type.c b/_cffi1/parse_c_type.c
--- a/_cffi1/parse_c_type.c
+++ b/_cffi1/parse_c_type.c
@@ -351,9 +351,11 @@
case TOK_INTEGER:
errno = 0;
+#ifndef MS_WIN32
if (sizeof(length) > sizeof(unsigned long))
length = strtoull(tok->p, &endptr, 0);
else
+#endif
length = strtoul(tok->p, &endptr, 0);
if (endptr != tok->p + tok->size)
return parse_error(tok, "invalid number");
diff --git a/_cffi1/parse_c_type.h b/_cffi1/parse_c_type.h
--- a/_cffi1/parse_c_type.h
+++ b/_cffi1/parse_c_type.h
@@ -1,5 +1,3 @@
-#include <stdint.h>
-
typedef void *_cffi_opcode_t;
@@ -137,7 +135,7 @@
struct _cffi_parse_info_s {
const struct _cffi_type_context_s *ctx;
_cffi_opcode_t *output;
- int output_size;
+ unsigned int output_size;
size_t error_location;
const char *error_message;
};
diff --git a/cffi/ffiplatform.py b/cffi/ffiplatform.py
--- a/cffi/ffiplatform.py
+++ b/cffi/ffiplatform.py
@@ -24,6 +24,7 @@
pass
def get_extension(srcfilename, modname, sources=(), **kwds):
+ _hack_at_distutils() # *before* the following import
from distutils.core import Extension
allsources = [srcfilename]
allsources.extend(sources)
More information about the pypy-commit
mailing list