Hi,

> On Thu, 10 Dec 2009, [email protected] wrote:
> 
> Hi,
> 
>> 2009-12-10 15:40 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
>>  * hbwin/win_misc.c
>>  * hbwin/win_prn1.c
>>    + Using new UNICODE parameter passing macros instead of HB_TCHAR*() ones.
>>      (where possible)
> 
> Thank you for your modifications but I would like to ask you about
> two things:
> 1. please do not leave any unnecessary casting like:
>      ( LPCTSTR ) HB_PARSTRDEF( ... )
>   such casting does not give anything (it cannot converts strings
>   between different formats) but can hide very serious bugs like wrong
>   HB_PARSTRDEF() body.

I know about this, but if I don't cast, MSVC (C++ mode) gives me errors 
on compile. (const WCHAR * cannot be converted to LPCWSTR or something 
like it)

> 2. please use HB_PARSTRDEF() only in places where is strictly necessary.
>   some of this code comes from xHarbour where few years ago all hb_parc()
>   where replaced with hb_parcx() by global S&R. From that time I always
>   used to check and replace unnecessary hb_parcx() with hb_parc().

I didn't reevaluate all of them, although I did serious cleanup 
of parcx usage in the past. I was also thinking to fully drop it 
for winapi calls, as I'm sure Windows won't BSOD or crash by 
passing NULL wherever a pointer is required. That's why I didn't 
add yet any special logic to HB_PARSTRDEF() yet. All I wanted 
to do is to keep this information for now.

>   If you will make mechanical translations all hb_parcx() to HB_PARSTRDEF()
>   then I will have to also verify HB_PARSTRDEF() calls. So please try
>   to already clean it at least for such basic things like:
> 
>      if( HB_ISCHAR( 1 ) )
>      {
>         void * hName;
>         xec->hDLL = LoadLibrary( HB_PARSTRDEF( 1, &hName, NULL ) );
>         hb_strfree( hName );
>      }

This was just out of scope of these modification. To be honest 
I can't easily see how above could be cleaned. In this case the 
winapi docs doesn't mark the parameter as optional, which to me 
means that NULL is not an accepted input. (okay it won't crash 
if passed, so HB_PARSTRDEF() is almost surely unnecessary)

> BTW We can add to strapi.c two very simple functions:
> 
>   const char * hb_strnull( const char * str )
>   {
>      return str ? str : "";
>   }
>   const HB_WCHAR * hb_strnull_u16( const HB_WCHAR * str )
>   {
>      return str ? str : s_szConstStr;
>   }
> 
> which can be used in HB_PARSTRDEF() macro.

Yes, this would be the perfect solution. Anyhow I didn't 
bother to add default value to HB_PARSTRDEF() yet, as 
in 99% of cases the default is empty string, only one 
was passed some other value, but it's not a requirement 
for WAPI_*() functions to give such extra features so 
it wasn't crucial.

If we're at this topic, I've found a few places which 
couldn't be covered by these macros, It'd be very nice 
if you could take a look at them and suggest the 
cleanest way to resolve them. F.e. there are cases 
when retrieved parameter is assigned to win structure, 
there are cases when win return value is returned 
in array elements (win_prn), there is one case which needs to 
use the retrieved parameter in two places (win_reg), 
and some more. Probably some additional macros are 
needed?

Many thanks for your comments.

Brgds,
Viktor

_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to