Mercurial > pytave
annotate oct-py-types.h @ 328:5782d7932529
Automatically convert Python 2 'int' type to Octave int64 (fixes issue #56)
* oct-py-types.cc, oct-py-types.h (pytave::extract_py_int64): New function.
* python_to_octave.cc (pytave::pyobj_to_octvalue): Convert Python 2 'int' to
Octave int64 type.
* @py/py.m, pycall.cc: Add %!tests for Python 'int' and 'long' type handling,
conditional on Python version.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Sat, 13 Aug 2016 23:52:57 -0700 |
parents | fd5881d48238 |
children | c081e30c2f64 |
rev | line source |
---|---|
320
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
1 /* |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
2 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
3 Copyright (C) 2016 Mike Miller |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
4 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
5 This file is part of Pytave. |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
6 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
7 Pytave is free software; you can redistribute it and/or modify it |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
10 option) any later version. |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
11 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
12 Pytave is distributed in the hope that it will be useful, but WITHOUT |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
15 for more details. |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
16 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
18 along with Pytave; see the file COPYING. If not, see |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
20 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
21 */ |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
22 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
23 #if ! defined (pytave_oct_py_types_h) |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
24 #define pytave_oct_py_types_h 1 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
25 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
26 #include <Python.h> |
325
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
27 #include <string> |
320
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
28 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
29 class octave_scalar_map; |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
30 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
31 namespace pytave |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
32 { |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
33 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
34 PyObject * |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
35 make_py_dict (const octave_scalar_map& map); |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
36 |
328
5782d7932529
Automatically convert Python 2 'int' type to Octave int64 (fixes issue #56)
Mike Miller <mtmiller@octave.org>
parents:
325
diff
changeset
|
37 int64_t |
5782d7932529
Automatically convert Python 2 'int' type to Octave int64 (fixes issue #56)
Mike Miller <mtmiller@octave.org>
parents:
325
diff
changeset
|
38 extract_py_int64 (PyObject *obj); |
5782d7932529
Automatically convert Python 2 'int' type to Octave int64 (fixes issue #56)
Mike Miller <mtmiller@octave.org>
parents:
325
diff
changeset
|
39 |
325
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
40 std::string |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
41 extract_py_str (PyObject *obj); |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
42 |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
43 PyObject * |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
44 make_py_str (const std::string& str); |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
45 |
320
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
46 } |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
47 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
48 #endif |