Mercurial > pytave
annotate octave_to_python.h @ 308:72ecb31b163a
Fix some pyobject doctests
* @pyobject/dummy.m: Fix tests to work for both python2 and python3 taking
into account the latest changes in pytave to drop conversion of lists, dicts &
tuples.
author | Abhinav Tripathi <genuinelucifer@gmail.com> |
---|---|
date | Tue, 09 Aug 2016 11:49:30 -0700 |
parents | a7d597726985 |
children | 09a1acb81d8b |
rev | line source |
---|---|
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
1 /* |
139
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
2 |
150
a3dc9d24ae38
maint: Add myself to copyright notices
Mike Miller <mtmiller@octave.org>
parents:
146
diff
changeset
|
3 Copyright (C) 2015-2016 Mike Miller |
139
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
4 Copyright (C) 2008 David Grundberg, HÃ¥kan Fors Nilsson |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
5 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
6 This file is part of Pytave. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
7 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
8 Pytave is free software: you can redistribute it and/or modify it |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
9 under the terms of the GNU General Public License as published by the |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
10 Free Software Foundation, either version 3 of the License, or (at your |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
11 option) any later version. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
12 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
13 Pytave is distributed in the hope that it will be useful, but WITHOUT |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
16 for more details. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
17 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
19 along with Pytave; see the file COPYING. If not, see |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
20 <http://www.gnu.org/licenses/>. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
21 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
22 */ |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
23 |
175
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
24 /*! \file octave_to_python.h |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
25 \brief Conversion of data values from GNU Octave to Python |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
26 |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
27 The functions in this file define the translation of GNU Octave |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
28 values to Python objects using the Boost.Python library and |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
29 the Octave/C++ API. |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
30 |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
31 This project is currently derived from an earlier project called |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
32 Pytave that allowed Python to call Octave functions on an |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
33 embedded Octave interpreter. The bulk of the project is in the |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
34 code to convert between Octave and Python data types, so most of |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
35 that is reusable. As a side goal, we may continue to maintain the |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
36 Python wrapper around Octave and incorporate that into Octave as |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
37 well, so that Octave can provide its own native Python module. |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
38 */ |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
39 |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
40 |
141
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
41 #if ! defined (pytave_octave_to_python_h) |
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
42 #define pytave_octave_to_python_h |
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
43 |
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
44 #include <boost/python.hpp> |
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
45 #include <ov.h> |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
46 |
175
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
47 //! Contains the functions used for conversion. |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
48 namespace pytave |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
49 { |
175
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
50 //! Conversion from any Octave value object to a Python object. |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
51 /*! |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
52 \param py_object a reference to boost::python::object to store the result of the conversion. |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
53 \param oct_value a constant reference to a octave_value that contains the object to be converted. |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
54 \see pyobj_to_octvalue |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
55 */ |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
56 void octvalue_to_pyobj (boost::python::object& py_object, |
175
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
57 const octave_value& oct_value); |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
58 |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
59 //! Octave value list objects are converted to Python tuples. |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
60 /*! |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
61 \param py_tuple a reference to boost::python::tuple to store |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
62 the result of the conversion. |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
63 \param oct_list a constant reference to a octave_value_list |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
64 that contains the tuple to be converted. |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
65 \see pytuple_to_octlist |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
66 */ |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
67 void octlist_to_pytuple (boost::python::tuple& py_tuple, |
a7d597726985
doc: doxygen config file and documentation
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
169
diff
changeset
|
68 const octave_value_list& oct_list); |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
69 } |
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
70 |
141
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
71 #endif |