Mercurial > pytave
annotate oct-py-types.h @ 325:fd5881d48238
Overhaul Python string creation and extraction
* oct-py-types.cc, oct-py-types.h (pytave::extract_py_str, pytave::make_py_str):
New functions to create a Python string and extract string value from Python.
(pytave::make_py_dict): Use make_py_str.
* octave_to_python.cc (pytave::octvalue_to_pyobj): Use make_py_str.
(pytave::octstring_to_pyobject): Delete.
* python_to_octave.cc (pytave::pyobj_to_octvalue): Use extract_py_str.
(pytave::pyunicode_to_utf8): Delete.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Sat, 13 Aug 2016 19:29:47 -0700 |
parents | c2aa34730dc9 |
children | 5782d7932529 |
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 |
325
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
37 std::string |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
38 extract_py_str (PyObject *obj); |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
39 |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
40 PyObject * |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
41 make_py_str (const std::string& str); |
fd5881d48238
Overhaul Python string creation and extraction
Mike Miller <mtmiller@octave.org>
parents:
320
diff
changeset
|
42 |
320
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
43 } |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
44 |
c2aa34730dc9
Convert scalar struct into Python dict (fixes issue #57)
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
45 #endif |