Mercurial > projects > dwt-win
changeset 79:67d24430822a
Delayed DLL load
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 06 Feb 2008 11:08:01 +0100 |
parents | b00303c762ac |
children | 1801ddeb8f32 |
files | dwt/dwthelper/utils.d dwt/internal/gdip/native.d dwt/internal/win32/OS.d |
diffstat | 3 files changed, 138 insertions(+), 88 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/dwthelper/utils.d Tue Feb 05 20:28:19 2008 +0100 +++ b/dwt/dwthelper/utils.d Wed Feb 06 11:08:01 2008 +0100 @@ -147,20 +147,20 @@ } } -struct GCStats { +private struct GCStats { size_t poolsize; // total size of pool size_t usedsize; // bytes allocated size_t freeblocks; // number of blocks marked FREE size_t freelistsize; // total of memory on free lists size_t pageblocks; // number of blocks marked PAGE } -extern(C) GCStats gc_stats(); +private extern(C) GCStats gc_stats(); + size_t RuntimeTotalMemory(){ GCStats s = gc_stats(); return s.poolsize; } -}
--- a/dwt/internal/gdip/native.d Tue Feb 05 20:28:19 2008 +0100 +++ b/dwt/internal/gdip/native.d Wed Feb 06 11:08:01 2008 +0100 @@ -12,8 +12,9 @@ module dwt.internal.gdip.native; -private import dwt.internal.win32.WINTYPES; -// private import tango.core.Memory; +import dwt.internal.win32.WINTYPES; +import tango.sys.SharedLib : SharedLib; +import tango.util.log.Trace; extern(Windows): @@ -721,6 +722,9 @@ Status GdipSetStringFormatHotkeyPrefix(Handle format, int hotkeyPrefix); Status GdipSetStringFormatTabStops( Handle format, float firstTabOffset, int count, float* tabStops); +void loadLib_Gdip(){ + // do nothing in this version +} } else{ // version(!STATIC_GDIPLUS) @@ -1671,8 +1675,21 @@ { "GdipSetStringFormatTabStops", cast(void**)& GdipSetStringFormatTabStops }, ]; + +void loadLib_Gdip(){ + if (auto lib = SharedLib.load(`gdiplus.dll`)) { + foreach( inout s; symbols ){ + *s.symbol = lib.getSymbol( s.name.ptr ); + if( s.symbol is null ){ + Trace.formatln("gdiplus.dll: Symbol '{}' not found", s.name ); + } + } + } else { + Trace.formatln("Could not load the library gdiplus.dll"); + } } +} /******************************************************************************
--- a/dwt/internal/win32/OS.d Tue Feb 05 20:28:19 2008 +0100 +++ b/dwt/internal/win32/OS.d Wed Feb 06 11:08:01 2008 +0100 @@ -18,6 +18,8 @@ import dwt.internal.C; import dwt.internal.Library; +import tango.sys.SharedLib : SharedLib; +import tango.util.log.Trace; @@ -58,6 +60,11 @@ public class OS : C { + struct Symbol { + char[] name; + void** symbol; + } + public static HINSTANCE GetLibraryHandle(){ //PORTING_FIXME: GetLibraryHandle // is the hInstance of the DLL or null, if not a DLL. @@ -4071,25 +4078,20 @@ // ---------------------------------------------------------------------------- // UxTheme dummies until dynamic loading is in place. // ---------------------------------------------------------------------------- -public static { - BOOL IsAppThemed(){ - return 0; - } - - HRESULT DrawThemeBackground( +public static extern(Windows) { + BOOL function ( + ) IsAppThemed; + + HRESULT function( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *pRect, RECT *pClipRect - ) - { - return S_OK; - } - - - HRESULT DrawThemeEdge( + ) DrawThemeBackground; + + HRESULT function( HTHEME hTheme, HDC hdc, int iPartId, @@ -4098,13 +4100,9 @@ UINT uEdge, UINT uFlags, LPRECT pContentRect - ) - { - return S_OK; - } - - - HRESULT DrawThemeIcon( + ) DrawThemeEdge; + + HRESULT function( HTHEME hTheme, HDC hdc, int iPartId, @@ -4112,22 +4110,15 @@ LPCRECT pRect, HIMAGELIST himl, int iImageIndex - ) - { - return S_OK; - } - - - HRESULT DrawThemeParentBackground( + ) DrawThemeIcon; + + HRESULT function( HWND hwnd, HDC hdc, RECT *prc - ) - { - return S_OK; - } - - HRESULT DrawThemeText( + ) DrawThemeParentBackground; + + HRESULT function( HTHEME hTheme, HDC hdc, int iPartId, @@ -4137,54 +4128,37 @@ DWORD dwTextFlags, DWORD dwTextFlags2, LPCRECT pRect - ) - { - return S_OK; - } - - HTHEME OpenThemeData( + ) DrawThemeText; + + HTHEME function( HWND hwnd, LPCWSTR pszClassList - ) - { - return null; - } - - - HRESULT BufferedPaintInit(){ - return S_OK; - } - - HRESULT CloseThemeData( + ) OpenThemeData; + + HRESULT function( + )BufferedPaintInit; + + HRESULT function( HTHEME hTheme - ){ - return S_OK; - } - - - HRESULT BufferedPaintUnInit(){ - return S_OK; - } - - HPAINTBUFFER BeginBufferedPaint( + ) CloseThemeData; + + HRESULT function( + ) BufferedPaintUnInit; + + HPAINTBUFFER function( HDC hdcTarget, RECT *prcTarget, uint/+BP_BUFFERFORMAT+/ dwFormat, void*/+BP_PAINTPARAMS+/ pPaintParams, HDC *phdc - ){ - return null; - } - - - HRESULT EndBufferedPaint( + ) BeginBufferedPaint; + + HRESULT function( HPAINTBUFFER hBufferedPaint, BOOL fUpdateTarget - ){ - return S_OK; - } - - HRESULT GetThemeTextExtent( + ) EndBufferedPaint; + + HRESULT function( HTHEME hTheme, HDC hdc, int iPartId, @@ -4194,23 +4168,48 @@ DWORD dwTextFlags, LPCRECT pBoundingRect, LPRECT pExtentRect - ) - { - return S_OK; - } - - HRESULT SetWindowTheme( + ) GetThemeTextExtent; + + HRESULT function( HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList - ) - { - return S_OK; + ) SetWindowTheme; + +} // public static + +static Symbol[] Symbols_UxTheme = [ + { "IsAppThemed", cast(void**)& IsAppThemed }, + { "DrawThemeBackground", cast(void**)& DrawThemeBackground }, + { "DrawThemeEdge", cast(void**)& DrawThemeEdge }, + { "DrawThemeIcon", cast(void**)& DrawThemeIcon }, + { "DrawThemeParentBackground", cast(void**)& DrawThemeParentBackground }, + { "DrawThemeText", cast(void**)& DrawThemeText }, + { "OpenThemeData", cast(void**)& OpenThemeData }, + { "BufferedPaintInit", cast(void**)& BufferedPaintInit }, + { "CloseThemeData", cast(void**)& CloseThemeData }, + { "BufferedPaintUnInit", cast(void**)& BufferedPaintUnInit }, + { "BeginBufferedPaint", cast(void**)& BeginBufferedPaint }, + { "EndBufferedPaint", cast(void**)& EndBufferedPaint }, + { "GetThemeTextExtent", cast(void**)& GetThemeTextExtent }, + { "SetWindowTheme", cast(void**)& SetWindowTheme }, +]; + +static void loadLib_UxTheme(){ + if (auto lib = SharedLib.load(`uxtheme.dll`)) { + foreach( inout s; Symbols_UxTheme ){ + *s.symbol = lib.getSymbol( s.name.ptr ); + if( s.symbol is null ){ + Trace.formatln("UxTheme.dll: Symbol '{}' not found", s.name ); + } + } + } else { + Trace.formatln("Could not load the library UxTheme.dll"); } -} // public static - +} //---------------------------------------------------------------------- // Coreimm.lib (WinCE) +// this function vars exist primarily for link error elimination //---------------------------------------------------------------------- public static extern(Windows) { @@ -4302,7 +4301,41 @@ BOOL fOpen ) ImmSetOpenStatus; -} // public static +} // public static extern(Windows) + +static Symbol[] Symbols_CoreImm = [ + { "ImmAssociateContext", cast(void**)& ImmAssociateContext }, + { "ImmCreateContext", cast(void**)& ImmCreateContext }, + { "ImmDestroyContext", cast(void**)& ImmDestroyContext }, + { "ImmGetContext", cast(void**)& ImmGetContext }, + { "ImmGetConversionStatus", cast(void**)& ImmGetConversionStatus }, + { "ImmGetDefaultIMEWnd", cast(void**)& ImmGetDefaultIMEWnd }, + { "ImmGetOpenStatus", cast(void**)& ImmGetOpenStatus }, + { "ImmReleaseContext", cast(void**)& ImmReleaseContext }, + { "ImmSetCompositionFont", cast(void**)& ImmSetCompositionFont }, + { "ImmGetCompositionString", cast(void**)& ImmGetCompositionString }, + { "ImmGetCompositionFont", cast(void**)& ImmGetCompositionFont }, + { "ImmSetCompositionFont", cast(void**)& ImmSetCompositionFont }, + { "ImmGetCompositionString", cast(void**)& ImmGetCompositionString }, + { "ImmGetCompositionFont", cast(void**)& ImmGetCompositionFont }, + { "ImmSetCompositionWindow", cast(void**)& ImmSetCompositionWindow }, + { "ImmSetConversionStatus", cast(void**)& ImmSetConversionStatus }, + { "ImmSetOpenStatus", cast(void**)& ImmSetOpenStatus }, +]; + +static void loadLib_CoreImm(){ + if (auto lib = SharedLib.load(`coreimm.dll`)) { + foreach( inout s; Symbols_CoreImm ){ + *s.symbol = lib.getSymbol( s.name.ptr ); + if( s.symbol is null ){ + Trace.formatln("CoreImm.dll: Symbol '{}' not found", s.name ); + } + } + } else { + Trace.formatln("Could not load the library coreimm.dll"); + } +} + //------------------------------------------------------------------------ /** All Natives */ alias WINAPI.AbortDoc AbortDoc;