File: dataobject.h

package info (click to toggle)
libwx-perl 1%3A0.9909-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,912 kB
  • sloc: cpp: 9,728; perl: 8,182; ansic: 626; makefile: 41
file content (87 lines) | stat: -rw-r--r-- 2,941 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/////////////////////////////////////////////////////////////////////////////
// Name:        ext/dnd/cpp/dataobject.h
// Purpose:     c++ wrapper for wxPl*DataObject and wxPlDataObjectSimple
// Author:      Mattia Barbon
// Modified by:
// Created:     13/08/2001
// RCS-ID:      $Id: dataobject.h 2057 2007-06-18 23:03:00Z mbarbon $
// Copyright:   (c) 2001-2002, 2005 Mattia Barbon
// Licence:     This program is free software; you can redistribute it and/or
//              modify it under the same terms as Perl itself
/////////////////////////////////////////////////////////////////////////////

#include <wx/dataobj.h>
#include "cpp/v_cback.h"

#define DEC_V_CBACK_SIZET__VOID_const( METHOD ) \
  size_t METHOD() const

#define DEC_V_CBACK_BOOL__VOIDP_const( METHOD ) \
  bool METHOD( void* ) const

#define DEC_V_CBACK_BOOL__SIZET_CVOIDP( METHOD ) \
  bool METHOD( size_t, const void* )

class wxPlDataObjectSimple:public wxDataObjectSimple
{
    WXPLI_DECLARE_V_CBACK();
public:
    wxPlDataObjectSimple( const char* package, const wxDataFormat& format )
        :wxDataObjectSimple( format ),
         m_callback( "Wx::PlDataObjectSimple" )
    {
        m_callback.SetSelf( wxPli_make_object( this, package ) );
    }
private:
    // SGI CC warns here, but it is harmless
    DEC_V_CBACK_SIZET__VOID_const( GetDataSize );
    DEC_V_CBACK_BOOL__VOIDP_const( GetDataHere );
    DEC_V_CBACK_BOOL__SIZET_CVOIDP( SetData );
};

size_t wxPlDataObjectSimple::GetDataSize() const
{
    dTHX;
    if( wxPliVirtualCallback_FindCallback( aTHX_ &m_callback, "GetDataSize" ) )
    {
        wxAutoSV ret( aTHX_ wxPliVirtualCallback_CallCallback
                                ( aTHX_ &m_callback, G_SCALAR, NULL ) );
        return SvUV( ret )
// wxGTK bug!
#if WXPERL_W_VERSION_GE( 2, 6, 2 ) && defined(__WXGTK__)
            + 1
#endif
            ;
    } else 
        return wxDataObjectSimple::GetDataSize(); 
}

bool wxPlDataObjectSimple::GetDataHere( void* param1 ) const
{
    dTHX;
    if( wxPliVirtualCallback_FindCallback( aTHX_ &m_callback, "GetDataHere" ) )
    {
        wxAutoSV ret( aTHX_ wxPliVirtualCallback_CallCallback
                                ( aTHX_ &m_callback, G_SCALAR, NULL ) );
        if( !SvOK( ret ) )
            return false;
        STRLEN len;
        char* val = SvPV( ret, len );
        memcpy( param1, val, len );
        return true;
    } else
        return wxDataObjectSimple::GetDataHere( param1 );
}

bool wxPlDataObjectSimple::SetData( size_t param1, const void* param2 )
{
    dTHX;
    if( wxPliVirtualCallback_FindCallback( aTHX_ &m_callback, "SetData" ) )
    {
        wxAutoSV n( aTHX_ newSVpvn( CHAR_P (const char*)param2, param1 ) );
        wxAutoSV ret( aTHX_ wxPliVirtualCallback_CallCallback
                                ( aTHX_ &m_callback, G_SCALAR, "s", (SV*)n ));
        return SvTRUE( ret );
    } else
        return wxDataObjectSimple::SetData( param1, param2 );
}