1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: main XS module
4 // Author: Mattia Barbon
7 // RCS-ID: $Id: Wx.xs 2610 2009-09-20 13:28:54Z mbarbon $
8 // Copyright: (c) 2000-2002, 2004-2009 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 /////////////////////////////////////////////////////////////////////////////
14 #define PERL_NO_GET_CONTEXT
17 #include "cpp/compat.h"
24 #include "cpp/wxapi.h"
26 #include <wx/window.h>
27 #include <wx/module.h>
29 #if WXPERL_W_VERSION_GE( 2, 5, 2 ) \
30 && defined(__DARWIN__)
32 #include <wx/html/htmlwin.h>
34 #include <wx/mediactrl.h>
38 #if defined(__WXMSW__)
39 #include <wx/msw/private.h>
42 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
45 #if defined(__WXGTK__)
46 int WXDLLEXPORT wxEntryStart( int& argc, char** argv );
48 int WXDLLEXPORT wxEntryStart( int argc, char** argv );
50 int WXDLLEXPORT wxEntryInitGui();
51 void WXDLLEXPORT wxEntryCleanup();
54 #include "cpp/v_cback.h"
56 // to declare wxPliUserDataCD
57 #include "cpp/helpers.h"
58 #include "cpp/helpers.cpp"
59 #include "cpp/v_cback.cpp"
60 #include "cpp/overload.cpp"
61 #include "cpp/ovl_const.cpp"
69 IMPLEMENT_APP_NO_MAIN(wxPliApp);
70 static bool wxPerlAppCreated = false;
71 static bool wxPerlInitialized = false;
73 bool wxPli_always_utf8;
87 #if defined( WXPL_STATIC )
88 XS( boot_Wx__DocView );
107 extern void SetConstants();
108 extern void SetConstantsOnce();
110 static int call_oninit( pTHX_ SV* This, SV* sub )
121 int count = call_sv( sub, G_SCALAR|G_EVAL );
126 if( SvTRUE( ERRSV ) )
130 else if( count == 1 )
144 #if defined(__WXMOTIF__) && WXPERL_W_VERSION_LT( 2, 5, 1 )
149 int wxEntryStart( int argc, char** argv )
151 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
152 // This seems to be necessary since there are 'rogue'
153 // objects present at this point (perhaps global objects?)
154 // Setting a checkpoint will ignore them as far as the
155 // memory checking facility is concerned.
156 // Of course you may argue that memory allocated in globals should be
157 // checked, but this is a reasonable compromise.
158 wxDebugContext::SetCheckpoint();
161 if (!wxApp::Initialize())
171 // GUI-specific initialization, such as creating an app context.
172 if( !wxTheApp->OnInitGui() )
178 void wxEntryCleanup()
180 // flush the logged messages if any
181 wxLog *pLog = wxLog::GetActiveTarget();
182 if ( pLog != NULL && pLog->HasPendingMessages() )
185 delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
186 // for further messages
190 // some code moved to _wxApp destructor
191 // since at this point the app is already destroyed
196 DEFINE_PLI_HELPERS( st_wxPliHelpers );
198 #include <wx/confbase.h>
199 typedef wxConfigBase::EntryType EntryType;
201 WXPLI_BOOT_ONCE_EXP(Wx);
202 #define boot_Wx wxPli_boot_Wx
204 extern bool Wx_booted, Wx_Const_booted, Wx_Ctrl_booted,
205 Wx_Evt_booted, Wx_Wnd_booted, Wx_GDI_booted, Wx_Win_booted;
207 #if WXPERL_W_VERSION_LT( 2, 9, 0 )
208 typedef int wxPolygonFillMode;
214 newXSproto( "Wx::_boot_Constant", boot_Wx_Const, file, "$$" );
215 newXSproto( "Wx::_boot_Controls", boot_Wx_Ctrl, file, "$$" );
216 newXSproto( "Wx::_boot_Events", boot_Wx_Evt, file, "$$" );
217 newXSproto( "Wx::_boot_Window", boot_Wx_Win, file, "$$" );
218 newXSproto( "Wx::_boot_Frames", boot_Wx_Wnd, file, "$$" );
219 newXSproto( "Wx::_boot_GDI", boot_Wx_GDI, file, "$$" );
220 #if defined( WXPL_STATIC )
221 newXSproto( "Wx::_boot_Wx__DocView", boot_Wx__DocView, file, "$$" );
223 newXSproto( "Wx::_boot_Wx__STC", boot_Wx__STC, file, "$$" );
226 newXSproto( "Wx::_boot_Wx__XRC", boot_Wx__XRC, file, "$$" );
228 newXSproto( "Wx::_boot_Wx__Print", boot_Wx__Print, file, "$$" );
229 newXSproto( "Wx::_boot_Wx__MDI", boot_Wx__MDI, file, "$$" );
230 newXSproto( "Wx::_boot_Wx__Html", boot_Wx__Html, file, "$$" );
231 newXSproto( "Wx::_boot_Wx__Help", boot_Wx__Help, file, "$$" );
232 newXSproto( "Wx::_boot_Wx__Grid", boot_Wx__Grid, file, "$$" );
233 newXSproto( "Wx::_boot_Wx__FS", boot_Wx__FS, file, "$$" );
234 newXSproto( "Wx::_boot_Wx__DND", boot_Wx__DND, file, "$$" );
236 SV* tmp = get_sv( "Wx::_exports", 1 );
237 sv_setiv( tmp, (IV)(void*)&st_wxPliHelpers );
239 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
240 #define wxPliEntryStart( argc, argv ) wxEntryStart( (argc), (argv) )
242 #define wxPliEntryStart( argc, argv ) ( wxEntryStart( (argc), (argv) ) == 0 )
248 wxPerlAppCreated = wxTheApp != NULL;
249 if( wxPerlInitialized ) { XSRETURN( true ); }
250 wxPerlInitialized = true;
252 NV ver = wxMAJOR_VERSION + wxMINOR_VERSION / 1000.0 +
253 wxRELEASE_NUMBER / 1000000.0;
254 // set up version as soon as possible
255 SV* tmp = get_sv( "Wx::_wx_version", 1 );
256 sv_setnv( tmp, ver );
257 tmp = get_sv( "Wx::wxVERSION", 1 );
258 sv_setnv( tmp, ver );
261 // change App.pm whenever these change
262 #if defined(__WXMSW__)
264 #elif defined(__WXGTK__)
266 #elif defined(__WXMOTIF__)
268 #elif defined(__WXMAC__)
270 #elif defined(__WXX11__)
276 tmp = get_sv( "Wx::_platform", 1 );
277 sv_setiv( tmp, platform );
279 if( wxPerlAppCreated || wxTopLevelWindows.GetCount() > 0 )
281 #if defined(DEBUGGING) && !defined(PERL_USE_SAFE_PUTENV)
282 // avoid crash on exit in Fedora (and other DEBUGGING Perls)
283 PL_use_safe_putenv = 1;
287 #if wxUSE_UNICODE && WXPERL_W_VERSION_GE( 2, 5, 3 )
290 argc = wxPli_get_args_argc_argv( (void***) &argv, 1 );
291 wxPerlInitialized = wxPliEntryStart( argc, argv );
292 #if WXPERL_W_VERSION_LE( 2, 5, 2 )
293 wxPli_delete_argv( (void***) &argv, 1 );
298 argc = wxPli_get_args_argc_argv( (void***) &argv, 0 );
299 wxPerlInitialized = wxPliEntryStart( argc, argv );
300 #if WXPERL_W_VERSION_LE( 2, 5, 2 )
301 wxPli_delete_argv( (void***) &argv, 0 );
304 RETVAL = wxPerlInitialized;
310 // this is after wxEntryStart, since
311 // wxInitializeStockObjects needs to be called
312 // (for colours, cursors, pens, etc...)
324 wxPerlAppCreated = wxTheApp != NULL;
325 Wx_booted = Wx_Const_booted = Wx_Ctrl_booted =
326 Wx_Evt_booted = Wx_Wnd_booted = Wx_GDI_booted = Wx_Win_booted = false;
327 if( wxPerlInitialized && !wxPerlAppCreated )
329 wxPerlInitialized = false;
332 SetAlwaysUTF8( always_utf8 = true )
336 wxPli_always_utf8 = always_utf8;
339 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
341 #include <wx/dynload.h>
344 _load_plugin( string )
348 delete new wxHtmlWindow();
350 delete new wxMediaCtrl();
353 RETVAL = wxPluginManager::LoadLibrary( string, wxDL_VERBATIM );
358 _unload_plugin( string )
361 RETVAL = wxPluginManager::UnloadLibrary( string );
368 _xsmatch( avref, proto, required = -1, allowmore = false )
375 wxPliPrototype* prototype;
379 av = wxPli_avref_2_av( avref );
380 if( !av ) croak( "first parameter must be an ARRAY reference" );
381 prototype = INT2PTR( wxPliPrototype*, SvIV( proto ) );
382 len = av_len( av ) + 1;
385 for( int i = 0; i < len; ++i )
386 PUSHs( *av_fetch( av, i, 0 ) );
388 RETVAL = wxPli_match_arguments( aTHX_ *prototype, required, allowmore );
390 POPMARK; // wxPli_match_* does a PUSHMARK
394 looks_like_number( sval )
397 RETVAL = my_looks_like_number( aTHX_ sval );
412 INCLUDE: XS/ToolTip.xs
413 INCLUDE: XS/Locale.xs
416 INCLUDE: XS/Stream.xs
417 INCLUDE: XS/TaskBarIcon.xs
418 INCLUDE: XS/Config.xs
419 INCLUDE: XS/Process.xs
420 INCLUDE: XS/FontMapper.xs
421 INCLUDE: XS/FontEnumerator.xs
423 INCLUDE: perl -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp XS/ArtProvider.xsp |
425 INCLUDE: perl -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp XS/MimeTypes.xsp |
427 INCLUDE: perl -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp XS/Sound.xsp |
429 INCLUDE: perl -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp XS/Power.xsp |
431 INCLUDE: perl -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp XS/ClassInfo.xs |
433 INCLUDE: perl -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp XS/Display.xsp |
435 INCLUDE: perl -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp XS/StandardPaths.xsp |
437 INCLUDE: perl -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp XS/Variant.xsp |
439 INCLUDE: perl -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp XS/NotificationMessage.xsp |
442 ##if defined(__WXMSW__)
444 ##define XS( name ) WXXS( name )
449 #!irrelevant class wxArray
450 #!irrelevant class wxArray<T>
451 #!irrelevant class wxArrayString
452 #!irrelevant class wxObjArray
453 #!irrelevant class wxBrushList
454 #!irrelevant class wxClientData
455 #!irrelevant class wxClientDataContainer
456 #!irrelevant class wxCondition
457 #!irrelevant class wxCriticalSection
458 #!irrelevant class wxCriticalSectionLocker
459 #!irrelevant class wxDebugContext
460 #!irrelevant class wxDebugStreamBuf
461 #!irrelevant class wxDynamicLibrary
462 #!irrelevant class wxDynamicLibraryDetails
463 #!irrelevant class wxFFile
464 #!irrelevant class wxFFileInputStream
465 #!irrelevant class wxFFileOutputStream
466 #!irrelevant class wxFFileStream
467 #!irrelevant class wxFile
468 #!irrelevant class wxFileInputStream
469 #!irrelevant class wxFileOutputStream
470 #!irrelevant class wxFileStream
471 #!irrelevant class wxFilterClassFactory
472 #!irrelevant class wxFontList
473 #!irrelevant class wxHashMap
474 #!irrelevant class wxHashSet
475 #!irrelevant class wxHashTable
476 #!irrelevant class wxList
477 #!irrelevant class wxLongLong
478 #!irrelevant class wxMemoryBuffer
479 #!irrelevant class wxModule
480 #!irrelevant class wxMutex
481 #!irrelevant class wxMutexLocker
482 #!irrelevant class wxNode
483 #!irrelevant class wxObjectRefData
484 #!irrelevant class wxPathList
485 #!irrelevant class wxPenList
486 #!irrelevant class wxProtocol
487 #!irrelevant class wxRecursionGuard
488 #!irrelevant class wxRecursionGuardFlag
489 #!irrelevant class wxScopedArray
490 #!irrelevant class wxScopedPtr
491 #!irrelevant class wxScopedTiedPtr
492 #!irrelevant class wxSemaphore
493 #!irrelevant class wxString
494 #!irrelevant class wxStringBuffer
495 #!irrelevant class wxStringBufferLength
496 #!irrelevant class wxStringClientData
497 #!irrelevant class wxStringTokenizer
498 #!irrelevant class wxThreadHelper
500 #!equivalent class wxThread to Perl modules thread, thread::shared
502 #!equivalent class wxArchiveClassFactory to Perl modules Archive::Any, Archive::Zip, Archive::Tar
503 #!equivalent class wxArchiveEntry to Perl modules Archive::Any, Archive::Zip, Archive::Tar
504 #!equivalent class wxArchiveInputStream to Perl modules Archive::Any, Archive::Zip, Archive::Tar
505 #!equivalent class wxArchiveIterator to Perl modules Archive::Any, Archive::Zip, Archive::Tar
506 #!equivalent class wxArchiveNotifier to Perl modules Archive::Any, Archive::Zip, Archive::Tar
507 #!equivalent class wxArchiveOutputStream to Perl modules Archive::Any, Archive::Zip, Archive::Tar
508 #!equivalent class wxAutomationObject to perl module Win32::OLE
510 #!equivalent class wxCSConv to Perl module Encode
511 #!equivalent class wxEncodingConverter to Perl module Encode
512 #!equivalent class wxMBConv to Perl module Encode
513 #!equivalent class wxMBConvFile to Perl module Encode
514 #!equivalent class wxMBConvUTF16 to Perl module Encode
515 #!equivalent class wxMBConvUTF32 to Perl module Encode
516 #!equivalent class wxMBConvUTF7 to Perl module Encode
517 #!equivalent class wxMBConvUTF8 to Perl module Encode
519 #!equivalent class wxDb to Perl module DBI
520 #!equivalent class wxDbColDataPtr to Perl module DBI
521 #!equivalent class wxDbColDef to Perl module DBI
522 #!equivalent class wxDbColFor to Perl module DBI
523 #!equivalent class wxDbColInf to Perl module DBI
524 #!equivalent class wxDbConnectInf to Perl module DBI
525 #!irrelevant class wxDbGridColInfo
526 #!equivalent class wxDbIdxDef to Perl module DBI
527 #!equivalent class wxDbInf to Perl module DBI
528 #!equivalent class wxDbTable to Perl module DBI
529 #!equivalent class wxDbTableInf to Perl module DBI
531 #!equivalent class wxDir to opendir/readdir and to Perl modules File::Find, File::Find::Rule
532 #!equivalent class wxDirTraverser to Perl modules File::Find, File::Find::Rule
533 #!equivalent class wxFileName to File::Spec, Path::Class
535 #!equivalent class wxFTP to Perl modules Net::FTP, LWP::UserAgent
536 #!equivalent class wxHTTP to Perl modules Net::HTTP, LWP::UserAgent
538 #!equivalent class wxRegEx to a Perl regular expression
539 #!equivalent class wxRegKey to Perl module Win32::Registry
541 #!equivalent class wxTarClassFactory to Perl module Archive::Tar
542 #!equivalent class wxTarEntry to Perl module Archive::Tar
543 #!equivalent class wxTarInputStream to Perl module Archive::Tar
544 #!equivalent class wxTarOutputStream to Perl module Archive::Tar
546 #!equivalent class wxTempFile to Perl module File::Temp
547 #!equivalent class wxTempFileOutputStream to Perl module File::Temp
549 #!equivalent class wxTextValidator to Perl module Wx::Perl::TextValidator
551 #!equivalent class wxURI to Perl module URI
552 #!equivalent class wxURL to Perl module URI::URL
554 #!equivalent class wxZipClassFactory to Perl module Archive::Zip
555 #!equivalent class wxZipEntry to Perl module Archive::Zip
556 #!equivalent class wxZipInputStream to Perl module Archive::Zip
557 #!equivalent class wxZipNotifier to Perl module Archive::Zip
558 #!equivalent class wxZipOutputStream to Perl module Archive::Zip
560 #!equivalent class wxZlibInputStream to Perl module Compress::Zlib, IO::Zlib
561 #!equivalent class wxZlibOutputStream to Perl module Compress::Zlib, IO::Zlib
563 #!equivalent class wxBufferedInputStream to Perl input/output
564 #!equivalent class wxBufferedOutputStream to Perl input/output
565 #!equivalent class wxCountingOutputStream to Perl input/output
566 #!equivalent class wxCountingOutputStream to Perl input/output
567 #!equivalent class wxDataInputStream to Perl module Storable
568 #!equivalent class wxDataOutputStream to Perl module Storable
569 #!equivalent class wxFilterInputStream to Perl module PerlIO::via
570 #!equivalent class wxFilterOutputStream to Perl module PerlIO::via
571 #!equivalent class wxMemoryInputStream to Perl module PerlIO::scalar
572 #!equivalent class wxMemoryOutputStream to Perl module PerlIO::scalar
573 #!equivalent class wxSocketInputStream to Perl modules IO::Socket::*
574 #!equivalent class wxSocketOutputStream to Perl modules IO::Socket::*
575 #!equivalent class wxStreamBase to Perl input/output
576 #!equivalent class wxStreamBase to Perl input/output
577 #!equivalent class wxStreamBuffer to Perl input/output
578 #!equivalent class wxStringInputStream to Perl module PerlIO::scalar
579 #!equivalent class wxStringOutputStream to Perl module PerlIO::scalar
580 #!equivalent class wxTextFile to Perl input/output
581 #!equivalent class wxTextInputStream to Perl input/output
582 #!equivalent class wxTextOutputStream to Perl input/output
584 #!equivalent class wxMetafile to Perl module Wx::Metafile
586 #!equivalent class wxDialUpEvent to Perl module Wx::DialUpEvent
587 #!equivalent class wxDialUpManager to Perl module Wx::DialUpManager
589 #!equivalent class wxGLCanvas to Perl module Wx::GLCanvas
590 #!equivalent class wxGLContext to Perl module Wx::GLCanvas
592 #!equivalent class wxDateTime to perl module DateTime, Date::Calc, Date::Manip, Time::Piece
593 #!equivalent class wxDateSpan to perl module DateTime, Date::Calc, Date::Manip, Time::Piece
594 #!equivalent class wxTimeSpan to perl module DateTime, Date::Calc, Date::Manip, Time::Piece