annotate oct-py-eval.h @ 403:3644df6564bc

maint: use C++11 nullptr rather than 0 or NULL * __py_struct_from_dict__.cc, oct-py-eval.cc, oct-py-eval.h, oct-py-object.h, oct-py-types.cc, oct-py-util.cc, pycall.cc, pyeval.cc, pyexec.cc: Use C++11 nullptr rather than 0 or NULL.
author Mike Miller <mtmiller@octave.org>
date Fri, 28 Apr 2017 14:19:49 -0700
parents c4b78e449c62
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
335
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
1 /*
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
2
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
3 Copyright (C) 2016 Mike Miller
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
4
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
5 This file is part of Pytave.
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
6
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
7 Pytave is free software; you can redistribute it and/or modify it
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
10 option) any later version.
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
11
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
12 Pytave is distributed in the hope that it will be useful, but WITHOUT
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
15 for more details.
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
16
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
18 along with Pytave; see the file COPYING. If not, see
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
20
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
21 */
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
22
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
23 #if ! defined (pytave_oct_py_eval_h)
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
24 #define pytave_oct_py_eval_h 1
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
25
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
26 #include <Python.h>
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
27 #include <string>
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
28
351
040aff46e4db Refactor calling a Python function into a set of wrapper functions
Mike Miller <mtmiller@octave.org>
parents: 335
diff changeset
29 class octave_value_list;
040aff46e4db Refactor calling a Python function into a set of wrapper functions
Mike Miller <mtmiller@octave.org>
parents: 335
diff changeset
30
335
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
31 namespace pytave
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
32 {
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
33
402
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
34 //! Call a Python function by name with the given argument list.
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
35 //!
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
36 //! The @a func string may be the name of a builtin function or of a function
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
37 //! in a loadable module in the form @c module.function.
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
38 //!
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
39 //! If @a args contains one or more values created by the @c pyargs function,
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
40 //! they are automatically interpreted as keyword arguments.
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
41 //!
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
42 //! @param func name of a Python function
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
43 //! @param args Octave argument list to be converted and passed to @a func
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
44 //! @return return value of @a func
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
45 PyObject *
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
46 py_call_function (const std::string& func, const octave_value_list& args);
351
040aff46e4db Refactor calling a Python function into a set of wrapper functions
Mike Miller <mtmiller@octave.org>
parents: 335
diff changeset
47
402
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
48 //! Call a Python function by name with arguments and keyword arguments.
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
49 //!
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
50 //! The @a func string may be the name of a builtin function or of a function
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
51 //! in a loadable module in the form @c module.function.
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
52 //!
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
53 //! @param func name of a Python function
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
54 //! @param args tuple of positional arguments
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
55 //! @param kwargs dictionary of keyword arguments
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
56 //! @return return value of @a func
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
57 PyObject *
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
58 py_call_function (const std::string& func, PyObject *args,
403
3644df6564bc maint: use C++11 nullptr rather than 0 or NULL
Mike Miller <mtmiller@octave.org>
parents: 402
diff changeset
59 PyObject *kwargs = nullptr);
351
040aff46e4db Refactor calling a Python function into a set of wrapper functions
Mike Miller <mtmiller@octave.org>
parents: 335
diff changeset
60
402
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
61 //! Call a Python function with the given argument list.
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
62 //!
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
63 //! If @a args contains one or more values created by the @c pyargs function,
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
64 //! they are automatically interpreted as keyword arguments.
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
65 //!
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
66 //! @param callable Python function or other callable object
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
67 //! @param args Octave argument list to be converted and passed to @a func
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
68 //! @return return value of @a func
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
69 PyObject *
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
70 py_call_function (PyObject *callable, const octave_value_list& args);
351
040aff46e4db Refactor calling a Python function into a set of wrapper functions
Mike Miller <mtmiller@octave.org>
parents: 335
diff changeset
71
402
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
72 //! Call a Python function with arguments and keyword arguments.
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
73 //!
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
74 //! @param callable Python function or other callable object
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
75 //! @param args tuple of positional arguments
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
76 //! @param kwargs dictionary of keyword arguments
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
77 //! @return return value of @a func
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
78 PyObject *
403
3644df6564bc maint: use C++11 nullptr rather than 0 or NULL
Mike Miller <mtmiller@octave.org>
parents: 402
diff changeset
79 py_call_function (PyObject *callable, PyObject *args,
3644df6564bc maint: use C++11 nullptr rather than 0 or NULL
Mike Miller <mtmiller@octave.org>
parents: 402
diff changeset
80 PyObject *kwargs = nullptr);
351
040aff46e4db Refactor calling a Python function into a set of wrapper functions
Mike Miller <mtmiller@octave.org>
parents: 335
diff changeset
81
402
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
82 PyObject *
403
3644df6564bc maint: use C++11 nullptr rather than 0 or NULL
Mike Miller <mtmiller@octave.org>
parents: 402
diff changeset
83 py_eval_string (const std::string& expr, PyObject *globals = nullptr,
3644df6564bc maint: use C++11 nullptr rather than 0 or NULL
Mike Miller <mtmiller@octave.org>
parents: 402
diff changeset
84 PyObject *locals = nullptr);
335
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
85
402
c4b78e449c62 maint: indent functions declared in the pytave namespace
Mike Miller <mtmiller@octave.org>
parents: 351
diff changeset
86 PyObject *
403
3644df6564bc maint: use C++11 nullptr rather than 0 or NULL
Mike Miller <mtmiller@octave.org>
parents: 402
diff changeset
87 py_exec_string (const std::string& expr, PyObject *globals = nullptr,
3644df6564bc maint: use C++11 nullptr rather than 0 or NULL
Mike Miller <mtmiller@octave.org>
parents: 402
diff changeset
88 PyObject *locals = nullptr);
335
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
89
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
90 }
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
91
9b862844e6b7 Enable Python print function in evaluated expressions (fixes issue #48)
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
92 #endif