File: DataObject.xs

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 (350 lines) | stat: -rw-r--r-- 7,526 bytes parent folder | download | duplicates (7)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#############################################################################
## Name:        ext/dnd/XS/DataObject.xs
## Purpose:     XS for Wx::*DataObject and Wx::DataFormat
## Author:      Mattia Barbon
## Modified by:
## Created:     12/08/2001
## RCS-ID:      $Id: DataObject.xs 2055 2007-06-18 22:05:48Z mbarbon $
## Copyright:   (c) 2001-2004, 2006-2007 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/dataobject.h"

MODULE=Wx PACKAGE=Wx::DataFormat

#ifdef __WXGTK20__

wxDataFormat*
newNative( dummy, format = wxDF_INVALID )
    SV* dummy
    wxDataFormatId format
  CODE:
    RETVAL = new wxDataFormat( format );
  OUTPUT: RETVAL

#else

wxDataFormat*
newNative( dummy, format = wxDF_INVALID )
    SV* dummy
    NativeFormat format
  CODE:
    RETVAL = new wxDataFormat( format );
  OUTPUT: RETVAL

#endif

#if WXPERL_W_VERSION_GE( 2, 9, 0 )

wxDataFormat*
newUser( dummy, id )
    SV* dummy
    wxString id
  CODE:
    RETVAL = new wxDataFormat( id );
  OUTPUT: RETVAL

#else

wxDataFormat*
newUser( dummy, id )
    SV* dummy
    wxChar* id
  CODE:
    RETVAL = new wxDataFormat( id );
  OUTPUT: RETVAL

#endif

static void
wxDataFormat::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );

## // thread OK
void
wxDataFormat::DESTROY()
  CODE:
    wxPli_thread_sv_unregister( aTHX_ "Wx::DataFormat", THIS, ST(0) );
    delete THIS;

wxString
wxDataFormat::GetId()

void
wxDataFormat::SetId( id )
    wxString id

#if defined( __WXMSW__ )

NativeFormat
wxDataFormat::GetType()

void
wxDataFormat::SetType( type )
    NativeFormat type

#else

wxDataFormatId
wxDataFormat::GetType()

#if 0

void
wxDataFormat::SetType( type )
    wxDataFormatId type

#endif

#endif

MODULE=Wx PACKAGE=Wx::DataObject

static void
wxDataObject::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );

# // thread OK
void
DESTROY( THIS )
    wxDataObject* THIS
  CODE:
    wxPli_thread_sv_unregister( aTHX_ wxPli_get_class( aTHX_ ST(0) ), THIS, ST(0) );
    if( THIS && wxPli_object_is_deleteable( aTHX_ ST(0) ) )
    {
        delete THIS;
    }

void
wxDataObject::Destroy()
  CODE:
    wxPli_thread_sv_unregister( aTHX_ wxPli_get_class( aTHX_ ST(0) ), THIS, ST(0) );
    delete THIS;

void
wxDataObject::GetAllFormats( dir = wxDataObjectBase::Get )
    Direction dir
  PPCODE:
    size_t formats = THIS->GetFormatCount( dir );
    size_t i, wanted = formats;
    wxDataFormat* formats_d = new wxDataFormat[ formats ];

    THIS->GetAllFormats( formats_d, dir );
    if( GIMME_V == G_SCALAR )
        wanted = 1;
    EXTEND( SP, (IV)wanted );
    for( i = 0; i < wanted; ++i )
    {
        PUSHs( wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
                new wxDataFormat( formats_d[i] ), "Wx::DataFormat" ) );
    }
    delete [] formats_d;

bool
wxDataObject::GetDataHere( format, buf )
    wxDataFormat* format
    SV* buf
  CODE:
    size_t size = THIS->GetDataSize( *format );
    void* buffer = SvGROW( buf, size + 1 );

    SvCUR_set( buf, size );
    RETVAL = THIS->GetDataHere( *format, buffer );
  OUTPUT: RETVAL

size_t
wxDataObject::GetDataSize( format )
    wxDataFormat* format
  CODE:
    RETVAL = THIS->GetDataSize( *format );
  OUTPUT: RETVAL

size_t
wxDataObject::GetFormatCount( dir = wxDataObjectBase::Get )
    Direction dir

wxDataFormat*
wxDataObject::GetPreferredFormat( dir = wxDataObjectBase::Get )
    Direction dir
  CODE:
    RETVAL = new wxDataFormat( THIS->GetPreferredFormat( dir ) );
  OUTPUT: RETVAL

bool
wxDataObject::IsSupported( format, dir = wxDataObjectBase::Get )
    wxDataFormat* format
    Direction dir
  CODE:
    RETVAL = THIS->IsSupported( *format, dir );
  OUTPUT: RETVAL

bool
wxDataObject::SetData( format, buf )
    wxDataFormat* format
    SV* buf
  PREINIT:
    char* data;
    STRLEN len;
  CODE:
    data = SvPV( buf, len );
    RETVAL = THIS->SetData( *format, len, data );
  OUTPUT: RETVAL

