Re: [C++-sig] Boost::Python Reference Counting

2014-05-20 Thread Wojciech Mamrak
In your code, after the call del(container), Element::_container is a dangling pointer. Using .def("getElement", &Container::getElement, return_internal_reference<>()) should prevent the deletion of container for as long as element variable will be alive, me understands (ties lifetime of _contein

Re: [C++-sig] Building tutorial example out of the boost tree, on Windows

2013-10-05 Thread Wojciech Mamrak
hi, have you placed user-config.jam in your %HOMEDRIVE%%HOMEPATH% location, and configured Python inside it, e.g. using msvc : 10.0 : : ; using python : 2.7 #version : D:/Python27 # cmd-or-prefix : D:/Libs/Python273/include #includes : D:/Libs/Python273/libs #libraries ; as described

Re: [C++-sig] import extension module in python on OSX

2013-09-11 Thread Wojciech Mamrak
why didn't you follow the example to the end? Your module is called 'hello_ext'. 2013/9/10 Simon W : > Hello, > > I've compiled the example code for Boost.Python: > > #include > > char const* greet() > > { > > return "hello, world"; > > } > > BOOST_PYTHON_MODULE(hello_ext) > > { > > usin

Re: [C++-sig] Failed to import pyd File When python embed into C++

2013-01-23 Thread Wojciech Mamrak
Before initilizing Python interpreter you need to register your module: PyImport_AppendInittab("pythonDll", initpythonDll); regards 2013/1/23 Michael Wild : > On Wed, Jan 23, 2013 at 8:19 AM, salinea wrote: >> >> >> I create a pyd File named "testPyd" with boostPython,and then I import the >> te

Re: [C++-sig] Wrapping a non-copyiable static instance in bp::object

2013-01-16 Thread Wojciech Mamrak
Hi, bp::object static_instance() { static bp::object* result = new bp::object(boost::ref(A::static_a)); return *result; } Instead of exposing a function static_instance in your module, you can alternatively add a variable to your module's scope: scope sc; sc.attr("static_a") = boost::ref(A::

[C++-sig] Boost chooses wrong static library

2012-11-28 Thread Wojciech Mamrak
Hello, I have built Python's (2.7.3) debugging version under Windows, added "on" in user-config.jam, then run bjam: bjam -j4 --toolset=msvc --with-python python-debugging=on variant=debug link=static runtime-link=static,shared in a.cpp file I included boost python headers this way: #define BOOST

Re: [C++-sig] building 32 Bit and 64 Bit extensions on the same machine

2012-08-26 Thread Wojciech Mamrak
___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] building 32 Bit and 64 Bit extensions on the same machine

2012-08-24 Thread Wojciech Mamrak
Hi, add address-model=64 to Boost::Python bjam compilation command and that's all. Be aware, that not all MSVS versions (e.g. Express Edition) are equipped with 64 Bit compiler. 2012/8/24 Ronny Herzog : > Dear all, > > I want to build 32 bit extensions and 64 bit extensions on my Windows 7 / 32 >

[C++-sig] Factory using embedded Python interpreter

2012-07-21 Thread Wojciech Mamrak
Hello list, I am trying to create C++ objects dynamically (some kind of factory) with use of embedded Python interpreter (i.e. eval). Naive implementation: namespace bp = boost::python; bp::object main_module = ...; bp::object main_namespace = ...; bp::object bpo_ob = bp::eval((type+"()").c_str(

[C++-sig] held type and implicitly_convertible

2012-04-30 Thread Wojciech Mamrak
Hello list, correct me if I am wrong, but based on what I have found in the docs, SO and few other places, when creating an object in Python and passing it to a wrapped C++ function which expects a pointer and which takes the ownership of that pointer, one should: * use auto_ptr as held type when

Re: [C++-sig] Problem Compiling Boost.Python Example

2012-04-07 Thread Wojciech Mamrak
Exemplary project sent. W dniu 7 kwietnia 2012 14:29 użytkownik Niall Douglas napisał: > On 6 Apr 2012 at 20:33, Payam Shiva wrote: > >> Thank you Adam. I tried what you said, but it doesn't work for me. It >> gave an error, among a bunch of others, that it couldn't find >> python26.lib. I have P

Re: [C++-sig] Problem Compiling Boost.Python Example

2012-04-06 Thread Wojciech Mamrak
Wait, don't give up :) Tomorrow I will send you a msvc solution of a simple application that embedds python, so that you can check the compilation, ok? W dniu 6 kwietnia 2012 18:03 użytkownik Payam Shiva napisał: > Thank you Adam. I tried what you said, but it doesn't work for me. It > gave an er

Re: [C++-sig] Problem Compiling Boost.Python Example

2012-04-06 Thread Wojciech Mamrak
Hi, I am lost. Do you wan't to build boost::python libraries or an example using them? Bjam is used for the former only. regards W dniu 6 kwietnia 2012 11:14 użytkownik Payam Shiva napisał: > I'm totally new to Boost.Python, so I'm trying to follow the tutorial. > It says to cd to the tutorial

Re: [C++-sig] how to override __setattr__ of an extension class

2012-02-28 Thread Wojciech Mamrak
Yes, this is what I meant :) I will precise my previous message. The docs are very concise on some topics, hence misleading. If you find such statement: "Beware the common pitfall of forgetting that the constructors of most of Python's mutable types make copies, just as in Python." then it is con

Re: [C++-sig] how to override __setattr__ of an extension class

2012-02-28 Thread Wojciech Mamrak
Here is a part of my message posted here few months ago, which has been left without any response (no offence - maybe it disappeared somewhere): The docs regarding the mutable copying problem are very misleading. Following Python [1] and Boost [2] scripts do not produce the same results: [1] b =

[C++-sig] miscellaneous questions about boost.python

2011-12-08 Thread Wojciech Mamrak
Hello, I have a few doubts and questions I haven't found answer googling here and there. I hope you can help me with them. 1. When exposing C++ objects to python using Boost, instance dictionaries are created only "on demand", the first time the instance's __dict__ attribute is accessed [http://wi

Re: [C++-sig] Converting existing C++ data to python using Boost.Python

2011-11-10 Thread Wojciech Mamrak
ython can handle that for you behind the scenes. Oh, I wasn't aware of that. Epic. > Where?! Sorry, my bad, misunderstanding of docs. Also ptr() method of Object class enables its use in low-level Python C API functions. Thanks for help! 2011/11/10 Dave Abrahams : > > on Thu Nov 10 2011

[C++-sig] Converting existing C++ data to python using Boost.Python

2011-11-10 Thread Wojciech Mamrak
Hello, I am aware about the possibility to register converters to- and from- Python, which enable the implicit conversions between user-defined and build-in types in Python. My question is different: Is it possible to use Boost.Python to convert existing data structures from C++ to Python? Simple