On 6 November 2012 20:02, Luc Fabresse <[email protected]> wrote:
> Hi all,
>
> 2012/11/6 Igor Stasenko <[email protected]>
>>
>> On 2 November 2012 06:05, Torsten Bergmann <[email protected]> wrote:
>> > Hi Igor,
>> >
>> > in Win32 often one passes NULL as argument
>> > (for instance if a function has an argument "handle to a window", then
>> > a hWnd of NULL can be given).
>> >
>> > For instance when I have
>> >
>> >    shellExecute: hwnd operation: lpOperation file: lpFile parameters:
>> > lpParameters directory: lpDirectory show: nShowCmd
>> >                 <primitive: #primitiveNativeCall module:
>> > #NativeBoostPlugin>
>> >
>> >                 ^ self nbCall: #(
>> >                         HINSTANCE ShellExecuteA(
>> >                                 HWND hwnd,
>> >                                 LPCTSTR lpOperation,
>> >                                 LPCTSTR lpFile,
>> >                                 LPCTSTR lpParameters,
>> >                                 LPCTSTR lpDirectory,
>> >                                 INT nShowCmd)) module: 'Shell32.dll'
>> >
>>
>> usually it controlled by options for code generator
>> like #optCoerceNilToNull
>> which will allow you to pass nil as valid argument.
>>
>> What is missing, is that in your case you passing an instance of
>> NBExternalObject,
>> and NBExternalObjectType converter does not honors that option.
>> This is easy to fix. I will add it as time allows me to do a pass on
>> NativeBoost.
>>
>> >
>> > The NBFFICallout class(NBNativeCodeGen
>> > class)>>handleFailureIn:nativeCode:
>> > tells me that "an instance of NBWin32Window" is expected.
>> >
>> right, so what you can do is to synthesize an instance of
>> NBWin32Window with handle value == 0.
>> This will effectively behave as if you passed null argument. Sure it
>> is not nearly elegant, so i mentioning it
>> just for protocol :)
>>
>>
>> > So currently I have to pass "NBWin32Window getFocus" as first
>> > argument. But often this is not necessary.
>> >
>> Another way of doing this is use convenience methods. Like with your
>> function,
>> you could have two methods for it, one which takes window argument,
>> and another which doesn't:
>>
>>
>> shellExecute: lpOperation file: lpFile parameters: lpParameters
>> directory: lpDirectory show: nShowCmd
>>
>>                  ^ self nbCall: #(
>>                          HINSTANCE ShellExecuteA(
>>                                  0,
>>                                  LPCTSTR lpOperation,
>>                                  LPCTSTR lpFile,
>>                                  LPCTSTR lpParameters,
>>                                  LPCTSTR lpDirectory,
>>                                  INT nShowCmd)) module: 'Shell32.dll'
>
>
> yes I like this NB feature of directly put real values in external call
> definitions.
> But, having a NULL constant could also makes sense:
>
> ^ self nbCall: #(
>                          HINSTANCE ShellExecuteA(
>                                  NULL,
>
>                                  LPCTSTR lpOperation,
>                                  LPCTSTR lpFile,
>                                  LPCTSTR lpParameters,
>                                  LPCTSTR lpDirectory,
>                                  INT nShowCmd)) module: 'Shell32.dll'
>
> perhaps NULL is already there somewhere, I never look for it ;-)
>

AFAIK, NULL pointer is not a standard part of ANSI C
the existance of

#define NULL 0

in many implementations doesn't actually makes it "official"

so, if you don't like putting 0 , you can always use class var with
value = 0 , and name it 'NULL'
'NUL' or 'ZERO' or whatever you want :)


> Luc
>

-- 
Best regards,
Igor Stasenko.

Reply via email to