MODULE=Wx PACKAGE=Wx::DataObjectSimple

wxDataObjectSimple*
wxDataObjectSimple::new( format = (wxDataFormat*)&wxFormatInvalid )
    wxDataFormat* format
  CODE:
    RETVAL = new wxDataObjectSimple( *format );
  OUTPUT: RETVAL

wxDataFormat*
wxDataObjectSimple::GetFormat()
  CODE:
    RETVAL = new wxDataFormat( THIS->GetFormat() );
  OUTPUT: RETVAL

void
wxDataObjectSimple::SetFormat( format )
    wxDataFormat* format
  CODE:
    THIS->SetFormat( *format );

MODULE=Wx PACKAGE=Wx::PlDataObjectSimple

SV*
wxPlDataObjectSimple::new( format = (wxDataFormat*)&wxFormatInvalid )
    wxDataFormat* format
  CODE:
    wxPlDataObjectSimple* THIS = new wxPlDataObjectSimple( CLASS, *format );
    RETVAL = newRV_noinc( SvRV( THIS->m_callback.GetSelf() ) );
    wxPli_thread_sv_register( aTHX_ "Wx::PlDataObjectSimple", THIS, RETVAL );
  OUTPUT: RETVAL

## // thread OK
void
wxPlDataObjectSimple::DESTROY()
  CODE:
    wxPli_thread_sv_unregister( aTHX_ "Wx::PlDataObjectSimple", THIS, ST(0) );
    if( THIS && wxPli_object_is_deleteable( aTHX_ ST(0) ) )
    {
        SV* self = THIS->m_callback.GetSelf();
        SvROK_off( self );
        SvRV( self ) = NULL;
        delete THIS;
    }

MODULE=Wx PACKAGE=Wx::DataObjectComposite

wxDataObjectComposite*
wxDataObjectComposite::new()

void
wxDataObjectComposite::Add( dataObject, preferred = false )
    wxDataObjectSimple* dataObject
    bool preferred
  CODE:
    // at this point the data object is owned!
    wxPli_object_set_deleteable( aTHX_ ST(1), false );
    SvREFCNT_inc( SvRV( ST(1) ) ); // at this point the scalar must not go away
    THIS->Add( dataObject, preferred );

#if WXPERL_W_VERSION_GE( 2, 7, 0 )

wxDataFormat*
wxDataObjectComposite::GetReceivedFormat()
  CODE:
    RETVAL = new wxDataFormat( THIS->GetReceivedFormat() );
  OUTPUT: RETVAL

#endif

MODULE=Wx PACKAGE=Wx::TextDataObject

wxTextDataObject*
wxTextDataObject::new( text = wxEmptyString )
    wxString text

size_t
wxTextDataObject::GetTextLength()

wxString
wxTextDataObject::GetText()

void
wxTextDataObject::SetText( text )
    wxString text

MODULE=Wx PACKAGE=Wx::BitmapDataObject

#if WXPERL_W_VERSION_GE( 2, 5, 1 ) || !defined(__WXMOTIF__)

wxBitmapDataObject*
wxBitmapDataObject::new( bitmap = (wxBitmap*)&wxNullBitmap )
    wxBitmap* bitmap
  CODE:
    RETVAL = new wxBitmapDataObject( *bitmap );
  OUTPUT: RETVAL

wxBitmap*
wxBitmapDataObject::GetBitmap()
  CODE:
    RETVAL = new wxBitmap( THIS->GetBitmap() );
  OUTPUT: RETVAL

void
wxBitmapDataObject::SetBitmap( bitmap )
    wxBitmap* bitmap
  CODE:
    THIS->SetBitmap( *bitmap );

#endif

MODULE=Wx PACKAGE=Wx::FileDataObject

#if !defined(__WXMOTIF__)

wxFileDataObject*
wxFileDataObject::new()

void
wxFileDataObject::AddFile( file )
    wxString file

void
wxFileDataObject::GetFilenames()
  PREINIT:
    int i, max;
  PPCODE:
    const wxArrayString& filenames = THIS->GetFilenames();
    max = filenames.GetCount();
    EXTEND( SP, max );
    for( i = 0; i < max; ++i ) {
#if wxUSE_UNICODE
      SV* tmp = sv_2mortal( newSVpv( filenames[i].mb_str(wxConvUTF8), 0 ) );
      SvUTF8_on( tmp );
      PUSHs( tmp );
#else
      PUSHs( sv_2mortal( newSVpv( CHAR_P filenames[i].c_str(), 0 ) ) );
#endif
    }

MODULE=Wx PACKAGE=Wx::URLDataObject

wxURLDataObject*
wxURLDataObject::new()

wxString
wxURLDataObject::GetURL()

void
wxURLDataObject::SetURL( url )
    wxString url

#endif