1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cpp/constants.h
3 // Purpose: module to allow modularity in constant() function
4 // Author: Mattia Barbon
7 // RCS-ID: $Id: constants.h 2498 2008-11-05 19:45:38Z mbarbon $
8 // Copyright: (c) 2001-2002, 2005, 2008 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 #ifndef _WXPERL_CONSTANTS_H
14 #define _WXPERL_CONSTANTS_H
16 typedef double (*PL_CONST_FUNC)( const char*, int );
18 #define WX_PL_CONSTANT_INIT() \
22 if( tolower( name[0] ) == 'w' && tolower( name[1] ) == 'x' ) \
23 fl = toupper( name[2] );
25 #define WX_PL_CONSTANT_CLEANUP() \
29 // implementation for OnInit/OnExit in Constants.xs
33 wxPlConstants( PL_CONST_FUNC function );
36 PL_CONST_FUNC m_function;
39 // duplicated from helpers.h
40 extern void FUNCPTR( wxPli_add_constant_function )
41 ( double (**)( const char*, int ) );
42 extern void FUNCPTR( wxPli_remove_constant_function )
43 ( double (**)( const char*, int ) );
45 inline wxPlConstants::wxPlConstants( PL_CONST_FUNC function )
46 :m_function( function )
48 #if NEEDS_PLI_HELPERS_STRUCT()
50 // GRR! init helpers...
51 SV* wxpli_tmp = get_sv( "Wx::_exports", 1 );
52 wxPliHelpers* name = INT2PTR( wxPliHelpers*, SvIV( wxpli_tmp ) );
53 wxPli_add_constant_function = name->m_wxPli_add_constant_function;
55 wxPli_add_constant_function( &m_function );
58 inline wxPlConstants::~wxPlConstants()
59 { wxPli_remove_constant_function( &m_function ); }
62 // _WXPERL_CONSTANTS_H
64 // Local variables: //