1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cpp/v_cback.cpp
3 // Purpose: implementation for v_cback.h
4 // Author: Mattia Barbon
7 // RCS-ID: $Id: v_cback.cpp 2057 2007-06-18 23:03:00Z mbarbon $
8 // Copyright: (c) 2000-2002, 2004 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 bool wxPliVirtualCallback::FindCallback( pTHX_ const char* name ) const
15 // it would be better to declare m_method & m_stash 'mutable'
16 // but of course some C++ compiler don't support it...
17 CV** pm_method = (CV**)&m_method;
18 HV** pm_stash = (HV**)&m_stash;
24 pkg = SvSTASH( SvRV( m_self ) );
30 GV* gv = gv_fetchmethod( pkg, CHAR_P name );
31 if( gv && isGV( gv ) )
32 // mortal, since CallCallback is called before we return to perl
33 *pm_method = (CV*) ( p_method = GvCV( gv ) );
40 *pm_stash = gv_stashpv( CHAR_P m_package, false );
47 GV* gv = gv_fetchmethod( m_stash, CHAR_P name );
48 if( gv && isGV( gv ) )
49 p_pmethod = GvCV( gv );
51 return p_method != p_pmethod;
54 SV* wxPliVirtualCallback::CallCallback( pTHX_ I32 flags, const char* argtypes,
55 va_list& arglist ) const
67 wxPli_push_args( aTHX_ &SP, argtypes, arglist );
70 SV* method = sv_2mortal( newRV_inc( (SV*) m_method ) );
71 call_sv( method, flags );
75 if( ( flags & G_DISCARD ) == 0 ) {
79 SvREFCNT_inc( retval );
91 bool wxPliVirtualCallback_FindCallback( pTHX_ const wxPliVirtualCallback* cb,
94 return cb->FindCallback( aTHX_ name );
97 SV* wxPliVirtualCallback_CallCallback( pTHX_ const wxPliVirtualCallback* cb,
99 const char* argtypes, ... )
102 va_start( arglist, argtypes );
104 SV* ret = cb->CallCallback( aTHX_ flags, argtypes, arglist );
111 // Local variables: //