GCC Code Coverage Report
Directory: emc/rs274ngc/ Exec Total Coverage
File: emc/rs274ngc/pyinterp1.cc Lines: 26 36 72.2 %
Date: 2016-10-27 Branches: 14 30 46.7 %

Line Exec Source
1
/*    This is a component of LinuxCNC
2
 *    Copyright 2013 Michael Haberler <git@mah.priv.at>
3
 *
4
 *    This program is free software; you can redistribute it and/or modify
5
 *    it under the terms of the GNU General Public License as published by
6
 *    the Free Software Foundation; either version 2 of the License, or
7
 *    (at your option) any later version.
8
 *
9
 *    This program is distributed in the hope that it will be useful,
10
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *    GNU General Public License for more details.
13
 *
14
 *    You should have received a copy of the GNU General Public License
15
 *    along with this program; if not, write to the Free Software
16
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 */
18
// Interpreter internals - Python bindings
19
// Michael Haberler 7/2011
20
//
21
22
#include <boost/python/object.hpp>
23
#include <boost/python/suite/indexing/map_indexing_suite.hpp>
24
#include <map>
25
26
namespace bp = boost::python;
27
28
#include "rs274ngc.hh"
29
#include "interp_internal.hh"
30
#include "rs274ngc_interp.hh"
31
#include "array1.hh"
32
33
namespace pp = pyplusplus::containers::static_sized;
34
#include "interp_array_types.hh"
35
36
static  active_g_codes_array saved_g_codes_wrapper ( context &c) {
37
    return active_g_codes_array(c.saved_g_codes);
38
}
39
40
static  active_m_codes_array saved_m_codes_wrapper ( context &c) {
41
    return active_m_codes_array(c.saved_m_codes);
42
}
43
44
static  active_settings_array saved_settings_wrapper ( context &c) {
45
    return active_settings_array(c.saved_settings);
46
}
47
48
static params_array saved_params_wrapper ( context &c) {
49
    return params_array(c.saved_params);
50
}
51
static bp::object remap_str( remap_struct &r) {
52
    return  bp::object("Remap(%s argspec=%s modal_group=%d prolog=%s ngc=%s python=%s epilog=%s) " %
53
		       bp::make_tuple(r.name,r.argspec,r.modal_group,r.prolog_func,
54
				      r.remap_ngc, r.remap_py, r.epilog_func));
55
}
56
57
68
void export_Internals()
58
{
59
    using namespace boost::python;
60
    using namespace boost;
61
    class_ <context, noncopyable>("Context",no_init)
62
136
	.def_readwrite("position",&context::position)
63
68
	.def_readwrite("sequence_number",&context::sequence_number)
64
68
	.def_readwrite("filename",  &context::filename)
65
136
	.def_readwrite("subname",  &context::subName)
66
	.add_property( "saved_params",
67
		       bp::make_function( saved_params_w(&saved_params_wrapper),
68
204
					  bp::with_custodian_and_ward_postcall< 0, 1 >()))
69
	.add_property( "saved_g_codes",
70
		       bp::make_function( active_g_codes_w(&saved_g_codes_wrapper),
71
204
					  bp::with_custodian_and_ward_postcall< 0, 1 >()))
72
	.add_property( "saved_m_codes",
73
		       bp::make_function( active_m_codes_w(&saved_m_codes_wrapper),
74
204
					  bp::with_custodian_and_ward_postcall< 0, 1 >()))
75
	.add_property( "saved_settings",
76
		       bp::make_function( active_settings_w(&saved_settings_wrapper),
77
204
					  bp::with_custodian_and_ward_postcall< 0, 1 >()))
78
68
	.def_readwrite("context_status", &context::context_status)
79
68
	.def_readwrite("named_params",  &context::named_params)
80
81
	.def_readwrite("call_type",  &context::call_type)
82
	//.def_readwrite("tupleargs",  &context::tupleargs)
83
	//.def_readwrite("kwargs",  &context::kwargs)
84
	//.def_readwrite("py_return_type",  &context::py_return_type)
85
	//.def_readwrite("py_returned_double",  &context::py_returned_double)
86
	//.def_readwrite("py_returned_int",  &context::py_returned_int)
87
	//.def_readwrite("generator_next",  &context::generator_next)
88
89
68
	;
90
    // FIXME make noncopyable: class_<ParamClass, noncopyable>("Params","Interpreter parameters",no_init)
91
    class_ <remap_struct /*, noncopyable */>("Remap" /*, no_init*/)
92
136
	.def_readwrite("name",&remap::name)
93
68
	.def_readwrite("argspec",&remap::argspec)
94
68
	.def_readwrite("modal_group",&remap::modal_group)
95
68
	.def_readwrite("prolog_func",&remap::prolog_func)
96
68
	.def_readwrite("remap_py",&remap::remap_py)
97
68
	.def_readwrite("remap_ngc",&remap::remap_ngc)
98
68
	.def_readwrite("epilog_func",&remap::epilog_func)
99
68
	.def_readwrite("motion_code",&remap::motion_code)
100
	.def("__str__", &remap_str)
101
102
68
	;
103
104
    class_<remap_map,noncopyable>("RemapMap",no_init)
105
136
        .def(map_indexing_suite<remap_map>())
106
	;
107
108
    class_<parameter_value_struct /*,noncopyable */>("ParameterValue") // ,no_init)
109
136
	.def_readwrite("attr",&parameter_value_struct::attr)
110
	.def_readwrite("value",&parameter_value_struct::value)
111
68
	;
112
113
    class_<parameter_map,noncopyable>("ParameterMap",no_init)
114
136
        .def(map_indexing_suite<parameter_map>())
115
	;
116
413
}