Revert rev 11187 "Merged with recent changes from trunk."
This reverts commit c595e4d90ebfd63eb55430c735bb121cf690bd59. Conflicts: Source/Modules/c.cxx From: William S Fulton <wsf@fultondesigns.co.uk> git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@13033 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
34a628c7c7
commit
d6b81eb831
703 changed files with 9266 additions and 21128 deletions
|
|
@ -27,24 +27,11 @@ extern int gcd(int x, int y);
|
|||
$2 = (char **) malloc(($1+1)*sizeof(char *));
|
||||
for (i = 0; i < $1; i++) {
|
||||
PyObject *s = PyList_GetItem($input,i);
|
||||
%#if PY_VERSION_HEX >= 0x03000000
|
||||
if (!PyUnicode_Check(s))
|
||||
%#else
|
||||
if (!PyString_Check(s))
|
||||
%#endif
|
||||
{
|
||||
if (!PyString_Check(s)) {
|
||||
free($2);
|
||||
SWIG_exception(SWIG_ValueError, "List items must be strings");
|
||||
}
|
||||
%#if PY_VERSION_HEX >= 0x03000000
|
||||
{
|
||||
int l;
|
||||
$2[i] = PyUnicode_AsStringAndSize(s, &l);
|
||||
}
|
||||
%#else
|
||||
$2[i] = PyString_AsString(s);
|
||||
%#endif
|
||||
|
||||
}
|
||||
$2[i] = 0;
|
||||
}
|
||||
|
|
@ -52,21 +39,12 @@ extern int gcd(int x, int y);
|
|||
extern int gcdmain(int argc, char *argv[]);
|
||||
|
||||
%typemap(in) (char *bytes, int len) {
|
||||
|
||||
%#if PY_VERSION_HEX >= 0x03000000
|
||||
if (!PyUnicode_Check($input)) {
|
||||
PyErr_SetString(PyExc_ValueError,"Expected a string");
|
||||
return NULL;
|
||||
}
|
||||
$1 = PyUnicode_AsStringAndSize($input, &$2);
|
||||
%#else
|
||||
if (!PyString_Check($input)) {
|
||||
PyErr_SetString(PyExc_ValueError,"Expected a string");
|
||||
return NULL;
|
||||
}
|
||||
$1 = PyString_AsString($input);
|
||||
$2 = PyString_Size($input);
|
||||
%#endif
|
||||
}
|
||||
|
||||
extern int count(char *bytes, int len, char c);
|
||||
|
|
@ -78,15 +56,9 @@ extern int count(char *bytes, int len, char c);
|
|||
so that we don't violate it's mutability */
|
||||
|
||||
%typemap(in) (char *str, int len) {
|
||||
%#if PY_VERSION_HEX >= 0x03000000
|
||||
$2 = PyUnicode_GetSize($input);
|
||||
$1 = (char *) malloc($2+1);
|
||||
memmove($1,PyUnicode_AsString($input),$2);
|
||||
%#else
|
||||
$2 = PyString_Size($input);
|
||||
$1 = (char *) malloc($2+1);
|
||||
memmove($1,PyString_AsString($input),$2);
|
||||
%#endif
|
||||
}
|
||||
|
||||
/* Return the mutated string as a new object. The t_output_helper
|
||||
|
|
@ -95,11 +67,7 @@ extern int count(char *bytes, int len, char c);
|
|||
|
||||
%typemap(argout) (char *str, int len) {
|
||||
PyObject *o;
|
||||
%#if PY_VERSION_HEX >= 0x03000000
|
||||
o = PyUnicode_FromStringAndSize($1,$2);
|
||||
%#else
|
||||
o = PyString_FromStringAndSize($1,$2);
|
||||
%#endif
|
||||
$result = t_output_helper($result,o);
|
||||
free($1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue