[C++-sig] Accessing pointer properties with boost-python ?
Vivien Henry
vivh.29 at hotmail.fr
Sun Nov 1 12:25:01 EST 2015
Hello everyone,
I am new on this mailing-list, so; first,
My name is Vivien Henry, working as Electrical Engineer in France
I am currently trying to wrap a CAD software, gerbv (http://gerbv.geda-project.org/), which is designed to handle Gerber files. (They also provide it as a library)
the file wrapper.cpp is generated through a personal script
The script is still a work in progress.
The generated code compiles, creating objects looks ok, accessing their attributes (numbers.. enums) as well.
BUT, the problem is when i want to access a property which is actually a pointer...
For instance, with this script:
>>> from gerbv import *
>>>
>>>
>>>
>>> i = gerbv_instruction_t()
>>> i
<gerbv.gerbv_instruction_t object at 0x7f655abe6788>
>>> i.opcode
gerbv.gerbv_opcodes_t.GERBV_OPCODE_NOP
>>> a = gerbv_amacro_t()
>>> a
<gerbv.gerbv_amacro_t object at 0x7f655abe67e0>
>>> a.program
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
None.None(gerbv_amacro_t)
did not match C++ signature:
None(amacro {lvalue})
>>>
I can't figure out what is happening here !
(you ll see that i am creating a proxy to access string and char array...)
Any help is welcome :D
Thanks a lot,
Vivien Henry
here the specific code for this error, which is in the file wrapper.cpp
class gerbv_amacro_t_proxy: public gerbv_amacro_t{
public:
std::string get_name(){
std::string s(name);
return s;
}
void set_name(std::string s){
name = (gchar*)s.c_str();
}
gerbv_amacro_t_proxy() {
}
};
// in boost_python macro... l655
class_<gerbv_amacro_t_proxy, boost::shared_ptr<gerbv_amacro_t_proxy> >("gerbv_amacro_t")
//Methods
//Properties
.add_property("name", &gerbv_amacro_t_proxy::get_name, &gerbv_amacro_t_proxy::set_name)
.add_property("program", make_getter(&gerbv_amacro_t_proxy::program, return_internal_reference<>()), make_setter(&gerbv_amacro_t_proxy::program, return_internal_reference<>()))
.def_readwrite("nuf_push", &gerbv_amacro_t_proxy::nuf_push)
.add_property("next", make_getter(&gerbv_amacro_t_proxy::next, return_internal_reference<>()), make_setter(&gerbv_amacro_t_proxy::next, return_internal_reference<>()))
;
// in boost python macro l918
class_<gerbv_instruction_t, boost::shared_ptr<gerbv_instruction_t> >("gerbv_instruction_t")
//Methods
//Properties
.def_readwrite("opcode", &gerbv_instruction_t::opcode)
.def_readwrite("data", &gerbv_instruction_t::data)
.add_property("next", make_getter(&gerbv_instruction_t::next, return_internal_reference<>()), make_setter(&gerbv_instruction_t::next, return_internal_reference<>()))
;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20151101/08b88495/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrapper.cpp
Type: text/x-c
Size: 46604 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20151101/08b88495/attachment-0001.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gerbv.h
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20151101/08b88495/attachment-0001.h>
More information about the Cplusplus-sig
mailing list