1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: some compatibility macros
4 // Author: Mattia Barbon
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 /////////////////////////////////////////////////////////////////////////////
13 #if !defined( PERL_REVISION ) && !defined( PATCHLEVEL )
14 #include <patchlevel.h>
17 // version < 5.6 does not define PERL_
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) ) )
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 ) \
31 ( 5 == (V) && PATCHLEVEL > (S) ) || \
32 ( 5 == (V) && PATCHLEVEL == (S) && SUBVERSION >= (P) ) )
35 #define WXPERL_P_VERSION_LT( V, S, P ) !WXPERL_P_VERSION_GE( V, S, P )
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 )
49 #if WXPERL_P_VERSION_GE( 5, 5, 0 ) && !WXPERL_P_VERSION_GE( 5, 6, 0 )
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
60 #define newSVuv( val ) newSViv( (IV)(UV)val )
61 #define SvPV_nolen( s ) SvPV( (s), PL_na )
65 #if WXPERL_P_VERSION_GE( 5, 6, 0 )
80 #if WXPERL_P_VERSION_GE( 5, 8, 0 )
82 // XXX this is an hack
85 #undef HAS_LOCALTIME_R
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.
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.
102 #if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
104 # define INT2PTR(any,d) (any)(d)
106 # if PTRSIZE == LONGSIZE
107 # define PTRV unsigned long
109 # define PTRV unsigned
111 # define INT2PTR(any,d) (any)(PTRV)(d)
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)
120 #define WXINTL_NO_GETTEXT_MACRO 1
122 #if defined(__WXMSW__)
123 # if WXPERL_P_VERSION_GE( 5, 6, 0 )
124 # define WXXS( name ) __declspec(dllexport) void name( pTHXo_ CV* cv )
127 # define WXXS( name ) __declspec( dllexport ) void name(CV* cv, CPerlObj* pPerl)
129 # define WXXS( name ) __declspec( dllexport ) void name(CV* cv)
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 )
140 # define FUNCPTR( name ) name
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 }
148 #define WXPL_EXTERN_C_START
149 #define WXPL_EXTERN_C_END