~ubuntu-branches/ubuntu/oneiric/swig1.3/oneiric

« back to all changes in this revision

Viewing changes to Lib/python/pyhead.swg

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2009-11-15 14:00:28 UTC
  • mfrom: (1.2.9 upstream) (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091115140028-me7amr2rie8zz1xn
Tags: 1.3.40-2ubuntu1
* Merge from Debian testing (LP: #356529), remaining changes:
  - Drop libchicken-dev from the build-depends (it's in universe)
  - Remove Pike from package description and from configure flags
  - drop "--without-mzscheme", we don't have it in our build-depends
  - use php-config5
  - Clean Runtime/ as well.
  - debian/rules (clean): Remove Lib/ocaml/swigp4.ml.
* debian/rules: Remove hardcoded python version.
* Remove upper limit for python from Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Compatibility macros for Python 3 */
 
2
#if PY_VERSION_HEX >= 0x03000000
 
3
 
 
4
#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
 
5
#define PyInt_Check(x) PyLong_Check(x)
 
6
#define PyInt_AsLong(x) PyLong_AsLong(x)
 
7
#define PyInt_FromLong(x) PyLong_FromLong(x)
 
8
#define PyString_Format(fmt, args)  PyUnicode_Format(fmt, args)
 
9
 
 
10
#endif
 
11
 
 
12
#ifndef Py_TYPE
 
13
#  define Py_TYPE(op) ((op)->ob_type)
 
14
#endif
 
15
 
 
16
/* SWIG APIs for compatibility of both Python 2 & 3 */
 
17
 
 
18
#if PY_VERSION_HEX >= 0x03000000
 
19
#  define SWIG_Python_str_FromFormat PyUnicode_FromFormat
 
20
#else
 
21
#  define SWIG_Python_str_FromFormat PyString_FromFormat
 
22
#endif
 
23
 
 
24
 
 
25
/* Warning: This function will allocate a new string in Python 3,
 
26
 * so please call SWIG_Python_str_DelForPy3(x) to free the space.
 
27
 */
 
28
SWIGINTERN char*
 
29
SWIG_Python_str_AsChar(PyObject *str)
 
30
{
 
31
#if PY_VERSION_HEX >= 0x03000000
 
32
  char *cstr;
 
33
  char *newstr;
 
34
  Py_ssize_t len;
 
35
  str = PyUnicode_AsUTF8String(str);
 
36
  PyBytes_AsStringAndSize(str, &cstr, &len);
 
37
  newstr = (char *) malloc(len+1);
 
38
  memcpy(newstr, cstr, len+1);
 
39
  Py_XDECREF(str);
 
40
  return newstr;
 
41
#else
 
42
  return PyString_AsString(str);
 
43
#endif
 
44
}
 
45
 
 
46
#if PY_VERSION_HEX >= 0x03000000
 
47
#  define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
 
48
#else
 
49
#  define SWIG_Python_str_DelForPy3(x) 
 
50
#endif
 
51
 
 
52
 
 
53
SWIGINTERN PyObject*
 
54
SWIG_Python_str_FromChar(const char *c)
 
55
{
 
56
#if PY_VERSION_HEX >= 0x03000000
 
57
  return PyUnicode_FromString(c); 
 
58
#else
 
59
  return PyString_FromString(c);
 
60
#endif
 
61
}
1
62
 
2
63
/* Add PyOS_snprintf for old Pythons */
3
64
#if PY_VERSION_HEX < 0x02020000
44
105
#  define PyObject_GenericGetAttr 0
45
106
# endif
46
107
#endif
 
108
 
47
109
/* Py_NotImplemented is defined in 2.1 and up. */
48
110
#if PY_VERSION_HEX < 0x02010000
49
111
# ifndef Py_NotImplemented
51
113
# endif
52
114
#endif
53
115
 
54
 
 
55
116
/* A crude PyString_AsStringAndSize implementation for old Pythons */
56
117
#if PY_VERSION_HEX < 0x02010000
57
118
# ifndef PyString_AsStringAndSize
66
127
# endif
67
128
#endif
68
129
 
69
 
 
70
130
/* PyBool_FromLong for old Pythons */
71
131
#if PY_VERSION_HEX < 0x02030000
72
132
static