You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by nandika jayawardana <ja...@gmail.com> on 2005/11/04 06:43:18 UTC
[AXIS2] using a macro for parameter checking
Hi all,
I think we can use a macro for parameter validation in the code,
currently for all in parameters to functions we use
if(!param)
{
(*env)->error->error_number = AXIS2_ERROR_INVALID_NULL_PARAMETER;
return NULL; /* or appropriate return type */
}
these lines are repeatedly used everywhere in the code , so if we can define
a macro to do the above stuff
the code will look much cleaner ,
what do u think about this .....
regards ..
nandika
Re: [AXIS2] using a macro for parameter checking
Posted by Damitha Kumarage <da...@gmail.com>.
nandika jayawardana wrote:
> Hi all,
>
> I think we can use a macro for parameter validation in the code,
cool
> currently for all in parameters to functions we use
>
> if(!param)
> {
> (*env)->error->error_number = AXIS2_ERROR_INVALID_NULL_PARAMETER;
BTW you also need to set the status code
(*env)->error->status_code = AXIS2_FAILURE;
So include it also in your macro
> return NULL; /* or appropriate return type */
> }
>
> these lines are repeatedly used everywhere in the code , so if we can
> define a macro to do the above stuff
> the code will look much cleaner ,
>
> what do u think about this .....
>
> regards ..
> nandika
>
>
>
>
>
Re: [AXIS2] using a macro for parameter checking
Posted by Samisa Abeysinghe <sa...@gmail.com>.
nandika jayawardana wrote:
> Hi all,
>
> I think we can use a macro for parameter validation in the code,
> currently for all in parameters to functions we use
>
> if(!param)
> {
> (*env)->error->error_number = AXIS2_ERROR_INVALID_NULL_PARAMETER;
> return NULL; /* or appropriate return type */
> }
>
> these lines are repeatedly used everywhere in the code , so if we can
> define a macro to do the above stuff
> the code will look much cleaner ,
This macro should only be used for mandatory parameters.
Anyway I am not a big fan of Macros. While it makes code smaller, it
makes code less readable.
However, as we make heavy use of macros for function pointers, it does
not hert to use few more :)
Samisa...
>
> what do u think about this .....
>
> regards ..
> nandika
>
>
>
>
>