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

List:       pykde
Subject:    Re: [SIP] How to hide helper functions?
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2022-07-02 9:55:15
Message-ID: 8a949706b42113b8e24c224f8fc32d58 () riverbankcomputing ! com
[Download RAW message or body]

On 02/07/2022 10:30, Weitian Leung wrote:
> No because the Python Foo.get_Count() will only raise an exception.
> Not exactly, because the interface is created by another interface,
> get_Count()  can be called normally.
> 
> Is it due to python property need to call the C++ method explicitly?

Python properties have an explicit getter. They don't go through the MRO 
to find the getter and so wouldn't find a non-abstract reimplementation 
of get_Count().

Phil

> ________________________________
> From: Phil Thompson <phil@riverbankcomputing.com>
> Sent: Saturday, July 2, 2022 4:34 PM
> To: Weitian Leung <Just_Fancy@live.com>
> Cc: pyqt@riverbankcomputing.com <pyqt@riverbankcomputing.com>
> Subject: Re: [SIP] How to hide helper functions?
> 
> On 02/07/2022 09:09, Weitian Leung wrote:
>> I have such situation that want to hide the handwritten functions, for
>> example
>> struct Foo /Abstract/
>> {
>>     HRESULT get_Count(long *count /Out/) = 0;
>>     long getCount();
>>     %MethodCode
>>         long count = 0;
>>         sipCpp->get_Count(&count);
>>         sipRes = count;
>>     %End
>>     %Property(name=Count, get=getCount)
>> };
>> the getCount is not the original interface method, I just want to make
>> the get_Count be a property, so write one helper function and use the
>> %Property directive.
>> But I don't want the user see or call the getCount method directly,
>> only the get_Count or Count property is acceptable.
>> 
>> It is possible do that?
> 
> No.
> 
>> Or is any other way to expose get_Count as a property?
> 
> No because the Python Foo.get_Count() will only raise an exception.
> 
> Phil
[prev in list] [next in list] [prev in thread] [next in thread] 

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