[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Suggestion for wrapping std::tr1::shared_ptr<>
From:       "Shen, Guobao" <shengb () bnl ! gov>
Date:       2011-06-21 15:26:24
Message-ID: 4E00B820.6000101 () bnl ! gov
[Download RAW message or body]

Hi Phil,
Thanks for your suggestion, but it said:
error: cannot convert 'a_ptr' to 'void*' in argument passing

I made an example as attached files to reproduce the error.

Any suggestion?

Thanks,

Guobao

On 06/21/2011 05:51 AM, Phil Thompson wrote:
> On Mon, 20 Jun 2011 10:03:42 -0400, "Shen, Guobao"<shengb@bnl.gov>  wrote:
>    
>> Hi, Phil and everyone,
>> It is great to find this mailing list.
>> I am recently starting to use SIP to expose a C++ app, which makes heavy
>>      
>    
>> use of std::tr1::shared_ptr.
>> I hit some problems to wrap them in SIP. Here is my example:
>>
>> class FooA;
>> typedef std::tr1::shared_ptr<const FooA>  a_ptr;
>>
>> class FooA : public std::tr1::enable_shared_from_this<FooA>  {
>> public:
>>       typedef std::tr1::shared_ptr<FooA>  shared_pointer;
>>         ...
>> }
>>
>> class FooB: {
>> public:
>>       a_ptr method1(std::string name, a_ptr pointer) const;
>>       ...
>> }
>>
>> How should I wrap them in SIP? Is there some code in PyQt that I can
>> look at?
>>
>> Thanks,
>>
>> Guobao
>>      
> You could try specifying it as a normal pointer in the .sip file...
>
>      typedef FooA *a_ptr;
>
> Phil
>
>    

-- 
Guobao Shen
Bldg. 902-B, 17 Cornell Avenue
National Synchrotron Light Source II
Brookhaven National Laboratory
Upton, New York 11973
Tel.	: +1 (631) 344 7540
Fax.	: +1 (631) 344 8085
http://www.bnl.gov/nsls2


["configure.py" (text/x-python)]

import os
import sipconfig

# The name of the SIP build file generated by SIP and used by the build
# system.
build_file = "test.sbf"

# Get the SIP configuration information.
config = sipconfig.Configuration()

# Run SIP to generate the code.
os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "test.sip"]))

# Create the Makefile.
makefile = sipconfig.SIPModuleMakefile(config, build_file)

# Add the library we are wrapping.  The name doesn't include any platform
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
# ".dll" extension on Windows).
makefile.extra_libs = ["test"]

# Generate the Makefile itself.
makefile.generate()


["test.h" (text/x-chdr)]

#ifndef TEST_H
#define TEST_H

#include <c++/4.4/tr1/memory>

class FooA;

typedef std::tr1::shared_ptr<const FooA> a_ptr;
typedef a_ptr * a_ptr_array;

class FooA : public std::tr1::enable_shared_from_this<FooA> {
public:
    typedef std::tr1::shared_ptr<FooA> shared_pointer;
    typedef std::tr1::shared_ptr<const FooA> const_shared_pointer;
    FooA();
    ~FooA();
    a_ptr getFooA() const;
};

#endif


["test.sip" (text/plain)]

%Module test 0

typedef FooA * a_ptr;

class FooA {
%TypeHeaderCode
#include <test.h>
%End

public:
    a_ptr getFooA();

};



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic