annotate oct-py-types.h @ 344:9d95f087e5aa

Add a function to extract a scalar map value from a Python dict * oct-py-types.cc, oct-py-types.h (pytave::extract_py_scalar_map): New function.
author Mike Miller <mtmiller@octave.org>
date Tue, 16 Aug 2016 15:29:01 -0700
parents 6bd8f5e3542a
children eac35d84ef0d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
320
c2aa34730dc9 Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
31 class octave_scalar_map;
337
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
32 class octave_value;
320
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 namespace pytave
c2aa34730dc9 Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
35 {
c2aa34730dc9 Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
36
340
06b8aeea456f Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents: 339
diff changeset
37 //! 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
38 //!
06b8aeea456f Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents: 339
diff changeset
39 //! @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
40 //! @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
41 bool
06b8aeea456f Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents: 339
diff changeset
42 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
43
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
44 //! 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
45 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
46 //! @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
47 //! @return Python bool object
320
c2aa34730dc9 Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
48 PyObject *
337
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
49 make_py_bool (bool value);
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
50
340
06b8aeea456f Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents: 339
diff changeset
51 //! 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
52 //!
06b8aeea456f Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents: 339
diff changeset
53 //! @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
54 //! @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
55 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
56 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
57
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
58 //! 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
59 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
60 //! @param value complex value
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
61 //! @return Python complex object
337
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
62 PyObject *
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
63 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
64
340
06b8aeea456f Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents: 339
diff changeset
65 //! 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
66 //!
06b8aeea456f Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents: 339
diff changeset
67 //! @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
68 //! @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
69 double
06b8aeea456f Add functions to conversion API to extract bool, double, and complex values
Mike Miller <mtmiller@octave.org>
parents: 339
diff changeset
70 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
71
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
72 //! 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
73 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
74 //! @param value floating point value
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
75 //! @return Python float object
337
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
76 PyObject *
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
77 make_py_float (double value);
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
78
344
9d95f087e5aa Add a function to extract a scalar map value from a Python dict
Mike Miller <mtmiller@octave.org>
parents: 342
diff changeset
79 //! 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
80 //!
9d95f087e5aa Add a function to extract a scalar map value from a Python dict
Mike Miller <mtmiller@octave.org>
parents: 342
diff changeset
81 //! @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
82 //! @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
83 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
84 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
85
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
86 //! 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
87 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
88 //! 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
89 //! Python values.
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 //! @param map Octave scalar map
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
92 //! @return Python dict object
337
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
93 PyObject *
320
c2aa34730dc9 Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
94 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
95
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
96 //! 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
97 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
98 //! @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
99 //! @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
100 int64_t
5782d7932529 Automatically convert Python 2 'int' type to Octave int64 (fixes issue #56)
Mike Miller <mtmiller@octave.org>
parents: 325
diff changeset
101 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
102
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
103 //! 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
104 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
105 //! @param value integer value
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
106 //! @return Python int or long object
336
c081e30c2f64 Overhaul Python list creation from cell array
Mike Miller <mtmiller@octave.org>
parents: 328
diff changeset
107 PyObject *
337
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
108 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
109
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
110 //! 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
111 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
112 //! @param value integer value
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
113 //! @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
114 PyObject *
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
115 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
116
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
117 //! 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
118 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
119 //! @param value integer value
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
120 //! @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
121 PyObject *
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
122 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
123
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
124 //! 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
125 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
126 //! @param value integer value
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
127 //! @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
128 PyObject *
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
129 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
130
342
6bd8f5e3542a Convert Octave cell array into Python tuple instead of list
Mike Miller <mtmiller@octave.org>
parents: 340
diff changeset
131 //! 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
132 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
133 //! 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
134 //! appropriate Python values.
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 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
137 //! @return Python tuple object
337
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
138 PyObject *
342
6bd8f5e3542a Convert Octave cell array into Python tuple instead of list
Mike Miller <mtmiller@octave.org>
parents: 340
diff changeset
139 make_py_tuple (const Cell& cell);
336
c081e30c2f64 Overhaul Python list creation from cell array
Mike Miller <mtmiller@octave.org>
parents: 328
diff changeset
140
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
141 //! 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
142 //! scalar value.
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
143 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
144 //! 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
145 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
146 //! @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
147 //! @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
148 //! @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
149 //! @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
150 //! @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
151 //! if running against Python 2.
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
152 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
153 //! @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
154 //! @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
155 //! @c complex)
337
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
156 PyObject *
d3d355dc44ad Overhaul Python numeric type creation from Octave scalar types
Mike Miller <mtmiller@octave.org>
parents: 336
diff changeset
157 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
158
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
159 //! 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
160 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
161 //! @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
162 //! @return string value of @a obj
325
fd5881d48238 Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents: 320
diff changeset
163 std::string
fd5881d48238 Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents: 320
diff changeset
164 extract_py_str (PyObject *obj);
fd5881d48238 Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents: 320
diff changeset
165
339
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
166 //! 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
167 //!
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
168 //! @param str string value
832ee1f14862 doc: document functions in oct-py-types.h
Mike Miller <mtmiller@octave.org>
parents: 337
diff changeset
169 //! @return Python str object
325
fd5881d48238 Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents: 320
diff changeset
170 PyObject *
fd5881d48238 Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents: 320
diff changeset
171 make_py_str (const std::string& str);
fd5881d48238 Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents: 320
diff changeset
172
320
c2aa34730dc9 Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
173 }
c2aa34730dc9 Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
174
c2aa34730dc9 Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
175 #endif