Mercurial > pytave
annotate oct-py-types.h @ 395:aa76e98a1a3e
ci: build against both Python 2 and 3
* bitbucket-pipelines.yml: Build and test against both Python 2 and 3.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Fri, 07 Apr 2017 10:47:45 -0700 |
parents | d362cdd1ddeb |
children | c4b78e449c62 |
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> |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
27 #include <complex> |
325
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
28 #include <string> |
320
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
29 |
336
c081e30c2f64
Overhaul Python list creation from cell array
Mike Miller <mtmiller@octave.org>
parents:
328
diff
changeset
|
30 class Cell; |
352
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
31 class FloatNDArray; |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
32 class NDArray; |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
33 template <typename T> class intNDArray; |
320
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
34 class octave_scalar_map; |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
35 class octave_value; |
320
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
36 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
37 namespace pytave |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
38 { |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
39 |
340
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
40 //! Extract the integer value of the given Python bool object. |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
41 //! |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
42 //! @param obj Python bool object |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
43 //! @return @c true or @c false value of @a obj |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
44 bool |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
45 extract_py_bool (PyObject *obj); |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
46 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
47 //! Create a Python bool object with the value of the given @c bool value. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
48 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
49 //! @param value @c true or @c false value |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
50 //! @return Python bool object |
320
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
51 PyObject * |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
52 make_py_bool (bool value); |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
53 |
340
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
54 //! Extract the complex value of the given Python complex object. |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
55 //! |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
56 //! @param obj Python complex object |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
57 //! @return complex value of @a obj |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
58 std::complex<double> |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
59 extract_py_complex (PyObject *obj); |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
60 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
61 //! Create a Python complex object with the value of the given @c complex value. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
62 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
63 //! @param value complex value |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
64 //! @return Python complex object |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
65 PyObject * |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
66 make_py_complex (std::complex<double> value); |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
67 |
340
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
68 //! Extract the floating point value of the given Python float object. |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
69 //! |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
70 //! @param obj Python float object |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
71 //! @return floating point value of @a obj |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
72 double |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
73 extract_py_float (PyObject *obj); |
06b8aeea456f
Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents:
339
diff
changeset
|
74 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
75 //! Create a Python float object with the value of the given @c double value. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
76 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
77 //! @param value floating point value |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
78 //! @return Python float object |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
79 PyObject * |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
80 make_py_float (double value); |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
81 |
344
9d95f087e5aa
Add a function to extract a scalar map value from a Python dict
Mike Miller <mtmiller@octave.org>
parents:
342
diff
changeset
|
82 //! Extract an Octave scalar map from the given Python dict object. |
9d95f087e5aa
Add a function to extract a scalar map value from a Python dict
Mike Miller <mtmiller@octave.org>
parents:
342
diff
changeset
|
83 //! |
9d95f087e5aa
Add a function to extract a scalar map value from a Python dict
Mike Miller <mtmiller@octave.org>
parents:
342
diff
changeset
|
84 //! @param obj Python dict object |
9d95f087e5aa
Add a function to extract a scalar map value from a Python dict
Mike Miller <mtmiller@octave.org>
parents:
342
diff
changeset
|
85 //! @return Octave scalar map containing the items of @a obj |
9d95f087e5aa
Add a function to extract a scalar map value from a Python dict
Mike Miller <mtmiller@octave.org>
parents:
342
diff
changeset
|
86 octave_scalar_map |
9d95f087e5aa
Add a function to extract a scalar map value from a Python dict
Mike Miller <mtmiller@octave.org>
parents:
342
diff
changeset
|
87 extract_py_scalar_map (PyObject *obj); |
9d95f087e5aa
Add a function to extract a scalar map value from a Python dict
Mike Miller <mtmiller@octave.org>
parents:
342
diff
changeset
|
88 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
89 //! Create a Python dict object from the given Octave scalar map value. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
90 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
91 //! The values contained in the map are recursively converted to appropriate |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
92 //! Python values. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
93 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
94 //! @param map Octave scalar map |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
95 //! @return Python dict object |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
96 PyObject * |
320
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
97 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
|
98 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
99 //! Extract the integer value of the given Python int or long object. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
100 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
101 //! @param obj Python int or long object |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
102 //! @return integer value of @a obj |
328
5782d7932529
Automatically convert Python 2 'int' type to Octave int64 (fixes issue #56)
Mike Miller <mtmiller@octave.org>
parents:
325
diff
changeset
|
103 int64_t |
5782d7932529
Automatically convert Python 2 'int' type to Octave int64 (fixes issue #56)
Mike Miller <mtmiller@octave.org>
parents:
325
diff
changeset
|
104 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
|
105 |
374
d362cdd1ddeb
pyobject: add conversion methods for single, intX, and uintX types
Mike Miller <mtmiller@octave.org>
parents:
352
diff
changeset
|
106 //! Extract the integer value of the given Python int or long object. |
d362cdd1ddeb
pyobject: add conversion methods for single, intX, and uintX types
Mike Miller <mtmiller@octave.org>
parents:
352
diff
changeset
|
107 //! |
d362cdd1ddeb
pyobject: add conversion methods for single, intX, and uintX types
Mike Miller <mtmiller@octave.org>
parents:
352
diff
changeset
|
108 //! @param obj Python int or long object |
d362cdd1ddeb
pyobject: add conversion methods for single, intX, and uintX types
Mike Miller <mtmiller@octave.org>
parents:
352
diff
changeset
|
109 //! @return integer value of @a obj |
d362cdd1ddeb
pyobject: add conversion methods for single, intX, and uintX types
Mike Miller <mtmiller@octave.org>
parents:
352
diff
changeset
|
110 uint64_t |
d362cdd1ddeb
pyobject: add conversion methods for single, intX, and uintX types
Mike Miller <mtmiller@octave.org>
parents:
352
diff
changeset
|
111 extract_py_uint64 (PyObject *obj); |
d362cdd1ddeb
pyobject: add conversion methods for single, intX, and uintX types
Mike Miller <mtmiller@octave.org>
parents:
352
diff
changeset
|
112 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
113 //! Create a Python int object with the value of the given @c int32_t value. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
114 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
115 //! @param value integer value |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
116 //! @return Python int or long object |
336
c081e30c2f64
Overhaul Python list creation from cell array
Mike Miller <mtmiller@octave.org>
parents:
328
diff
changeset
|
117 PyObject * |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
118 make_py_int (int32_t value); |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
119 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
120 //! Create a Python int object with the value of the given @c uint32_t value. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
121 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
122 //! @param value integer value |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
123 //! @return Python int or long object |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
124 PyObject * |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
125 make_py_int (uint32_t value); |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
126 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
127 //! Create a Python int object with the value of the given @c int64_t value. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
128 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
129 //! @param value integer value |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
130 //! @return Python int or long object |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
131 PyObject * |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
132 make_py_int (int64_t value); |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
133 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
134 //! Create a Python int object with the value of the given @c uint64_t value. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
135 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
136 //! @param value integer value |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
137 //! @return Python int or long object |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
138 PyObject * |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
139 make_py_int (uint64_t value); |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
140 |
352
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
141 //! Create a Python array object with the value of the given Octave array. |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
142 //! |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
143 //! @param nda array value |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
144 //! @return Python array object |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
145 PyObject * |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
146 make_py_array (const NDArray& nda); |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
147 |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
148 //! Create a Python array object with the value of the given Octave array. |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
149 //! |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
150 //! @param nda array value |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
151 //! @return Python array object |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
152 PyObject * |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
153 make_py_array (const FloatNDArray& nda); |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
154 |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
155 //! Create a Python array object with the value of the given Octave array. |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
156 //! |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
157 //! @param nda array value |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
158 //! @return Python array object |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
159 template <typename T> |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
160 PyObject * |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
161 make_py_array (const intNDArray<T>& nda); |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
162 |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
163 //! Create a Python array object from the given Octave numeric vector. |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
164 //! |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
165 //! All Octave real floating point and integer values are converted to |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
166 //! corresponding Python array types by this function. |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
167 //! |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
168 //! @warning Depending on the version of Python and how it is configured, |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
169 //! @c int64 and @c uint64 vectors may not be supported. |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
170 //! |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
171 //! @param value Octave numeric or boolean scalar value |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
172 //! @return Python array object |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
173 PyObject * |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
174 make_py_array (const octave_value& value); |
eac35d84ef0d
Convert Octave numeric vectors into Python array.array
Mike Miller <mtmiller@octave.org>
parents:
344
diff
changeset
|
175 |
342
6bd8f5e3542a
Convert Octave cell array into Python tuple instead of list
Mike Miller <mtmiller@octave.org>
parents:
340
diff
changeset
|
176 //! Create a Python tuple object from the given Octave cell array value. |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
177 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
178 //! The values contained in the cell array are recursively converted to |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
179 //! appropriate Python values. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
180 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
181 //! @param cell Octave cell array |
342
6bd8f5e3542a
Convert Octave cell array into Python tuple instead of list
Mike Miller <mtmiller@octave.org>
parents:
340
diff
changeset
|
182 //! @return Python tuple object |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
183 PyObject * |
342
6bd8f5e3542a
Convert Octave cell array into Python tuple instead of list
Mike Miller <mtmiller@octave.org>
parents:
340
diff
changeset
|
184 make_py_tuple (const Cell& cell); |
336
c081e30c2f64
Overhaul Python list creation from cell array
Mike Miller <mtmiller@octave.org>
parents:
328
diff
changeset
|
185 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
186 //! Create a Python numeric object from the given Octave numeric or boolean |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
187 //! scalar value. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
188 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
189 //! The following implicit type conversions are implemented by this function: |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
190 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
191 //! @arg @c bool from Octave logical scalar, |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
192 //! @arg @c complex from Octave double or single precision complex scalar, |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
193 //! @arg @c float from Octave double or single precision scalar, |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
194 //! @arg @c int from any Octave integer-valued scalar, |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
195 //! @arg @c long from any Octave @c uint32, @c int64, or @c uint64, and only |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
196 //! if running against Python 2. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
197 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
198 //! @param value Octave numeric or boolean scalar value |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
199 //! @return Python numeric object (@c bool, @c int, @c long, @c float, or |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
200 //! @c complex) |
337
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
201 PyObject * |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
202 make_py_numeric_value (const octave_value& value); |
d3d355dc44ad
Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents:
336
diff
changeset
|
203 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
204 //! Extract the string value of the given Python str, bytes, or unicode object. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
205 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
206 //! @param obj Python str, bytes, or unicode object |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
207 //! @return string value of @a obj |
325
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
208 std::string |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
209 extract_py_str (PyObject *obj); |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
210 |
339
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
211 //! Create a Python str object from the given @c string value. |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
212 //! |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
213 //! @param str string value |
832ee1f14862
doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents:
337
diff
changeset
|
214 //! @return Python str object |
325
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
215 PyObject * |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
216 make_py_str (const std::string& str); |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
217 |
320
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
218 } |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
219 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
220 #endif |