Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / cpp / constants.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        cpp/constants.h
3 // Purpose:     module to allow modularity in constant() function
4 // Author:      Mattia Barbon
5 // Modified by:
6 // Created:     17/03/2001
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 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WXPERL_CONSTANTS_H
14 #define _WXPERL_CONSTANTS_H
15
16 typedef double (*PL_CONST_FUNC)( const char*, int );
17
18 #define WX_PL_CONSTANT_INIT() \
19   errno = 0;                \
20   char fl = name[0];        \
21                             \
22   if( tolower( name[0] ) == 'w' && tolower( name[1] ) == 'x' ) \
23     fl = toupper( name[2] );
24
25 #define WX_PL_CONSTANT_CLEANUP() \
26   errno = EINVAL;                \
27   return 0;
28
29 // implementation for OnInit/OnExit in Constants.xs
30 class wxPlConstants
31 {
32 public:
33     wxPlConstants( PL_CONST_FUNC function );
34     ~wxPlConstants();
35 private:
36     PL_CONST_FUNC m_function;
37 };
38
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 ) );
44
45 inline wxPlConstants::wxPlConstants( PL_CONST_FUNC function )
46     :m_function( function )
47 {
48 #if NEEDS_PLI_HELPERS_STRUCT()
49     dTHX;
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;
54 #endif
55     wxPli_add_constant_function( &m_function );
56 }
57
58 inline wxPlConstants::~wxPlConstants()
59     { wxPli_remove_constant_function( &m_function ); }
60
61 #endif
62     // _WXPERL_CONSTANTS_H
63
64 // Local variables: //
65 // mode: c++ //
66 // End: //
67
68
69