Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / debian / libwx-perl / usr / lib / perl5 / Wx / cpp / compat.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        cpp/compat.h
3 // Purpose:     some compatibility macros
4 // Author:      Mattia Barbon
5 // Modified by:
6 // Created:     29/10/2000
7 // RCS-ID:      $Id: compat.h 2532 2009-02-21 08:51:16Z mbarbon $
8 // Copyright:   (c) 2000-2003, 2006, 2008-2009 Mattia Barbon
9 // Licence:     This program is free software; you can redistribute it and/or
10 //              modify it under the same terms as Perl itself
11 /////////////////////////////////////////////////////////////////////////////
12
13 #if !defined( PERL_REVISION ) && !defined( PATCHLEVEL )
14 #include <patchlevel.h>
15 #endif
16
17 // version < 5.6 does not define PERL_
18 #ifdef PERL_REVISION
19 #define WXPERL_P_VERSION_EQ( V, S, P ) \
20  ( ( PERL_REVISION == (V) ) && ( PERL_VERSION == (S) ) && ( PERL_SUBVERSION == (P) ) )
21 #define WXPERL_P_VERSION_GE( V, S, P ) \
22  ( ( PERL_REVISION > (V) ) || \
23    ( PERL_REVISION == (V) && PERL_VERSION > (S) ) || \
24    ( PERL_REVISION == (V) && PERL_VERSION == (S) && PERL_SUBVERSION >= (P) ) )
25
26 #else
27 #define WXPERL_P_VERSION_EQ( V, S, P ) \
28  ( ( 5 == (V) ) && ( PATCHLEVEL == (S) ) && ( SUBVERSION == (P) ) )
29 #define WXPERL_P_VERSION_GE( V, S, P ) \
30  ( ( 5 > (V) ) || \
31    ( 5 == (V) && PATCHLEVEL > (S) ) || \
32    ( 5 == (V) && PATCHLEVEL == (S) && SUBVERSION >= (P) ) )
33
34 #endif
35 #define WXPERL_P_VERSION_LT( V, S, P ) !WXPERL_P_VERSION_GE( V, S, P )
36
37 #define WXPERL_W_VERSION_EQ( V, S, P ) \
38  ( wxMAJOR_VERSION == (V) && wxMINOR_VERSION == (S) && wxRELEASE_NUMBER == (P) )
39 #define WXPERL_W_VERSION_GE( V, S, P ) \
40  ( ( wxMAJOR_VERSION > (V) ) || \
41    ( wxMAJOR_VERSION == (V) && wxMINOR_VERSION > (S) ) || \
42    ( wxMAJOR_VERSION == (V) && wxMINOR_VERSION == (S) && wxRELEASE_NUMBER >= (P) ) )
43 #define WXPERL_W_VERSION_LE( V, S, P ) \
44  ( ( wxMAJOR_VERSION < (V) ) || \
45    ( wxMAJOR_VERSION == (V) && wxMINOR_VERSION < (S) ) || \
46    ( wxMAJOR_VERSION == (V) && wxMINOR_VERSION == (S) && wxRELEASE_NUMBER <= (P) ) )
47 #define WXPERL_W_VERSION_LT( V, S, P ) !WXPERL_W_VERSION_GE( V, S, P )
48
49 #if WXPERL_P_VERSION_GE( 5, 5, 0 ) && !WXPERL_P_VERSION_GE( 5, 6, 0 )
50
51 #define CHAR_P (char*)
52 #define get_sv perl_get_sv
53 #define get_av perl_get_av
54 #define call_sv perl_call_sv
55 #define eval_pv perl_eval_pv
56 #define call_method perl_call_method
57 #define require_pv perl_require_pv
58 #define call_argv perl_call_argv
59
60 #define newSVuv( val ) newSViv( (IV)(UV)val )
61 #define SvPV_nolen( s ) SvPV( (s), PL_na )
62
63 #endif
64
65 #if WXPERL_P_VERSION_GE( 5, 6, 0 )
66
67 #define CHAR_P
68
69 #else
70
71 #define vTHX
72 #define pTHX
73 #define aTHX
74 #define dTHX
75 #define pTHX_
76 #define aTHX_
77
78 #endif
79
80 #if WXPERL_P_VERSION_GE( 5, 8, 0 )
81
82 // XXX this is an hack
83 #include <config.h>
84 #undef HAS_CRYPT_R
85 #undef HAS_LOCALTIME_R
86
87 #endif
88
89 #ifndef PTR2IV
90
91 // from perl.h
92 /*
93  *  The macros INT2PTR and NUM2PTR are (despite their names)
94  *  bi-directional: they will convert int/float to or from pointers.
95  *  However the conversion to int/float are named explicitly:
96  *  PTR2IV, PTR2UV, PTR2NV.
97  *
98  *  For int conversions we do not need two casts if pointers are
99  *  the same size as IV and UV.   Otherwise we need an explicit
100  *  cast (PTRV) to avoid compiler warnings.
101  */
102 #if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
103 #  define PTRV                  UV
104 #  define INT2PTR(any,d)        (any)(d)
105 #else
106 #  if PTRSIZE == LONGSIZE
107 #    define PTRV                unsigned long
108 #  else
109 #    define PTRV                unsigned
110 #  endif
111 #  define INT2PTR(any,d)        (any)(PTRV)(d)
112 #endif
113 #define NUM2PTR(any,d)  (any)(PTRV)(d)
114 #define PTR2IV(p)       INT2PTR(IV,p)
115 #define PTR2UV(p)       INT2PTR(UV,p)
116 #define PTR2NV(p)       NUM2PTR(NV,p)
117
118 #endif
119
120 #define WXINTL_NO_GETTEXT_MACRO 1
121
122 #if defined(__WXMSW__)
123 #  if WXPERL_P_VERSION_GE( 5, 6, 0 )
124 #    define WXXS( name ) __declspec(dllexport) void name( pTHXo_ CV* cv )
125 #  else
126 #    ifdef PERL_OBJECT
127 #      define WXXS( name ) __declspec( dllexport ) void name(CV* cv, CPerlObj* pPerl)
128 #    else
129 #      define WXXS( name ) __declspec( dllexport ) void name(CV* cv)
130 #    endif
131 #  endif
132 #endif
133
134 #define WXPLDLL
135 #define NEEDS_PLI_HELPERS_STRUCT() \
136   defined( WXPL_EXT ) && !defined( WXPL_STATIC ) && !defined(__WXMAC__)
137 #if NEEDS_PLI_HELPERS_STRUCT()
138 #  define FUNCPTR( name ) ( * name )
139 #else
140 #  define FUNCPTR( name ) name
141 #endif
142
143 // puts extern "C" around perl headers
144 #if defined(__CYGWIN__)
145 #define WXPL_EXTERN_C_START extern "C" {
146 #define WXPL_EXTERN_C_END   }
147 #else
148 #define WXPL_EXTERN_C_START
149 #define WXPL_EXTERN_C_END
150 #endif
151