Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / debian / libwx-perl / usr / lib / perl5 / Wx / cpp / overload.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        cpp/overload.h
3 // Purpose:     C++ code to redispatch a function based on function argument
4 //              types
5 // Author:      Mattia Barbon
6 // Modified by:
7 // Created:     11/08/2002
8 // RCS-ID:      $Id: overload.h 2737 2010-01-03 19:50:07Z mbarbon $
9 // Copyright:   (c) 2002, 2004, 2006-2007, 2010 Mattia Barbon
10 // Licence:     This program is free software; you can redistribute it and/or
11 //              modify it under the same terms as Perl itself
12 /////////////////////////////////////////////////////////////////////////////
13
14 #include "cpp/ovl_const.h"
15
16 #define BEGIN_OVERLOAD() \
17     PUSHMARK(MARK); \
18     int count; \
19     if( false );
20
21 #define END_OVERLOAD( FUNCTION ) \
22     else \
23     { \
24         static const char msg[] = "unable to resolve overloaded method for "; \
25         require_pv( "Carp" ); \
26         const char* argv[3]; argv[0] = msg; argv[1] = #FUNCTION; argv[2] = 0; \
27         call_argv( "Carp::croak", G_VOID|G_DISCARD, (char**) argv ); \
28     } \
29     /* POPMARK; */
30
31 #define REDISPATCH( NEW_METHOD_NAME ) \
32     count = call_method( #NEW_METHOD_NAME, GIMME_V ); SPAGAIN
33
34 #define REDISPATCH_FUNCTION( NEW_METHOD_NAME ) \
35     count = call_pv( #NEW_METHOD_NAME, GIMME_V ); SPAGAIN
36
37 #define MATCH_VOIDM_REDISP( METHOD ) \
38     else if( items == 1 )           \
39         { REDISPATCH( METHOD ); }
40
41 #define MATCH_ANY_REDISP( METHOD ) \
42     else if( true )               \
43         { REDISPATCH( METHOD ); }
44
45 #define MATCH_REDISP( PROTO, METHOD ) \
46     else if( wxPli_match_arguments_skipfirst( aTHX_ PROTO,  \
47                                               -1, false ) ) \
48         { REDISPATCH( METHOD ); }
49
50 #define MATCH_REDISP_COUNT( PROTO, METHOD, REQUIRED ) \
51     else if( wxPli_match_arguments_skipfirst( aTHX_ PROTO,       \
52                                               REQUIRED, false ) ) \
53         { REDISPATCH( METHOD ); }
54
55 #define MATCH_REDISP_COUNT_ALLOWMORE( PROTO, METHOD, REQUIRED ) \
56     else if( wxPli_match_arguments_skipfirst( aTHX_ PROTO,       \
57                                               REQUIRED, true ) ) \
58         { REDISPATCH( METHOD ); }
59
60 /* used for overloading static functions, see GraphicsContext.xs for an example */
61 #define MATCH_REDISP_FUNCTION( PROTO, METHOD ) \
62     else if( wxPli_match_arguments( aTHX_ PROTO,  \
63                                     -1, false ) ) \
64         { REDISPATCH_FUNCTION( METHOD );  }
65
66 #define MATCH_REDISP_COUNT_FUNCTION( PROTO, METHOD, REQUIRED ) \
67     else if( wxPli_match_arguments( aTHX_ PROTO,        \
68                                     REQUIRED, false ) ) \
69         { REDISPATCH_FUNCTION( METHOD ); }
70
71 #define MATCH_REDISP_COUNT_ALLOWMORE_FUNCTION( PROTO, METHOD, REQUIRED ) \
72     else if( wxPli_match_arguments( aTHX_ PROTO,       \
73                                     REQUIRED, true ) ) \
74         { REDISPATCH_FUNCTION( METHOD ); }