initial commit

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2025-10-31 23:37:30 +01:00
commit 7228269764
9653 changed files with 4034514 additions and 0 deletions

View File

@@ -0,0 +1,356 @@
# =========================================================================
# This makefile was generated by
# Bakefile 0.2.13 (http://www.bakefile.org)
# Do not modify, all changes will be overwritten!
# =========================================================================
@MAKE_SET@
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
INSTALL = @INSTALL@
EXEEXT = @EXEEXT@
WINDRES = @WINDRES@
BK_DEPS = @BK_DEPS@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
LIBS = @LIBS@
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
USE_DPI_AWARE_MANIFEST = @USE_DPI_AWARE_MANIFEST@
WX_LIB_FLAVOUR = @WX_LIB_FLAVOUR@
TOOLKIT = @TOOLKIT@
TOOLKIT_LOWERCASE = @TOOLKIT_LOWERCASE@
TOOLKIT_VERSION = @TOOLKIT_VERSION@
TOOLCHAIN_FULLNAME = @TOOLCHAIN_FULLNAME@
EXTRALIBS = @EXTRALIBS@
EXTRALIBS_XML = @EXTRALIBS_XML@
EXTRALIBS_GUI = @EXTRALIBS_GUI@
EXTRALIBS_OPENGL = @EXTRALIBS_OPENGL@
WX_CPPFLAGS = @WX_CPPFLAGS@
WX_CXXFLAGS = @WX_CXXFLAGS@
WX_LDFLAGS = @WX_LDFLAGS@
HOST_SUFFIX = @HOST_SUFFIX@
DYLIB_RPATH_FLAG = @DYLIB_RPATH_FLAG@
SAMPLES_CXXFLAGS = @SAMPLES_CXXFLAGS@
wx_top_builddir = @wx_top_builddir@
### Variables: ###
DESTDIR =
WX_RELEASE = 3.3
WX_VERSION = $(WX_RELEASE).1
LIBDIRNAME = $(wx_top_builddir)/lib
BENCH_CXXFLAGS = $(WX_CPPFLAGS) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
$(__THREAD_DEFINE_p) -I$(srcdir) $(__DLLFLAG_p) -DwxUSE_GUI=0 $(WX_CXXFLAGS) \
$(SAMPLES_CXXFLAGS) $(CPPFLAGS) $(CXXFLAGS)
BENCH_OBJECTS = \
bench_bench.o \
bench_datetime.o \
bench_htmlpars.o \
bench_htmltag.o \
bench_ipcclient.o \
bench_log.o \
bench_mbconv.o \
bench_regex.o \
bench_strings.o \
bench_tls.o \
bench_printfbench.o
BENCH_GUI_CXXFLAGS = $(WX_CPPFLAGS) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
$(__THREAD_DEFINE_p) -I$(srcdir) $(__DLLFLAG_p) -I$(srcdir)/../../samples \
$(WX_CXXFLAGS) $(SAMPLES_CXXFLAGS) $(CPPFLAGS) $(CXXFLAGS)
BENCH_GUI_OBJECTS = \
$(__bench_gui___win32rc) \
bench_gui_bench.o \
bench_gui_display.o \
bench_gui_image.o
BENCH_GRAPHICS_CXXFLAGS = $(WX_CPPFLAGS) -D__WX$(TOOLKIT)__ \
$(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) \
$(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) -I$(srcdir) $(__DLLFLAG_p) \
-I$(srcdir)/../../samples $(WX_CXXFLAGS) $(SAMPLES_CXXFLAGS) $(CPPFLAGS) \
$(CXXFLAGS)
BENCH_GRAPHICS_OBJECTS = \
$(__bench_graphics___win32rc) \
bench_graphics_graphics.o
### Conditionally set variables: ###
@COND_DEPS_TRACKING_0@CXXC = $(CXX)
@COND_DEPS_TRACKING_1@CXXC = $(BK_DEPS) $(CXX)
@COND_USE_GUI_0@PORTNAME = base
@COND_USE_GUI_1@PORTNAME = $(TOOLKIT_LOWERCASE)$(TOOLKIT_VERSION)
@COND_TOOLKIT_MAC@WXBASEPORT = _carbon
@COND_BUILD_debug@WXDEBUGFLAG = d
@COND_WXUNIV_1@WXUNIVNAME = univ
@COND_MONOLITHIC_0@EXTRALIBS_FOR_BASE = $(EXTRALIBS)
@COND_MONOLITHIC_1@EXTRALIBS_FOR_BASE = $(EXTRALIBS) \
@COND_MONOLITHIC_1@ $(EXTRALIBS_XML) $(EXTRALIBS_GUI)
@COND_MONOLITHIC_0@EXTRALIBS_FOR_GUI = $(EXTRALIBS_GUI)
@COND_MONOLITHIC_1@EXTRALIBS_FOR_GUI =
COND_MONOLITHIC_0___WXLIB_NET_p = \
-lwx_base$(WXBASEPORT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_MONOLITHIC_0@__WXLIB_NET_p = $(COND_MONOLITHIC_0___WXLIB_NET_p)
@COND_MONOLITHIC_1@__LIB_PNG_IF_MONO_p = $(__LIB_PNG_p)
@COND_USE_GUI_1@__bench_gui___depname = bench_gui$(EXEEXT)
@COND_PLATFORM_WIN32_1@__bench_gui___win32rc = bench_gui_sample_rc.o
@COND_PLATFORM_MACOSX_1_USE_GUI_1@__bench_gui_app_Contents_PkgInfo___depname \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ = bench_gui.app/Contents/PkgInfo
@COND_PLATFORM_MACOSX_1_USE_GUI_1@__bench_gui_bundle___depname \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ = bench_gui_bundle
@COND_TOOLKIT_COCOA@____bench_gui_BUNDLE_TGT_REF_DEP = \
@COND_TOOLKIT_COCOA@ $(__bench_gui_app_Contents_PkgInfo___depname)
@COND_TOOLKIT_MAC@____bench_gui_BUNDLE_TGT_REF_DEP = \
@COND_TOOLKIT_MAC@ $(__bench_gui_app_Contents_PkgInfo___depname)
@COND_TOOLKIT_OSX_CARBON@____bench_gui_BUNDLE_TGT_REF_DEP \
@COND_TOOLKIT_OSX_CARBON@ = $(__bench_gui_app_Contents_PkgInfo___depname)
@COND_TOOLKIT_OSX_COCOA@____bench_gui_BUNDLE_TGT_REF_DEP \
@COND_TOOLKIT_OSX_COCOA@ = $(__bench_gui_app_Contents_PkgInfo___depname)
@COND_TOOLKIT_OSX_IPHONE@____bench_gui_BUNDLE_TGT_REF_DEP \
@COND_TOOLKIT_OSX_IPHONE@ = $(__bench_gui_app_Contents_PkgInfo___depname)
@COND_MONOLITHIC_1_USE_STC_1@__LIB_SCINTILLA_IF_MONO_p \
@COND_MONOLITHIC_1_USE_STC_1@ = $(__LIB_SCINTILLA_p)
@COND_MONOLITHIC_1_USE_STC_1@__LIB_LEXILLA_IF_MONO_p = $(__LIB_LEXILLA_p)
@COND_USE_GUI_1@__bench_graphics___depname = bench_graphics$(EXEEXT)
@COND_PLATFORM_WIN32_1@__bench_graphics___win32rc = \
@COND_PLATFORM_WIN32_1@ bench_graphics_sample_rc.o
@COND_PLATFORM_MACOSX_1_USE_GUI_1@__bench_graphics_app_Contents_PkgInfo___depname \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ = bench_graphics.app/Contents/PkgInfo
@COND_PLATFORM_MACOSX_1_USE_GUI_1@__bench_graphics_bundle___depname \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ = bench_graphics_bundle
@COND_TOOLKIT_COCOA@____bench_graphics_BUNDLE_TGT_REF_DEP \
@COND_TOOLKIT_COCOA@ = $(__bench_graphics_app_Contents_PkgInfo___depname)
@COND_TOOLKIT_MAC@____bench_graphics_BUNDLE_TGT_REF_DEP = \
@COND_TOOLKIT_MAC@ $(__bench_graphics_app_Contents_PkgInfo___depname)
@COND_TOOLKIT_OSX_CARBON@____bench_graphics_BUNDLE_TGT_REF_DEP \
@COND_TOOLKIT_OSX_CARBON@ = \
@COND_TOOLKIT_OSX_CARBON@ $(__bench_graphics_app_Contents_PkgInfo___depname)
@COND_TOOLKIT_OSX_COCOA@____bench_graphics_BUNDLE_TGT_REF_DEP \
@COND_TOOLKIT_OSX_COCOA@ = \
@COND_TOOLKIT_OSX_COCOA@ $(__bench_graphics_app_Contents_PkgInfo___depname)
@COND_TOOLKIT_OSX_IPHONE@____bench_graphics_BUNDLE_TGT_REF_DEP \
@COND_TOOLKIT_OSX_IPHONE@ = \
@COND_TOOLKIT_OSX_IPHONE@ $(__bench_graphics_app_Contents_PkgInfo___depname)
@COND_MONOLITHIC_1_USE_STC_1@__LIB_SCINTILLA_IF_MONO_p_1 \
@COND_MONOLITHIC_1_USE_STC_1@ = $(__LIB_SCINTILLA_p)
@COND_MONOLITHIC_1_USE_STC_1@__LIB_LEXILLA_IF_MONO_p_1 = $(__LIB_LEXILLA_p)
@COND_WXUNIV_1@__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__
@COND_WXUNIV_1@__WXUNIV_DEFINE_p_0 = --define __WXUNIVERSAL__
@COND_DEBUG_FLAG_0@__DEBUG_DEFINE_p = -DwxDEBUG_LEVEL=0
@COND_DEBUG_FLAG_0@__DEBUG_DEFINE_p_0 = --define wxDEBUG_LEVEL=0
@COND_USE_EXCEPTIONS_0@__EXCEPTIONS_DEFINE_p = -DwxNO_EXCEPTIONS
@COND_USE_EXCEPTIONS_0@__EXCEPTIONS_DEFINE_p_0 = --define wxNO_EXCEPTIONS
@COND_USE_RTTI_0@__RTTI_DEFINE_p = -DwxNO_RTTI
@COND_USE_RTTI_0@__RTTI_DEFINE_p_0 = --define wxNO_RTTI
@COND_USE_THREADS_0@__THREAD_DEFINE_p = -DwxNO_THREADS
@COND_USE_THREADS_0@__THREAD_DEFINE_p_0 = --define wxNO_THREADS
@COND_SHARED_1@__DLLFLAG_p = -DWXUSINGDLL
@COND_SHARED_1@__DLLFLAG_p_0 = --define WXUSINGDLL
@COND_PLATFORM_WIN32_1@__WIN32_DPI_MANIFEST_p = \
@COND_PLATFORM_WIN32_1@ --define \
@COND_PLATFORM_WIN32_1@ wxUSE_DPI_AWARE_MANIFEST=$(USE_DPI_AWARE_MANIFEST)
@COND_TOOLKIT_MSW@__RCDEFDIR_p = --include-dir \
@COND_TOOLKIT_MSW@ $(LIBDIRNAME)/wx/include/$(TOOLCHAIN_FULLNAME)
COND_MONOLITHIC_0___WXLIB_CORE_p = \
-lwx_$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_MONOLITHIC_0@__WXLIB_CORE_p = $(COND_MONOLITHIC_0___WXLIB_CORE_p)
COND_MONOLITHIC_0___WXLIB_BASE_p = \
-lwx_base$(WXBASEPORT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_MONOLITHIC_0@__WXLIB_BASE_p = $(COND_MONOLITHIC_0___WXLIB_BASE_p)
COND_MONOLITHIC_1___WXLIB_MONO_p = \
-lwx_$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_MONOLITHIC_1@__WXLIB_MONO_p = $(COND_MONOLITHIC_1___WXLIB_MONO_p)
@COND_USE_STC_1@__LIB_SCINTILLA_p = \
@COND_USE_STC_1@ -lwxscintilla$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_USE_STC_1@__LIB_LEXILLA_p = \
@COND_USE_STC_1@ -lwxlexilla$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_USE_GUI_1_wxUSE_LIBTIFF_builtin@__LIB_TIFF_p \
@COND_USE_GUI_1_wxUSE_LIBTIFF_builtin@ = \
@COND_USE_GUI_1_wxUSE_LIBTIFF_builtin@ -lwxtiff$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_USE_GUI_1_wxUSE_LIBJPEG_builtin@__LIB_JPEG_p \
@COND_USE_GUI_1_wxUSE_LIBJPEG_builtin@ = \
@COND_USE_GUI_1_wxUSE_LIBJPEG_builtin@ -lwxjpeg$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_USE_GUI_1_wxUSE_LIBPNG_builtin@__LIB_PNG_p \
@COND_USE_GUI_1_wxUSE_LIBPNG_builtin@ = \
@COND_USE_GUI_1_wxUSE_LIBPNG_builtin@ -lwxpng$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_USE_GUI_1_wxUSE_LIBWEBP_builtin@__LIB_WEBP_p \
@COND_USE_GUI_1_wxUSE_LIBWEBP_builtin@ = \
@COND_USE_GUI_1_wxUSE_LIBWEBP_builtin@ -lwxwebp$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_wxUSE_ZLIB_builtin@__LIB_ZLIB_p = \
@COND_wxUSE_ZLIB_builtin@ -lwxzlib$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_wxUSE_REGEX_builtin@__LIB_REGEX_p = \
@COND_wxUSE_REGEX_builtin@ -lwxregexu$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
@COND_wxUSE_EXPAT_builtin@__LIB_EXPAT_p = \
@COND_wxUSE_EXPAT_builtin@ -lwxexpat$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
### Targets: ###
all: bench$(EXEEXT) data $(__bench_gui___depname) $(__bench_gui_bundle___depname) $(__bench_graphics___depname) $(__bench_graphics_bundle___depname) data-image
install:
uninstall:
install-strip: install
clean:
rm -rf ./.deps ./.pch
rm -f ./*.o
rm -f bench$(EXEEXT)
rm -f bench_gui$(EXEEXT)
rm -rf bench_gui.app
rm -f bench_graphics$(EXEEXT)
rm -rf bench_graphics.app
distclean: clean
rm -f config.cache config.log config.status bk-deps bk-make-pch Makefile
bench$(EXEEXT): $(BENCH_OBJECTS)
$(CXX) -o $@ $(BENCH_OBJECTS) -L$(LIBDIRNAME) $(DYLIB_RPATH_FLAG) $(LDFLAGS) $(WX_LDFLAGS) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_PNG_IF_MONO_p) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS)
data:
@mkdir -p .
@for f in htmltest.html; do \
if test ! -f ./$$f -a ! -d ./$$f ; \
then x=yep ; \
else x=`find $(srcdir)/$$f -newer ./$$f -print` ; \
fi; \
case "$$x" in ?*) \
cp -pRf $(srcdir)/$$f . ;; \
esac; \
done
@COND_USE_GUI_1@bench_gui$(EXEEXT): $(BENCH_GUI_OBJECTS) $(__bench_gui___win32rc)
@COND_USE_GUI_1@ $(CXX) -o $@ $(BENCH_GUI_OBJECTS) -L$(LIBDIRNAME) $(DYLIB_RPATH_FLAG) $(LDFLAGS) $(WX_LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_LEXILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS)
@COND_PLATFORM_MACOSX_1_USE_GUI_1@bench_gui.app/Contents/PkgInfo: $(__bench_gui___depname) $(top_srcdir)/src/osx/carbon/Info.plist.in $(top_srcdir)/src/osx/carbon/wxmac.icns
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_gui.app/Contents
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_gui.app/Contents/MacOS
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_gui.app/Contents/Resources
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ sed -e "s/\$${MACOSX_BUNDLE_GUI_IDENTIFIER}/org.wxwidgets.bench_gui/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_EXECUTABLE_NAME}/bench_gui/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_BUNDLE_NAME}/bench_gui/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_COPYRIGHT}/Copyright 2002-2025 wxWidgets/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_BUNDLE_VERSION}/$(WX_VERSION)/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_INFO_STRING}/bench_gui version $(WX_VERSION), (c) 2002-2025 wxWidgets/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_LONG_VERSION_STRING}/$(WX_VERSION), (c) 2002-2025 wxWidgets/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_SHORT_VERSION_STRING}/$(WX_RELEASE)/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ $(top_srcdir)/src/osx/carbon/Info.plist.in >bench_gui.app/Contents/Info.plist
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ /bin/echo "APPL????" >bench_gui.app/Contents/PkgInfo
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ ln -f bench_gui$(EXEEXT) bench_gui.app/Contents/MacOS/bench_gui
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ cp -f $(top_srcdir)/src/osx/carbon/wxmac.icns bench_gui.app/Contents/Resources/wxmac.icns
@COND_PLATFORM_MACOSX_1_USE_GUI_1@bench_gui_bundle: $(____bench_gui_BUNDLE_TGT_REF_DEP)
@COND_USE_GUI_1@bench_graphics$(EXEEXT): $(BENCH_GRAPHICS_OBJECTS) $(__bench_graphics___win32rc)
@COND_USE_GUI_1@ $(CXX) -o $@ $(BENCH_GRAPHICS_OBJECTS) -L$(LIBDIRNAME) $(DYLIB_RPATH_FLAG) $(LDFLAGS) $(WX_LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) -lwx_$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl-$(WX_RELEASE)$(HOST_SUFFIX) $(EXTRALIBS_OPENGL) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p_1) $(__LIB_LEXILLA_IF_MONO_p_1) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS)
@COND_PLATFORM_MACOSX_1_USE_GUI_1@bench_graphics.app/Contents/PkgInfo: $(__bench_graphics___depname) $(top_srcdir)/src/osx/carbon/Info.plist.in $(top_srcdir)/src/osx/carbon/wxmac.icns
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_graphics.app/Contents
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_graphics.app/Contents/MacOS
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_graphics.app/Contents/Resources
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ sed -e "s/\$${MACOSX_BUNDLE_GUI_IDENTIFIER}/org.wxwidgets.bench_graphics/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_EXECUTABLE_NAME}/bench_graphics/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_BUNDLE_NAME}/bench_graphics/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_COPYRIGHT}/Copyright 2002-2025 wxWidgets/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_BUNDLE_VERSION}/$(WX_VERSION)/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_INFO_STRING}/bench_graphics version $(WX_VERSION), (c) 2002-2025 wxWidgets/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_LONG_VERSION_STRING}/$(WX_VERSION), (c) 2002-2025 wxWidgets/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_SHORT_VERSION_STRING}/$(WX_RELEASE)/" \
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ $(top_srcdir)/src/osx/carbon/Info.plist.in >bench_graphics.app/Contents/Info.plist
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ /bin/echo "APPL????" >bench_graphics.app/Contents/PkgInfo
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ ln -f bench_graphics$(EXEEXT) bench_graphics.app/Contents/MacOS/bench_graphics
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ cp -f $(top_srcdir)/src/osx/carbon/wxmac.icns bench_graphics.app/Contents/Resources/wxmac.icns
@COND_PLATFORM_MACOSX_1_USE_GUI_1@bench_graphics_bundle: $(____bench_graphics_BUNDLE_TGT_REF_DEP)
data-image:
@mkdir -p .
@for f in ../../samples/image/horse.bmp ../../samples/image/horse.jpg ../../samples/image/horse.png ../../samples/image/horse.tif; do \
if test ! -f ./$$f -a ! -d ./$$f ; \
then x=yep ; \
else x=`find $(srcdir)/$$f -newer ./$$f -print` ; \
fi; \
case "$$x" in ?*) \
cp -pRf $(srcdir)/$$f . ;; \
esac; \
done
bench_bench.o: $(srcdir)/bench.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/bench.cpp
bench_datetime.o: $(srcdir)/datetime.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/datetime.cpp
bench_htmlpars.o: $(srcdir)/htmlparser/htmlpars.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/htmlparser/htmlpars.cpp
bench_htmltag.o: $(srcdir)/htmlparser/htmltag.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/htmlparser/htmltag.cpp
bench_ipcclient.o: $(srcdir)/ipcclient.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/ipcclient.cpp
bench_log.o: $(srcdir)/log.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/log.cpp
bench_mbconv.o: $(srcdir)/mbconv.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/mbconv.cpp
bench_regex.o: $(srcdir)/regex.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/regex.cpp
bench_strings.o: $(srcdir)/strings.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/strings.cpp
bench_tls.o: $(srcdir)/tls.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/tls.cpp
bench_printfbench.o: $(srcdir)/printfbench.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/printfbench.cpp
bench_gui_sample_rc.o: $(srcdir)/../../samples/sample.rc
$(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) --include-dir $(srcdir) $(__DLLFLAG_p_0) $(__WIN32_DPI_MANIFEST_p) --include-dir $(srcdir)/../../samples $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include
bench_gui_bench.o: $(srcdir)/bench.cpp
$(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/bench.cpp
bench_gui_display.o: $(srcdir)/display.cpp
$(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/display.cpp
bench_gui_image.o: $(srcdir)/image.cpp
$(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/image.cpp
bench_graphics_sample_rc.o: $(srcdir)/../../samples/sample.rc
$(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) --include-dir $(srcdir) $(__DLLFLAG_p_0) $(__WIN32_DPI_MANIFEST_p) --include-dir $(srcdir)/../../samples $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include
bench_graphics_graphics.o: $(srcdir)/graphics.cpp
$(CXXC) -c -o $@ $(BENCH_GRAPHICS_CXXFLAGS) $(srcdir)/graphics.cpp
# Include dependency info, if present:
@IF_GNU_MAKE@-include ./.deps/*.d
.PHONY: all install uninstall clean distclean data bench_gui_bundle \
bench_graphics_bundle data-image

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" ?>
<makefile>
<include file="../../build/bakefiles/common_samples.bkl"/>
<template id="wx_bench">
</template>
<exe id="bench" template="wx_sample_console,wx_bench"
template_append="wx_append_base">
<sources>
bench.cpp
datetime.cpp
htmlparser/htmlpars.cpp
htmlparser/htmltag.cpp
ipcclient.cpp
log.cpp
mbconv.cpp
regex.cpp
strings.cpp
tls.cpp
printfbench.cpp
</sources>
<wx-lib>net</wx-lib>
<wx-lib>base</wx-lib>
</exe>
<wx-data id="data">
<files>htmltest.html</files>
</wx-data>
<exe id="bench_gui" template="wx_sample,wx_bench"
template_append="wx_append"
cond="USE_GUI=='1'">
<app-type>console</app-type>
<sources>
bench.cpp
display.cpp
image.cpp
</sources>
<wx-lib>core</wx-lib>
<wx-lib>base</wx-lib>
</exe>
<exe id="bench_graphics" template="wx_sample,wx_bench"
template_append="wx_append"
cond="USE_GUI=='1'">
<app-type>console</app-type>
<sources>
graphics.cpp
</sources>
<wx-lib>core</wx-lib>
<wx-lib>base</wx-lib>
<wx-lib>gl</wx-lib>
</exe>
<wx-data id="data-image">
<files>
../../samples/image/horse.bmp
../../samples/image/horse.jpg
../../samples/image/horse.png
../../samples/image/horse.tif
</files>
</wx-data>
</makefile>

View File

@@ -0,0 +1,389 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/bench.cpp
// Purpose: Main file of the benchmarking suite
// Author: Vadim Zeitlin
// Created: 2008-07-19
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include <float.h>
#include "wx/app.h"
#include "wx/cmdline.h"
#include "wx/stopwatch.h"
#include "wx/uilocale.h"
#if wxUSE_GUI
#include "wx/frame.h"
#endif
#include "bench.h"
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
static const char OPTION_LIST = 'l';
static const char OPTION_SINGLE = '1';
static const char OPTION_RUN_TIME = 't';
static const char OPTION_NUM_RUNS = 'n';
static const char OPTION_NUMERIC_PARAM = 'p';
static const char OPTION_STRING_PARAM = 's';
// ----------------------------------------------------------------------------
// BenchApp declaration
// ----------------------------------------------------------------------------
#if wxUSE_GUI
typedef wxApp BenchAppBase;
#else
typedef wxAppConsole BenchAppBase;
#endif
class BenchApp : public BenchAppBase
{
public:
BenchApp();
// standard overrides
virtual void OnInitCmdLine(wxCmdLineParser& parser);
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
virtual bool OnInit();
virtual int OnRun();
virtual int OnExit();
// accessors
int GetNumericParameter() const { return m_numParam; }
const wxString& GetStringParameter() const { return m_strParam; }
private:
// output the results of a single benchmark if successful or just return
// false if anything went wrong
bool RunSingleBenchmark(Bench::Function* func);
// list all registered benchmarks
void ListBenchmarks();
// command lines options/parameters
wxSortedArrayString m_toRun;
long m_numRuns, // number of times to run a single benchmark or 0
m_runTime, // minimum time to run a single benchmark if m_numRuns == 0
m_numParam;
wxString m_strParam;
};
wxIMPLEMENT_APP_CONSOLE(BenchApp);
// ============================================================================
// Bench namespace symbols implementation
// ============================================================================
Bench::Function *Bench::Function::ms_head = nullptr;
long Bench::GetNumericParameter(long defVal)
{
const long val = wxGetApp().GetNumericParameter();
return val ? val : defVal;
}
wxString Bench::GetStringParameter(const wxString& defVal)
{
const wxString& val = wxGetApp().GetStringParameter();
return !val.empty() ? val : defVal;
}
// ============================================================================
// BenchApp implementation
// ============================================================================
BenchApp::BenchApp()
{
m_numRuns = 0; // this means to use m_runTime
m_runTime = 500; // default minimum
m_numParam = 0;
}
bool BenchApp::OnInit()
{
if ( !BenchAppBase::OnInit() )
return false;
// Some benchmarks are locale-sensitive, so use the current locale.
wxUILocale::UseDefault();
wxPrintf("wxWidgets benchmarking program\n"
"Build: %s\n", WX_BUILD_OPTIONS_SIGNATURE);
#if wxUSE_GUI
// create a hidden parent window to be used as parent for the GUI controls
new wxFrame(nullptr, wxID_ANY, "Hidden wx benchmark frame");
#endif // wxUSE_GUI
return true;
}
void BenchApp::OnInitCmdLine(wxCmdLineParser& parser)
{
BenchAppBase::OnInitCmdLine(parser);
parser.AddSwitch(OPTION_LIST,
"list",
"list all the existing benchmarks");
parser.AddSwitch(OPTION_SINGLE,
"single",
"run the benchmark once only");
parser.AddOption(OPTION_RUN_TIME,
"run-time",
wxString::Format
(
"maximum time to run each benchmark in ms "
"(default: %ld, set to 0 to disable)",
m_runTime
),
wxCMD_LINE_VAL_NUMBER);
parser.AddOption(OPTION_NUM_RUNS,
"num-runs",
wxString::Format
(
"number of times to run each benchmark in a loop "
"(default: %ld, 0 means to run until max time passes)",
m_numRuns
),
wxCMD_LINE_VAL_NUMBER);
parser.AddOption(OPTION_NUMERIC_PARAM,
"num-param",
wxString::Format
(
"numeric parameter used by some benchmark functions "
"(default: %ld)",
m_numParam
),
wxCMD_LINE_VAL_NUMBER);
parser.AddOption(OPTION_STRING_PARAM,
"str-param",
"string parameter used by some benchmark functions "
"(default: empty)",
wxCMD_LINE_VAL_STRING);
parser.AddParam("benchmark name",
wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE);
}
bool BenchApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
if ( parser.Found(OPTION_LIST) )
{
ListBenchmarks();
return false;
}
const size_t count = parser.GetParamCount();
if ( !count )
{
parser.Usage();
ListBenchmarks();
return false;
}
const bool runTimeSpecified = parser.Found(OPTION_RUN_TIME, &m_runTime);
const bool numRunsSpecified = parser.Found(OPTION_NUM_RUNS, &m_numRuns);
parser.Found(OPTION_NUMERIC_PARAM, &m_numParam);
parser.Found(OPTION_STRING_PARAM, &m_strParam);
if ( parser.Found(OPTION_SINGLE) )
{
if ( runTimeSpecified || numRunsSpecified )
{
wxFprintf(stderr, "Incompatible options specified.\n");
return false;
}
m_numRuns = 1;
}
else if ( numRunsSpecified && !runTimeSpecified )
{
// If only the number of runs is specified, use it only.
m_runTime = 0;
}
// construct sorted array for quick verification of benchmark names
wxSortedArrayString benchmarks;
for ( Bench::Function *func = Bench::Function::GetFirst();
func;
func = func->GetNext() )
{
benchmarks.push_back(func->GetName());
}
for ( size_t n = 0; n < count; n++ )
{
const wxString name = parser.GetParam(n);
if ( benchmarks.Index(name) == wxNOT_FOUND )
{
wxFprintf(stderr, "No benchmark named \"%s\".\n", name);
return false;
}
m_toRun.push_back(name);
}
return BenchAppBase::OnCmdLineParsed(parser);
}
int BenchApp::OnRun()
{
int rc = EXIT_SUCCESS;
wxString params;
if ( m_numParam )
params += wxString::Format("N=%ld", m_numParam);
if ( !m_strParam.empty() )
{
if ( !params.empty() )
params += " and ";
params += wxString::Format("s=\"%s\"", m_strParam);
}
if ( !params.empty() )
wxPrintf("Benchmarks are running with non-default %s\n", params);
for ( Bench::Function *func = Bench::Function::GetFirst();
func;
func = func->GetNext() )
{
if ( m_toRun.Index(func->GetName()) == wxNOT_FOUND )
continue;
if ( !RunSingleBenchmark(func) )
{
wxFprintf(stderr, "ERROR running %s\n", func->GetName());
rc = EXIT_FAILURE;
}
}
return rc;
}
bool BenchApp::RunSingleBenchmark(Bench::Function* func)
{
if ( !func->Init() )
return false;
wxPrintf("%-30s", wxString(func->GetName()) + ':');
fflush(stdout);
// We use the algorithm for iteratively computing the mean and the
// standard deviation of the sequence of values described in Knuth's
// "The Art of Computer Programming, Volume 2: Seminumerical
// Algorithms", section 4.2.2.
//
// The algorithm defines the sequences M(k) and S(k) as follows:
//
// M(1) = x(1), M(k) = M(k-1) + (x(k) - M(k-1)) / k
// S(1) = 0, S(k) = S(k-1) + (x(k) - M(k-1))*(x(k) - M(k))
//
// where x(k) is the k-th value. Then the mean is simply the last value
// of the first sequence M(N) and the standard deviation is
// sqrt(S(N)/(N-1)).
wxStopWatch swTotal;
if ( !func->Run() )
return false;
double timeMin = DBL_MAX,
timeMax = 0;
double m = swTotal.TimeInMicro().ToDouble();
double s = 0;
long n = 0;
for ( ;; )
{
// One termination condition is reaching the maximum number of runs.
if ( ++n == m_numRuns )
break;
double t;
{
wxStopWatch swThis;
if ( !func->Run() )
return false;
t = swThis.TimeInMicro().ToDouble();
}
if ( t < timeMin )
timeMin = t;
if ( t > timeMax )
timeMax = t;
const double lastM = m;
m += (t - lastM) / n;
s += (t - lastM)*(t - m);
// The other termination condition is that we are running for at least
// m_runTime milliseconds.
if ( m_runTime && swTotal.Time() >= m_runTime )
break;
}
func->Done();
// For a single run there is no standard deviation and min/max don't make
// much sense.
if ( n == 1 )
{
wxPrintf("single run took %.0fus\n", m);
}
else
{
s = sqrt(s / (n - 1));
wxPrintf
(
"%12ld runs, %.0fus avg, %.0f std dev (%.0f/%.0f min/max)\n",
n, m, s, timeMin, timeMax
);
}
fflush(stdout);
return true;
}
int BenchApp::OnExit()
{
#if wxUSE_GUI
delete GetTopWindow();
#endif // wxUSE_GUI
return 0;
}
/* static */
void BenchApp::ListBenchmarks()
{
wxPrintf("Available benchmarks:\n");
for ( Bench::Function *func = Bench::Function::GetFirst();
func;
func = func->GetNext() )
{
wxPrintf("\t%s\n", func->GetName());
}
}

View File

@@ -0,0 +1,126 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/bench.h
// Purpose: Main header of the benchmarking suite
// Author: Vadim Zeitlin
// Created: 2008-07-19
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TESTS_BENCHMARKS_BENCH_H_
#define _WX_TESTS_BENCHMARKS_BENCH_H_
#include "wx/cpp.h"
#include "wx/crt.h"
#include "wx/defs.h"
namespace Bench
{
/**
Utility object used to register the benchmark functions.
@see BENCHMARK_FUNC
*/
class Function
{
public:
typedef bool (*InitType)();
typedef bool (*FuncType)();
typedef void (*DoneType)();
/// Ctor is used implicitly by BENCHMARK_FUNC().
Function(const char *name,
FuncType func,
InitType init = nullptr,
DoneType done = nullptr)
: m_name(name),
m_func(func),
m_init(init),
m_done(done),
m_next(ms_head)
{
ms_head = this;
}
/// Get the name of this function
const char *GetName() const { return m_name; }
/// Perform once-only initialization prior to Run().
bool Init() { return m_init ? (*m_init)() : true; }
/// Run the function, return its return value.
bool Run() { return (*m_func)(); }
/// Clean up after performing the benchmark.
void Done() { if ( m_done ) (*m_done)(); }
/// Get the head of the linked list of benchmark objects
static Function *GetFirst() { return ms_head; }
/// Get the next object in the linked list or nullptr
Function *GetNext() const { return m_next; }
private:
// the head of the linked list of Bench::Function objects
static Function *ms_head;
// name of and pointer to the function, as passed to the ctor
const char * const m_name;
const FuncType m_func;
const InitType m_init;
const DoneType m_done;
// pointer to the next object in the linked list or nullptr
Function * const m_next;
wxDECLARE_NO_COPY_CLASS(Function);
};
/**
Get the numeric parameter.
Tests may use this parameter in whatever way they see fit, by default it is
1 but can be set to a different value by user from the command line.
*/
long GetNumericParameter(long defValue = 1);
/**
Get the string parameter.
Tests may use this parameter in whatever way they see fit, by default it is
empty but can be set to a different value by user from the command line.
*/
wxString GetStringParameter(const wxString& defValue = wxString());
} // namespace Bench
/**
This macro defines a benchmark function.
All these functions return a boolean value and take no parameters. The
return value is needed to prevent the compiler from optimizing the
benchmark entirely away and so typically will be constructed using the
results of the benchmark actions, even though normally benchmark should
always return true.
Once benchmark is defined, it can be invoked from the command line of the
main benchmarking program.
*/
#define BENCHMARK_FUNC(name) \
static bool name(); \
static Bench::Function wxMAKE_UNIQUE_NAME(name)(#name, name); \
bool name()
/**
Define a benchmark function requiring initialization and shutdown.
This macro is similar to BENCHMARK_FUNC() but ensures that @a init is
called before the benchmark is ran and @a done afterwards.
*/
#define BENCHMARK_FUNC_WITH_INIT(name, init, done) \
static bool name(); \
static Bench::Function wxMAKE_UNIQUE_NAME(name)(#name, name, init, done); \
bool name()
#endif // _WX_TESTS_BENCHMARKS_BENCH_H_

View File

@@ -0,0 +1,19 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/datetime.cpp
// Purpose: wxDateTime benchmarks
// Author: Vadim Zeitlin
// Created: 2011-05-23
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/datetime.h"
#include "bench.h"
BENCHMARK_FUNC(ParseDate)
{
wxDateTime dt;
return dt.ParseDate("May 23, 2011") && dt.GetMonth() == wxDateTime::May;
}

View File

@@ -0,0 +1,30 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/display.cpp
// Purpose: wxDisplay benchmarks
// Author: Vadim Zeitlin
// Created: 2018-09-30
// Copyright: (c) 2018 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/display.h"
#include "wx/gdicmn.h"
#include "bench.h"
BENCHMARK_FUNC(DisplaySize)
{
int w, h;
wxDisplaySize(&w, &h);
return w > 0;
}
BENCHMARK_FUNC(GetDisplaySize)
{
return wxGetDisplaySize().x > 0;
}
BENCHMARK_FUNC(DisplayGetGeometry)
{
return wxDisplay().GetGeometry().GetSize().x > 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
This is a copy of wxWidgets 2.8's wxHTML parser. Unlike the 2.9+ version, it
uses wxString::operator[] during parsing and so is perfect for testing
real-life performance of the new wxString class' operator[] caching.

View File

@@ -0,0 +1,892 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/html/htmlpars.cpp
// Purpose: wx28HtmlParser class (generic parser)
// Author: Vaclav Slavik
// Copyright: (c) 1999 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#include "htmlpars.h"
#ifndef WXPRECOMP
#include "wx/dynarray.h"
#include "wx/log.h"
#include "wx/intl.h"
#include "wx/app.h"
#endif
#include "wx/crt.h"
#include "wx/tokenzr.h"
#include "wx/wfstream.h"
#include "wx/url.h"
#include "wx/fontmap.h"
#include "wx/html/htmldefs.h"
#include "wx/arrimpl.cpp"
// DLL options compatibility check:
WX_CHECK_BUILD_OPTIONS("wxHTML")
const wxChar *wxTRACE_HTML_DEBUG = wxT("htmldebug");
//-----------------------------------------------------------------------------
// wx28HtmlParser helpers
//-----------------------------------------------------------------------------
class wx28HtmlTextPiece
{
public:
wx28HtmlTextPiece(int pos, int lng) : m_pos(pos), m_lng(lng) {}
int m_pos, m_lng;
};
WX_DECLARE_OBJARRAY(wx28HtmlTextPiece, wx28HtmlTextPieces);
WX_DEFINE_OBJARRAY(wx28HtmlTextPieces)
class wx28HtmlParserState
{
public:
wx28HtmlTag *m_curTag;
wx28HtmlTag *m_tags;
wx28HtmlTextPieces *m_textPieces;
int m_curTextPiece;
wxString m_source;
wx28HtmlParserState *m_nextState;
};
//-----------------------------------------------------------------------------
// wx28HtmlParser
//-----------------------------------------------------------------------------
wxIMPLEMENT_ABSTRACT_CLASS(wx28HtmlParser, wxObject);
wx28HtmlParser::wx28HtmlParser()
: wxObject(), m_HandlersHash(wxKEY_STRING),
m_FS(nullptr), m_HandlersStack(nullptr)
{
m_entitiesParser = new wx28HtmlEntitiesParser;
m_Tags = nullptr;
m_CurTag = nullptr;
m_TextPieces = nullptr;
m_CurTextPiece = 0;
m_SavedStates = nullptr;
}
wx28HtmlParser::~wx28HtmlParser()
{
while (RestoreState()) {}
DestroyDOMTree();
if (m_HandlersStack)
{
wxList& tmp = *m_HandlersStack;
wxList::iterator it, en;
for( it = tmp.begin(), en = tmp.end(); it != en; ++it )
delete (wxHashTable*)*it;
tmp.clear();
}
delete m_HandlersStack;
m_HandlersHash.Clear();
wxClearList(m_HandlersList);
delete m_entitiesParser;
}
wxObject* wx28HtmlParser::Parse(const wxString& source)
{
InitParser(source);
DoParsing();
wxObject *result = GetProduct();
DoneParser();
return result;
}
void wx28HtmlParser::InitParser(const wxString& source)
{
SetSource(source);
m_stopParsing = false;
}
void wx28HtmlParser::DoneParser()
{
DestroyDOMTree();
}
void wx28HtmlParser::SetSource(const wxString& src)
{
DestroyDOMTree();
m_Source = src;
CreateDOMTree();
m_CurTag = nullptr;
m_CurTextPiece = 0;
}
void wx28HtmlParser::CreateDOMTree()
{
wx28HtmlTagsCache cache(m_Source);
m_TextPieces = new wx28HtmlTextPieces;
CreateDOMSubTree(nullptr, 0, m_Source.length(), &cache);
m_CurTextPiece = 0;
}
extern bool wxIsCDATAElement(const wxChar *tag);
void wx28HtmlParser::CreateDOMSubTree(wx28HtmlTag *cur,
int begin_pos, int end_pos,
wx28HtmlTagsCache *cache)
{
if (end_pos <= begin_pos) return;
wxChar c;
int i = begin_pos;
int textBeginning = begin_pos;
// If the tag contains CDATA text, we include the text between beginning
// and ending tag verbosely. Setting i=end_pos will skip to the very
// end of this function where text piece is added, bypassing any child
// tags parsing (CDATA element can't have child elements by definition):
if (cur != nullptr && wxIsCDATAElement(cur->GetName().c_str()))
{
i = end_pos;
}
while (i < end_pos)
{
c = m_Source.GetChar(i);
if (c == wxT('<'))
{
// add text to m_TextPieces:
if (i - textBeginning > 0)
m_TextPieces->Add(
wx28HtmlTextPiece(textBeginning, i - textBeginning));
// if it is a comment, skip it:
if (i < end_pos-6 && m_Source.GetChar(i+1) == wxT('!') &&
m_Source.GetChar(i+2) == wxT('-') &&
m_Source.GetChar(i+3) == wxT('-'))
{
// Comments begin with "<!--" and end with "--[ \t\r\n]*>"
// according to HTML 4.0
int dashes = 0;
i += 4;
while (i < end_pos)
{
c = m_Source.GetChar(i++);
if ((c == wxT(' ') || c == wxT('\n') ||
c == wxT('\r') || c == wxT('\t')) && dashes >= 2) {}
else if (c == wxT('>') && dashes >= 2)
{
textBeginning = i;
break;
}
else if (c == wxT('-'))
dashes++;
else
dashes = 0;
}
}
// add another tag to the tree:
else if (i < end_pos-1 && m_Source.GetChar(i+1) != wxT('/'))
{
wx28HtmlTag *chd;
if (cur)
chd = new wx28HtmlTag(cur, m_Source,
i, end_pos, cache, m_entitiesParser);
else
{
chd = new wx28HtmlTag(nullptr, m_Source,
i, end_pos, cache, m_entitiesParser);
if (!m_Tags)
{
// if this is the first tag to be created make the root
// m_Tags point to it:
m_Tags = chd;
}
else
{
// if there is already a root tag add this tag as
// the last sibling:
chd->m_Prev = m_Tags->GetLastSibling();
chd->m_Prev->m_Next = chd;
}
}
if (chd->HasEnding())
{
CreateDOMSubTree(chd,
chd->GetBeginPos(), chd->GetEndPos1(),
cache);
i = chd->GetEndPos2();
}
else
i = chd->GetBeginPos();
textBeginning = i;
}
// ... or skip ending tag:
else
{
while (i < end_pos && m_Source.GetChar(i) != wxT('>')) i++;
textBeginning = i+1;
}
}
else i++;
}
// add remaining text to m_TextPieces:
if (end_pos - textBeginning > 0)
m_TextPieces->Add(
wx28HtmlTextPiece(textBeginning, end_pos - textBeginning));
}
void wx28HtmlParser::DestroyDOMTree()
{
wx28HtmlTag *t1, *t2;
t1 = m_Tags;
while (t1)
{
t2 = t1->GetNextSibling();
delete t1;
t1 = t2;
}
m_Tags = m_CurTag = nullptr;
delete m_TextPieces;
m_TextPieces = nullptr;
}
void wx28HtmlParser::DoParsing()
{
m_CurTag = m_Tags;
m_CurTextPiece = 0;
DoParsing(0, m_Source.length());
}
void wx28HtmlParser::DoParsing(int begin_pos, int end_pos)
{
if (end_pos <= begin_pos) return;
wx28HtmlTextPieces& pieces = *m_TextPieces;
size_t piecesCnt = pieces.GetCount();
while (begin_pos < end_pos)
{
while (m_CurTag && m_CurTag->GetBeginPos() < begin_pos)
m_CurTag = m_CurTag->GetNextTag();
while (m_CurTextPiece < piecesCnt &&
pieces[m_CurTextPiece].m_pos < begin_pos)
m_CurTextPiece++;
if (m_CurTextPiece < piecesCnt &&
(!m_CurTag ||
pieces[m_CurTextPiece].m_pos < m_CurTag->GetBeginPos()))
{
// Add text:
AddText(GetEntitiesParser()->Parse(
m_Source.Mid(pieces[m_CurTextPiece].m_pos,
pieces[m_CurTextPiece].m_lng)).t_str());
begin_pos = pieces[m_CurTextPiece].m_pos +
pieces[m_CurTextPiece].m_lng;
m_CurTextPiece++;
}
else if (m_CurTag)
{
if (m_CurTag->HasEnding())
begin_pos = m_CurTag->GetEndPos2();
else
begin_pos = m_CurTag->GetBeginPos();
wx28HtmlTag *t = m_CurTag;
m_CurTag = m_CurTag->GetNextTag();
AddTag(*t);
if (m_stopParsing)
return;
}
else break;
}
}
void wx28HtmlParser::AddTag(const wx28HtmlTag& tag)
{
wx28HtmlTagHandler *h;
bool inner = false;
h = (wx28HtmlTagHandler*) m_HandlersHash.Get(tag.GetName());
if (h)
{
inner = h->HandleTag(tag);
if (m_stopParsing)
return;
}
if (!inner)
{
if (tag.HasEnding())
DoParsing(tag.GetBeginPos(), tag.GetEndPos1());
}
}
void wx28HtmlParser::AddTagHandler(wx28HtmlTagHandler *handler)
{
wxString s(handler->GetSupportedTags());
wxStringTokenizer tokenizer(s, wxT(", "));
while (tokenizer.HasMoreTokens())
m_HandlersHash.Put(tokenizer.GetNextToken(), handler);
if (m_HandlersList.IndexOf(handler) == wxNOT_FOUND)
m_HandlersList.Append(handler);
handler->SetParser(this);
}
void wx28HtmlParser::PushTagHandler(wx28HtmlTagHandler *handler, const wxString& tags)
{
wxStringTokenizer tokenizer(tags, wxT(", "));
wxString key;
if (m_HandlersStack == nullptr)
{
m_HandlersStack = new wxList;
}
m_HandlersStack->Insert((wxObject*)new wxHashTable(m_HandlersHash));
while (tokenizer.HasMoreTokens())
{
key = tokenizer.GetNextToken();
m_HandlersHash.Delete(key);
m_HandlersHash.Put(key, handler);
}
}
void wx28HtmlParser::PopTagHandler()
{
wxList::compatibility_iterator first;
if ( !m_HandlersStack ||
!(first = m_HandlersStack->GetFirst()) )
{
wxLogWarning(_("Warning: attempt to remove HTML tag handler from empty stack."));
return;
}
m_HandlersHash = *((wxHashTable*) first->GetData());
delete (wxHashTable*) first->GetData();
m_HandlersStack->Erase(first);
}
void wx28HtmlParser::SetSourceAndSaveState(const wxString& src)
{
wx28HtmlParserState *s = new wx28HtmlParserState;
s->m_curTag = m_CurTag;
s->m_tags = m_Tags;
s->m_textPieces = m_TextPieces;
s->m_curTextPiece = m_CurTextPiece;
s->m_source = m_Source;
s->m_nextState = m_SavedStates;
m_SavedStates = s;
m_CurTag = nullptr;
m_Tags = nullptr;
m_TextPieces = nullptr;
m_CurTextPiece = 0;
m_Source = wxEmptyString;
SetSource(src);
}
bool wx28HtmlParser::RestoreState()
{
if (!m_SavedStates) return false;
DestroyDOMTree();
wx28HtmlParserState *s = m_SavedStates;
m_SavedStates = s->m_nextState;
m_CurTag = s->m_curTag;
m_Tags = s->m_tags;
m_TextPieces = s->m_textPieces;
m_CurTextPiece = s->m_curTextPiece;
m_Source = s->m_source;
delete s;
return true;
}
wxString wx28HtmlParser::GetInnerSource(const wx28HtmlTag& tag)
{
return GetSource()->Mid(tag.GetBeginPos(),
tag.GetEndPos1() - tag.GetBeginPos());
}
//-----------------------------------------------------------------------------
// wx28HtmlTagHandler
//-----------------------------------------------------------------------------
wxIMPLEMENT_ABSTRACT_CLASS(wx28HtmlTagHandler, wxObject);
void wx28HtmlTagHandler::ParseInnerSource(const wxString& source)
{
// It is safe to temporarily change the source being parsed,
// provided we restore the state back after parsing
m_Parser->SetSourceAndSaveState(source);
m_Parser->DoParsing();
m_Parser->RestoreState();
}
//-----------------------------------------------------------------------------
// wx28HtmlEntitiesParser
//-----------------------------------------------------------------------------
wxIMPLEMENT_DYNAMIC_CLASS(wx28HtmlEntitiesParser,wxObject);
wx28HtmlEntitiesParser::wx28HtmlEntitiesParser()
{
}
wx28HtmlEntitiesParser::~wx28HtmlEntitiesParser()
{
}
void wx28HtmlEntitiesParser::SetEncoding(wxFontEncoding encoding)
{
(void) encoding;
}
wxString wx28HtmlEntitiesParser::Parse(const wxString& input)
{
const wxChar *c, *last;
const wxChar *in_str = input.c_str();
wxString output;
for (c = in_str, last = in_str; *c != wxT('\0'); c++)
{
if (*c == wxT('&'))
{
if ( output.empty() )
output.reserve(input.length());
if (c - last > 0)
output.append(last, c - last);
if ( *++c == wxT('\0') )
break;
wxString entity;
const wxChar *ent_s = c;
wxChar entity_char;
for (; (*c >= wxT('a') && *c <= wxT('z')) ||
(*c >= wxT('A') && *c <= wxT('Z')) ||
(*c >= wxT('0') && *c <= wxT('9')) ||
*c == wxT('_') || *c == wxT('#'); c++) {}
entity.append(ent_s, c - ent_s);
if (*c != wxT(';')) c--;
last = c+1;
entity_char = GetEntityChar(entity);
if (entity_char)
output << entity_char;
else
{
output.append(ent_s-1, c-ent_s+2);
wxLogTrace(wxTRACE_HTML_DEBUG,
wxT("Unrecognized HTML entity: '%s'"),
entity.c_str());
}
}
}
if (last == in_str) // common case: no entity
return input;
if (*last != wxT('\0'))
output.append(last);
return output;
}
struct wx28HtmlEntityInfo
{
const wxChar *name;
unsigned code;
};
extern "C" int LINKAGEMODE wx28HtmlEntityCompare(const void *key, const void *item)
{
return wxStrcmp((wxChar*)key, ((wx28HtmlEntityInfo*)item)->name);
}
wxChar wx28HtmlEntitiesParser::GetEntityChar(const wxString& entity)
{
unsigned code = 0;
if (entity[0] == wxT('#'))
{
const wxChar *ent_s = entity.c_str();
const wxChar *format;
if (ent_s[1] == wxT('x') || ent_s[1] == wxT('X'))
{
format = wxT("%x");
ent_s++;
}
else
format = wxT("%u");
ent_s++;
if (wxSscanf(ent_s, format, &code) != 1)
code = 0;
}
else
{
static wx28HtmlEntityInfo substitutions[] = {
{ wxT("AElig"),198 },
{ wxT("Aacute"),193 },
{ wxT("Acirc"),194 },
{ wxT("Agrave"),192 },
{ wxT("Alpha"),913 },
{ wxT("Aring"),197 },
{ wxT("Atilde"),195 },
{ wxT("Auml"),196 },
{ wxT("Beta"),914 },
{ wxT("Ccedil"),199 },
{ wxT("Chi"),935 },
{ wxT("Dagger"),8225 },
{ wxT("Delta"),916 },
{ wxT("ETH"),208 },
{ wxT("Eacute"),201 },
{ wxT("Ecirc"),202 },
{ wxT("Egrave"),200 },
{ wxT("Epsilon"),917 },
{ wxT("Eta"),919 },
{ wxT("Euml"),203 },
{ wxT("Gamma"),915 },
{ wxT("Iacute"),205 },
{ wxT("Icirc"),206 },
{ wxT("Igrave"),204 },
{ wxT("Iota"),921 },
{ wxT("Iuml"),207 },
{ wxT("Kappa"),922 },
{ wxT("Lambda"),923 },
{ wxT("Mu"),924 },
{ wxT("Ntilde"),209 },
{ wxT("Nu"),925 },
{ wxT("OElig"),338 },
{ wxT("Oacute"),211 },
{ wxT("Ocirc"),212 },
{ wxT("Ograve"),210 },
{ wxT("Omega"),937 },
{ wxT("Omicron"),927 },
{ wxT("Oslash"),216 },
{ wxT("Otilde"),213 },
{ wxT("Ouml"),214 },
{ wxT("Phi"),934 },
{ wxT("Pi"),928 },
{ wxT("Prime"),8243 },
{ wxT("Psi"),936 },
{ wxT("Rho"),929 },
{ wxT("Scaron"),352 },
{ wxT("Sigma"),931 },
{ wxT("THORN"),222 },
{ wxT("Tau"),932 },
{ wxT("Theta"),920 },
{ wxT("Uacute"),218 },
{ wxT("Ucirc"),219 },
{ wxT("Ugrave"),217 },
{ wxT("Upsilon"),933 },
{ wxT("Uuml"),220 },
{ wxT("Xi"),926 },
{ wxT("Yacute"),221 },
{ wxT("Yuml"),376 },
{ wxT("Zeta"),918 },
{ wxT("aacute"),225 },
{ wxT("acirc"),226 },
{ wxT("acute"),180 },
{ wxT("aelig"),230 },
{ wxT("agrave"),224 },
{ wxT("alefsym"),8501 },
{ wxT("alpha"),945 },
{ wxT("amp"),38 },
{ wxT("and"),8743 },
{ wxT("ang"),8736 },
{ wxT("aring"),229 },
{ wxT("asymp"),8776 },
{ wxT("atilde"),227 },
{ wxT("auml"),228 },
{ wxT("bdquo"),8222 },
{ wxT("beta"),946 },
{ wxT("brvbar"),166 },
{ wxT("bull"),8226 },
{ wxT("cap"),8745 },
{ wxT("ccedil"),231 },
{ wxT("cedil"),184 },
{ wxT("cent"),162 },
{ wxT("chi"),967 },
{ wxT("circ"),710 },
{ wxT("clubs"),9827 },
{ wxT("cong"),8773 },
{ wxT("copy"),169 },
{ wxT("crarr"),8629 },
{ wxT("cup"),8746 },
{ wxT("curren"),164 },
{ wxT("dArr"),8659 },
{ wxT("dagger"),8224 },
{ wxT("darr"),8595 },
{ wxT("deg"),176 },
{ wxT("delta"),948 },
{ wxT("diams"),9830 },
{ wxT("divide"),247 },
{ wxT("eacute"),233 },
{ wxT("ecirc"),234 },
{ wxT("egrave"),232 },
{ wxT("empty"),8709 },
{ wxT("emsp"),8195 },
{ wxT("ensp"),8194 },
{ wxT("epsilon"),949 },
{ wxT("equiv"),8801 },
{ wxT("eta"),951 },
{ wxT("eth"),240 },
{ wxT("euml"),235 },
{ wxT("euro"),8364 },
{ wxT("exist"),8707 },
{ wxT("fnof"),402 },
{ wxT("forall"),8704 },
{ wxT("frac12"),189 },
{ wxT("frac14"),188 },
{ wxT("frac34"),190 },
{ wxT("frasl"),8260 },
{ wxT("gamma"),947 },
{ wxT("ge"),8805 },
{ wxT("gt"),62 },
{ wxT("hArr"),8660 },
{ wxT("harr"),8596 },
{ wxT("hearts"),9829 },
{ wxT("hellip"),8230 },
{ wxT("iacute"),237 },
{ wxT("icirc"),238 },
{ wxT("iexcl"),161 },
{ wxT("igrave"),236 },
{ wxT("image"),8465 },
{ wxT("infin"),8734 },
{ wxT("int"),8747 },
{ wxT("iota"),953 },
{ wxT("iquest"),191 },
{ wxT("isin"),8712 },
{ wxT("iuml"),239 },
{ wxT("kappa"),954 },
{ wxT("lArr"),8656 },
{ wxT("lambda"),955 },
{ wxT("lang"),9001 },
{ wxT("laquo"),171 },
{ wxT("larr"),8592 },
{ wxT("lceil"),8968 },
{ wxT("ldquo"),8220 },
{ wxT("le"),8804 },
{ wxT("lfloor"),8970 },
{ wxT("lowast"),8727 },
{ wxT("loz"),9674 },
{ wxT("lrm"),8206 },
{ wxT("lsaquo"),8249 },
{ wxT("lsquo"),8216 },
{ wxT("lt"),60 },
{ wxT("macr"),175 },
{ wxT("mdash"),8212 },
{ wxT("micro"),181 },
{ wxT("middot"),183 },
{ wxT("minus"),8722 },
{ wxT("mu"),956 },
{ wxT("nabla"),8711 },
{ wxT("nbsp"),160 },
{ wxT("ndash"),8211 },
{ wxT("ne"),8800 },
{ wxT("ni"),8715 },
{ wxT("not"),172 },
{ wxT("notin"),8713 },
{ wxT("nsub"),8836 },
{ wxT("ntilde"),241 },
{ wxT("nu"),957 },
{ wxT("oacute"),243 },
{ wxT("ocirc"),244 },
{ wxT("oelig"),339 },
{ wxT("ograve"),242 },
{ wxT("oline"),8254 },
{ wxT("omega"),969 },
{ wxT("omicron"),959 },
{ wxT("oplus"),8853 },
{ wxT("or"),8744 },
{ wxT("ordf"),170 },
{ wxT("ordm"),186 },
{ wxT("oslash"),248 },
{ wxT("otilde"),245 },
{ wxT("otimes"),8855 },
{ wxT("ouml"),246 },
{ wxT("para"),182 },
{ wxT("part"),8706 },
{ wxT("permil"),8240 },
{ wxT("perp"),8869 },
{ wxT("phi"),966 },
{ wxT("pi"),960 },
{ wxT("piv"),982 },
{ wxT("plusmn"),177 },
{ wxT("pound"),163 },
{ wxT("prime"),8242 },
{ wxT("prod"),8719 },
{ wxT("prop"),8733 },
{ wxT("psi"),968 },
{ wxT("quot"),34 },
{ wxT("rArr"),8658 },
{ wxT("radic"),8730 },
{ wxT("rang"),9002 },
{ wxT("raquo"),187 },
{ wxT("rarr"),8594 },
{ wxT("rceil"),8969 },
{ wxT("rdquo"),8221 },
{ wxT("real"),8476 },
{ wxT("reg"),174 },
{ wxT("rfloor"),8971 },
{ wxT("rho"),961 },
{ wxT("rlm"),8207 },
{ wxT("rsaquo"),8250 },
{ wxT("rsquo"),8217 },
{ wxT("sbquo"),8218 },
{ wxT("scaron"),353 },
{ wxT("sdot"),8901 },
{ wxT("sect"),167 },
{ wxT("shy"),173 },
{ wxT("sigma"),963 },
{ wxT("sigmaf"),962 },
{ wxT("sim"),8764 },
{ wxT("spades"),9824 },
{ wxT("sub"),8834 },
{ wxT("sube"),8838 },
{ wxT("sum"),8721 },
{ wxT("sup"),8835 },
{ wxT("sup1"),185 },
{ wxT("sup2"),178 },
{ wxT("sup3"),179 },
{ wxT("supe"),8839 },
{ wxT("szlig"),223 },
{ wxT("tau"),964 },
{ wxT("there4"),8756 },
{ wxT("theta"),952 },
{ wxT("thetasym"),977 },
{ wxT("thinsp"),8201 },
{ wxT("thorn"),254 },
{ wxT("tilde"),732 },
{ wxT("times"),215 },
{ wxT("trade"),8482 },
{ wxT("uArr"),8657 },
{ wxT("uacute"),250 },
{ wxT("uarr"),8593 },
{ wxT("ucirc"),251 },
{ wxT("ugrave"),249 },
{ wxT("uml"),168 },
{ wxT("upsih"),978 },
{ wxT("upsilon"),965 },
{ wxT("uuml"),252 },
{ wxT("weierp"),8472 },
{ wxT("xi"),958 },
{ wxT("yacute"),253 },
{ wxT("yen"),165 },
{ wxT("yuml"),255 },
{ wxT("zeta"),950 },
{ wxT("zwj"),8205 },
{ wxT("zwnj"),8204 },
{nullptr, 0}};
static size_t substitutions_cnt = 0;
if (substitutions_cnt == 0)
while (substitutions[substitutions_cnt].code != 0)
substitutions_cnt++;
wx28HtmlEntityInfo *info = nullptr;
info = (wx28HtmlEntityInfo*) bsearch(entity.c_str(), substitutions,
substitutions_cnt,
sizeof(wx28HtmlEntityInfo),
wx28HtmlEntityCompare);
if (info)
code = info->code;
}
if (code == 0)
return 0;
else
return GetCharForCode(code);
}
wxFSFile *wx28HtmlParser::OpenURL(wx28HtmlURLType WXUNUSED(type),
const wxString& url) const
{
return m_FS ? m_FS->OpenFile(url) : nullptr;
}
//-----------------------------------------------------------------------------
// wx28HtmlParser::ExtractCharsetInformation
//-----------------------------------------------------------------------------
class wxMetaTagParser : public wx28HtmlParser
{
public:
wxMetaTagParser() { }
wxObject* GetProduct() { return nullptr; }
protected:
virtual void AddText(const wxChar* WXUNUSED(txt)) {}
wxDECLARE_NO_COPY_CLASS(wxMetaTagParser);
};
class wxMetaTagHandler : public wx28HtmlTagHandler
{
public:
wxMetaTagHandler(wxString *retval) : wx28HtmlTagHandler(), m_retval(retval) {}
wxString GetSupportedTags() { return wxT("META,BODY"); }
bool HandleTag(const wx28HtmlTag& tag);
private:
wxString *m_retval;
wxDECLARE_NO_COPY_CLASS(wxMetaTagHandler);
};
bool wxMetaTagHandler::HandleTag(const wx28HtmlTag& tag)
{
if (tag.GetName() == wxT("BODY"))
{
m_Parser->StopParsing();
return false;
}
if (tag.HasParam(wxT("HTTP-EQUIV")) &&
tag.GetParam(wxT("HTTP-EQUIV")).IsSameAs(wxT("Content-Type"), false) &&
tag.HasParam(wxT("CONTENT")))
{
wxString content = tag.GetParam(wxT("CONTENT")).Lower();
if (content.Left(19) == wxT("text/html; charset="))
{
*m_retval = content.Mid(19);
m_Parser->StopParsing();
}
}
return false;
}
/*static*/
wxString wx28HtmlParser::ExtractCharsetInformation(const wxString& markup)
{
wxString charset;
wxMetaTagParser *parser = new wxMetaTagParser();
if(parser)
{
parser->AddTagHandler(new wxMetaTagHandler(&charset));
parser->Parse(markup);
delete parser;
}
return charset;
}

View File

@@ -0,0 +1,270 @@
/////////////////////////////////////////////////////////////////////////////
// Name: htmlpars.h
// Purpose: wx28HtmlParser class (generic parser)
// Author: Vaclav Slavik
// Copyright: (c) 1999 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_HTMLPARS_H_
#define _WX_HTMLPARS_H_
#include "wx/defs.h"
#include "wx/filesys.h"
#include "wx/hash.h"
#include "wx/fontenc.h"
#include "htmltag.h"
class wxMBConv;
class wx28HtmlParser;
class wx28HtmlTagHandler;
class wx28HtmlEntitiesParser;
class wx28HtmlTextPieces;
class wx28HtmlParserState;
enum wx28HtmlURLType
{
wxHTML_URL_PAGE,
wxHTML_URL_IMAGE,
wxHTML_URL_OTHER
};
// This class handles generic parsing of HTML document : it scans
// the document and divides it into blocks of tags (where one block
// consists of starting and ending tag and of text between these
// 2 tags.
class wx28HtmlParser : public wxObject
{
wxDECLARE_ABSTRACT_CLASS(wx28HtmlParser);
public:
wx28HtmlParser();
virtual ~wx28HtmlParser();
// Sets the class which will be used for opening files
void SetFS(wxFileSystem *fs) { m_FS = fs; }
wxFileSystem* GetFS() const { return m_FS; }
// Opens file if the parser is allowed to open given URL (may be forbidden
// for security reasons)
virtual wxFSFile *OpenURL(wx28HtmlURLType type, const wxString& url) const;
// You can simply call this method when you need parsed output.
// This method does these things:
// 1. call InitParser(source);
// 2. call DoParsing();
// 3. call GetProduct(); (its return value is then returned)
// 4. call DoneParser();
wxObject* Parse(const wxString& source);
// Sets the source. This must be called before running Parse() method.
virtual void InitParser(const wxString& source);
// This must be called after Parse().
virtual void DoneParser();
// May be called during parsing to immediately return from Parse().
virtual void StopParsing() { m_stopParsing = true; }
// Parses the m_Source from begin_pos to end_pos-1.
// (in noparams version it parses whole m_Source)
void DoParsing(int begin_pos, int end_pos);
void DoParsing();
// Returns pointer to the tag at parser's current position
wx28HtmlTag *GetCurrentTag() const { return m_CurTag; }
// Returns product of parsing
// Returned value is result of parsing of the part. The type of this result
// depends on internal representation in derived parser
// (see wx28HtmlWinParser for details).
virtual wxObject* GetProduct() = 0;
// adds handler to the list & hash table of handlers.
virtual void AddTagHandler(wx28HtmlTagHandler *handler);
// Forces the handler to handle additional tags (not returned by GetSupportedTags).
// The handler should already be in use by this parser.
// Example: you want to parse following pseudo-html structure:
// <myitems>
// <it name="one" value="1">
// <it name="two" value="2">
// </myitems>
// <it> This last it has different meaning, we don't want it to be parsed by myitems handler!
// handler can handle only 'myitems' (e.g. its GetSupportedTags returns "MYITEMS")
// you can call PushTagHandler(handler, "IT") when you find <myitems>
// and call PopTagHandler() when you find </myitems>
void PushTagHandler(wx28HtmlTagHandler *handler, const wxString& tags);
// Restores state before last call to PushTagHandler
void PopTagHandler();
wxString* GetSource() {return &m_Source;}
void SetSource(const wxString& src);
// Sets HTML source and remembers current parser's state so that it can
// later be restored. This is useful for on-line modifications of
// HTML source (for example, <pre> handler replaces spaces with &nbsp;
// and newlines with <br>)
virtual void SetSourceAndSaveState(const wxString& src);
// Restores parser's state from stack or returns false if the stack is
// empty
virtual bool RestoreState();
// Returns HTML source inside the element (i.e. between the starting
// and ending tag)
wxString GetInnerSource(const wx28HtmlTag& tag);
// Parses HTML string 'markup' and extracts charset info from <meta> tag
// if present. Returns empty string if the tag is missing.
// For wxHTML's internal use.
static wxString ExtractCharsetInformation(const wxString& markup);
// Returns entity parser object, used to substitute HTML &entities;
wx28HtmlEntitiesParser *GetEntitiesParser() const { return m_entitiesParser; }
protected:
// DOM structure
void CreateDOMTree();
void DestroyDOMTree();
void CreateDOMSubTree(wx28HtmlTag *cur,
int begin_pos, int end_pos,
wx28HtmlTagsCache *cache);
// Adds text to the output.
// This is called from Parse() and must be overridden in derived classes.
// txt is not guaranteed to be only one word. It is largest continuous part of text
// (= not broken by tags)
// NOTE : using char* because of speed improvements
virtual void AddText(const wxChar* txt) = 0;
// Adds tag and proceeds it. Parse() may (and usually is) called from this method.
// This is called from Parse() and may be overridden.
// Default behaviour is that it looks for proper handler in m_Handlers. The tag is
// ignored if no hander is found.
// Derived class is *responsible* for filling in m_Handlers table.
virtual void AddTag(const wx28HtmlTag& tag);
protected:
// DOM tree:
wx28HtmlTag *m_CurTag;
wx28HtmlTag *m_Tags;
wx28HtmlTextPieces *m_TextPieces;
size_t m_CurTextPiece;
wxString m_Source;
wx28HtmlParserState *m_SavedStates;
// handlers that handle particular tags. The table is accessed by
// key = tag's name.
// This attribute MUST be filled by derived class otherwise it would
// be empty and no tags would be recognized
// (see wx28HtmlWinParser for details about filling it)
// m_HandlersHash is for random access based on knowledge of tag name (BR, P, etc.)
// it may (and often does) contain more references to one object
// m_HandlersList is list of all handlers and it is guaranteed to contain
// only one reference to each handler instance.
wxList m_HandlersList;
wxHashTable m_HandlersHash;
wxDECLARE_NO_COPY_CLASS(wx28HtmlParser);
// class for opening files (file system)
wxFileSystem *m_FS;
// handlers stack used by PushTagHandler and PopTagHandler
wxList *m_HandlersStack;
// entity parse
wx28HtmlEntitiesParser *m_entitiesParser;
// flag indicating that the parser should stop
bool m_stopParsing;
};
// This class (and derived classes) cooperates with wx28HtmlParser.
// Each recognized tag is passed to handler which is capable
// of handling it. Each tag is handled in 3 steps:
// 1. Handler will modifies state of parser
// (using its public methods)
// 2. Parser parses source between starting and ending tag
// 3. Handler restores original state of the parser
class wx28HtmlTagHandler : public wxObject
{
wxDECLARE_ABSTRACT_CLASS(wx28HtmlTagHandler);
public:
wx28HtmlTagHandler() : wxObject () { m_Parser = nullptr; }
// Sets the parser.
// NOTE : each _instance_ of handler is guaranteed to be called
// only by one parser. This means you don't have to care about
// reentrancy.
virtual void SetParser(wx28HtmlParser *parser)
{ m_Parser = parser; }
// Returns list of supported tags. The list is in uppercase and
// tags are delimited by ','.
// Example : "I,B,FONT,P"
// is capable of handling italic, bold, font and paragraph tags
virtual wxString GetSupportedTags() = 0;
// This is hadling core method. It does all the Steps 1-3.
// To process step 2, you can call ParseInner()
// returned value : true if it called ParseInner(),
// false etherwise
virtual bool HandleTag(const wx28HtmlTag& tag) = 0;
protected:
// parses input between beginning and ending tag.
// m_Parser must be set.
void ParseInner(const wx28HtmlTag& tag)
{ m_Parser->DoParsing(tag.GetBeginPos(), tag.GetEndPos1()); }
// Parses given source as if it was tag's inner code (see
// wx28HtmlParser::GetInnerSource). Unlike ParseInner(), this method lets
// you specify the source code to parse. This is useful when you need to
// modify the inner text before parsing.
void ParseInnerSource(const wxString& source);
wx28HtmlParser *m_Parser;
wxDECLARE_NO_COPY_CLASS(wx28HtmlTagHandler);
};
// This class is used to parse HTML entities in strings. It can handle
// both named entities and &#xxxx entries where xxxx is Unicode code.
class wx28HtmlEntitiesParser : public wxObject
{
wxDECLARE_DYNAMIC_CLASS(wx28HtmlEntitiesParser);
public:
wx28HtmlEntitiesParser();
virtual ~wx28HtmlEntitiesParser();
// Sets encoding of output string.
// Has no effect any more.
void SetEncoding(wxFontEncoding encoding);
// Parses entities in input and replaces them with respective characters
// (with respect to output encoding)
wxString Parse(const wxString& input);
// Returns character for given entity or 0 if the enity is unknown
wxChar GetEntityChar(const wxString& entity);
// Returns character that represents given Unicode code
wxChar GetCharForCode(unsigned code) { return (wxChar)code; }
protected:
wxDECLARE_NO_COPY_CLASS(wx28HtmlEntitiesParser);
};
#endif // _WX_HTMLPARS_H_

View File

@@ -0,0 +1,467 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/html/htmltag.cpp
// Purpose: wx28HtmlTag class (represents single tag)
// Author: Vaclav Slavik
// Copyright: (c) 1999 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#include "htmltag.h"
#include "htmlpars.h"
#include "wx/crt.h"
//-----------------------------------------------------------------------------
// wx28HtmlTagsCache
//-----------------------------------------------------------------------------
struct wx28HtmlCacheItem
{
// this is "pos" value passed to wx28HtmlTag's constructor.
// it is position of '<' character of the tag
int Key;
// end positions for the tag:
// end1 is '<' of ending tag,
// end2 is '>' or both are
// -1 if there is no ending tag for this one...
// or -2 if this is ending tag </...>
int End1, End2;
// name of this tag
wxChar *Name;
};
wxIMPLEMENT_CLASS(wx28HtmlTagsCache,wxObject);
#define CACHE_INCREMENT 64
bool wxIsCDATAElement(const wxChar *tag)
{
return (wxStrcmp(tag, wxT("SCRIPT")) == 0) ||
(wxStrcmp(tag, wxT("STYLE")) == 0);
}
wx28HtmlTagsCache::wx28HtmlTagsCache(const wxString& source)
{
const wxChar *src = source.c_str();
int lng = source.length();
wxChar tagBuffer[256];
m_Cache = nullptr;
m_CacheSize = 0;
m_CachePos = 0;
int pos = 0;
while (pos < lng)
{
if (src[pos] == wxT('<')) // tag found:
{
if (m_CacheSize % CACHE_INCREMENT == 0)
m_Cache = (wx28HtmlCacheItem*) realloc(m_Cache, (m_CacheSize + CACHE_INCREMENT) * sizeof(wx28HtmlCacheItem));
int tg = m_CacheSize++;
int stpos = pos++;
m_Cache[tg].Key = stpos;
int i;
for ( i = 0;
pos < lng && i < (int)WXSIZEOF(tagBuffer) - 1 &&
src[pos] != wxT('>') && !wxIsspace(src[pos]);
i++, pos++ )
{
tagBuffer[i] = (wxChar)wxToupper(src[pos]);
}
tagBuffer[i] = wxT('\0');
m_Cache[tg].Name = new wxChar[i+1];
memcpy(m_Cache[tg].Name, tagBuffer, (i+1)*sizeof(wxChar));
while (pos < lng && src[pos] != wxT('>')) pos++;
if (src[stpos+1] == wxT('/')) // ending tag:
{
m_Cache[tg].End1 = m_Cache[tg].End2 = -2;
// find matching begin tag:
for (i = tg; i >= 0; i--)
if ((m_Cache[i].End1 == -1) && (wxStrcmp(m_Cache[i].Name, tagBuffer+1) == 0))
{
m_Cache[i].End1 = stpos;
m_Cache[i].End2 = pos + 1;
break;
}
}
else
{
m_Cache[tg].End1 = m_Cache[tg].End2 = -1;
if (wxIsCDATAElement(tagBuffer))
{
// store the orig pos in case we are missing the closing
// tag (see below)
wxInt32 old_pos = pos;
bool foundCloseTag = false;
// find next matching tag
int tag_len = wxStrlen(tagBuffer);
while (pos < lng)
{
// find the ending tag
while (pos + 1 < lng &&
(src[pos] != '<' || src[pos+1] != '/'))
++pos;
if (src[pos] == '<')
++pos;
// see if it matches
int match_pos = 0;
while (pos < lng && match_pos < tag_len && src[pos] != '>' && src[pos] != '<') {
// cast to wxChar needed to suppress warning in
// Unicode build
if ((wxChar)wxToupper(src[pos]) == tagBuffer[match_pos]) {
++match_pos;
}
else if (src[pos] == wxT(' ') || src[pos] == wxT('\n') ||
src[pos] == wxT('\r') || src[pos] == wxT('\t')) {
// need to skip over these
}
else {
match_pos = 0;
}
++pos;
}
// found a match
if (match_pos == tag_len)
{
pos = pos - tag_len - 3;
foundCloseTag = true;
break;
}
else // keep looking for the closing tag
{
++pos;
}
}
if (!foundCloseTag)
{
// we didn't find closing tag; this means the markup
// is incorrect and the best thing we can do is to
// ignore the unclosed tag and continue parsing as if
// it didn't exist:
pos = old_pos;
}
}
}
}
pos++;
}
// ok, we're done, now we'll free .Name members of cache - we don't need it anymore:
for (int i = 0; i < m_CacheSize; i++)
{
delete[] m_Cache[i].Name;
m_Cache[i].Name = nullptr;
}
}
void wx28HtmlTagsCache::QueryTag(int at, int* end1, int* end2)
{
if (m_Cache == nullptr) return;
if (m_Cache[m_CachePos].Key != at)
{
int delta = (at < m_Cache[m_CachePos].Key) ? -1 : 1;
do
{
if ( m_CachePos < 0 || m_CachePos == m_CacheSize )
{
// something is very wrong with HTML, give up by returning an
// impossibly large value which is going to be ignored by the
// caller
*end1 =
*end2 = INT_MAX;
return;
}
m_CachePos += delta;
}
while (m_Cache[m_CachePos].Key != at);
}
*end1 = m_Cache[m_CachePos].End1;
*end2 = m_Cache[m_CachePos].End2;
}
//-----------------------------------------------------------------------------
// wx28HtmlTag
//-----------------------------------------------------------------------------
wxIMPLEMENT_CLASS(wx28HtmlTag,wxObject);
wx28HtmlTag::wx28HtmlTag(wx28HtmlTag *parent,
const wxString& source, int pos, int end_pos,
wx28HtmlTagsCache *cache,
wx28HtmlEntitiesParser *entParser) : wxObject()
{
/* Setup DOM relations */
m_Next = nullptr;
m_FirstChild = m_LastChild = nullptr;
m_Parent = parent;
if (parent)
{
m_Prev = m_Parent->m_LastChild;
if (m_Prev == nullptr)
m_Parent->m_FirstChild = this;
else
m_Prev->m_Next = this;
m_Parent->m_LastChild = this;
}
else
m_Prev = nullptr;
/* Find parameters and their values: */
int i;
wxChar c;
// fill-in name, params and begin pos:
i = pos+1;
// find tag's name and convert it to uppercase:
while ((i < end_pos) &&
((c = source[i++]) != wxT(' ') && c != wxT('\r') &&
c != wxT('\n') && c != wxT('\t') &&
c != wxT('>')))
{
if ((c >= wxT('a')) && (c <= wxT('z')))
c -= (wxT('a') - wxT('A'));
m_Name << c;
}
// if the tag has parameters, read them and "normalize" them,
// i.e. convert to uppercase, replace whitespaces by spaces and
// remove whitespaces around '=':
if (source[i-1] != wxT('>'))
{
#define IS_WHITE(c) (c == wxT(' ') || c == wxT('\r') || \
c == wxT('\n') || c == wxT('\t'))
wxString pname, pvalue;
wxChar quote;
enum
{
ST_BEFORE_NAME = 1,
ST_NAME,
ST_BEFORE_EQ,
ST_BEFORE_VALUE,
ST_VALUE
} state;
quote = 0;
state = ST_BEFORE_NAME;
while (i < end_pos)
{
c = source[i++];
if (c == wxT('>') && !(state == ST_VALUE && quote != 0))
{
if (state == ST_BEFORE_EQ || state == ST_NAME)
{
m_ParamNames.Add(pname);
m_ParamValues.Add(wxEmptyString);
}
else if (state == ST_VALUE && quote == 0)
{
m_ParamNames.Add(pname);
if (entParser)
m_ParamValues.Add(entParser->Parse(pvalue));
else
m_ParamValues.Add(pvalue);
}
break;
}
switch (state)
{
case ST_BEFORE_NAME:
if (!IS_WHITE(c))
{
pname = c;
state = ST_NAME;
}
break;
case ST_NAME:
if (IS_WHITE(c))
state = ST_BEFORE_EQ;
else if (c == wxT('='))
state = ST_BEFORE_VALUE;
else
pname << c;
break;
case ST_BEFORE_EQ:
if (c == wxT('='))
state = ST_BEFORE_VALUE;
else if (!IS_WHITE(c))
{
m_ParamNames.Add(pname);
m_ParamValues.Add(wxEmptyString);
pname = c;
state = ST_NAME;
}
break;
case ST_BEFORE_VALUE:
if (!IS_WHITE(c))
{
if (c == wxT('"') || c == wxT('\''))
quote = c, pvalue = wxEmptyString;
else
quote = 0, pvalue = c;
state = ST_VALUE;
}
break;
case ST_VALUE:
if ((quote != 0 && c == quote) ||
(quote == 0 && IS_WHITE(c)))
{
m_ParamNames.Add(pname);
if (quote == 0)
{
// VS: backward compatibility, no real reason,
// but wxHTML code relies on this... :(
pvalue.MakeUpper();
}
if (entParser)
m_ParamValues.Add(entParser->Parse(pvalue));
else
m_ParamValues.Add(pvalue);
state = ST_BEFORE_NAME;
}
else
pvalue << c;
break;
}
}
#undef IS_WHITE
}
m_Begin = i;
cache->QueryTag(pos, &m_End1, &m_End2);
if (m_End1 > end_pos) m_End1 = end_pos;
if (m_End2 > end_pos) m_End2 = end_pos;
}
wx28HtmlTag::~wx28HtmlTag()
{
wx28HtmlTag *t1, *t2;
t1 = m_FirstChild;
while (t1)
{
t2 = t1->GetNextSibling();
delete t1;
t1 = t2;
}
}
bool wx28HtmlTag::HasParam(const wxString& par) const
{
return (m_ParamNames.Index(par, false) != wxNOT_FOUND);
}
wxString wx28HtmlTag::GetParam(const wxString& par, bool with_commas) const
{
int index = m_ParamNames.Index(par, false);
if (index == wxNOT_FOUND)
return wxEmptyString;
if (with_commas)
{
// VS: backward compatibility, seems to be never used by wxHTML...
wxString s;
s << wxT('"') << m_ParamValues[index] << wxT('"');
return s;
}
else
return m_ParamValues[index];
}
int wx28HtmlTag::ScanParam(const wxString& par,
const wxChar *format,
void *param) const
{
wxString parval = GetParam(par);
return wxSscanf(parval, format, param);
}
bool wx28HtmlTag::GetParamAsInt(const wxString& par, int *clr) const
{
if ( !HasParam(par) )
return false;
long i;
if ( !GetParam(par).ToLong(&i) )
return false;
*clr = (int)i;
return true;
}
wxString wx28HtmlTag::GetAllParams() const
{
// VS: this function is for backward compatibility only,
// never used by wxHTML
wxString s;
size_t cnt = m_ParamNames.GetCount();
for (size_t i = 0; i < cnt; i++)
{
s << m_ParamNames[i];
s << wxT('=');
if (m_ParamValues[i].Find(wxT('"')) != wxNOT_FOUND)
s << wxT('\'') << m_ParamValues[i] << wxT('\'');
else
s << wxT('"') << m_ParamValues[i] << wxT('"');
}
return s;
}
wx28HtmlTag *wx28HtmlTag::GetFirstSibling() const
{
if (m_Parent)
return m_Parent->m_FirstChild;
else
{
wx28HtmlTag *cur = (wx28HtmlTag*)this;
while (cur->m_Prev)
cur = cur->m_Prev;
return cur;
}
}
wx28HtmlTag *wx28HtmlTag::GetLastSibling() const
{
if (m_Parent)
return m_Parent->m_LastChild;
else
{
wx28HtmlTag *cur = (wx28HtmlTag*)this;
while (cur->m_Next)
cur = cur->m_Next;
return cur;
}
}
wx28HtmlTag *wx28HtmlTag::GetNextTag() const
{
if (m_FirstChild) return m_FirstChild;
if (m_Next) return m_Next;
wx28HtmlTag *cur = m_Parent;
if (!cur) return nullptr;
while (cur->m_Parent && !cur->m_Next)
cur = cur->m_Parent;
return cur->m_Next;
}

View File

@@ -0,0 +1,138 @@
/////////////////////////////////////////////////////////////////////////////
// Name: htmltag.h
// Purpose: wx28HtmlTag class (represents single tag)
// Author: Vaclav Slavik
// Copyright: (c) 1999 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_HTMLTAG_H_
#define _WX_HTMLTAG_H_
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/arrstr.h"
class wx28HtmlEntitiesParser;
//-----------------------------------------------------------------------------
// wx28HtmlTagsCache
// - internal wxHTML class, do not use!
//-----------------------------------------------------------------------------
struct wx28HtmlCacheItem;
class wx28HtmlTagsCache : public wxObject
{
wxDECLARE_DYNAMIC_CLASS(wx28HtmlTagsCache);
private:
wx28HtmlCacheItem *m_Cache;
int m_CacheSize;
int m_CachePos;
public:
wx28HtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = nullptr;}
wx28HtmlTagsCache(const wxString& source);
virtual ~wx28HtmlTagsCache() {free(m_Cache);}
// Finds parameters for tag starting at at and fills the variables
void QueryTag(int at, int* end1, int* end2);
wxDECLARE_NO_COPY_CLASS(wx28HtmlTagsCache);
};
//--------------------------------------------------------------------------------
// wx28HtmlTag
// This represents single tag. It is used as internal structure
// by wx28HtmlParser.
//--------------------------------------------------------------------------------
class wx28HtmlTag : public wxObject
{
wxDECLARE_CLASS(wx28HtmlTag);
protected:
// constructs wx28HtmlTag object based on HTML tag.
// The tag begins (with '<' character) at position pos in source
// end_pos is position where parsing ends (usually end of document)
wx28HtmlTag(wx28HtmlTag *parent,
const wxString& source, int pos, int end_pos,
wx28HtmlTagsCache *cache,
wx28HtmlEntitiesParser *entParser);
friend class wx28HtmlParser;
public:
virtual ~wx28HtmlTag();
wx28HtmlTag *GetParent() const {return m_Parent;}
wx28HtmlTag *GetFirstSibling() const;
wx28HtmlTag *GetLastSibling() const;
wx28HtmlTag *GetChildren() const { return m_FirstChild; }
wx28HtmlTag *GetPreviousSibling() const { return m_Prev; }
wx28HtmlTag *GetNextSibling() const {return m_Next; }
// Return next tag, as if tree had been flattened
wx28HtmlTag *GetNextTag() const;
// Returns tag's name in uppercase.
inline wxString GetName() const {return m_Name;}
// Returns true if the tag has given parameter. Parameter
// should always be in uppercase.
// Example : <IMG SRC="test.jpg"> HasParam("SRC") returns true
bool HasParam(const wxString& par) const;
// Returns value of the param. Value is in uppercase unless it is
// enclosed with "
// Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
// <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
// (or ("WhaT.jpg") if with_commas == true)
wxString GetParam(const wxString& par, bool with_commas = false) const;
bool GetParamAsInt(const wxString& par, int *clr) const;
// Scans param like scanf() functions family does.
// Example : ScanParam("COLOR", "\"#%X\"", &clr);
// This is always with with_commas=false
// Returns number of scanned values
// (like sscanf() does)
// NOTE: unlike scanf family, this function only accepts
// *one* parameter !
int ScanParam(const wxString& par, const wxChar *format, void *param) const;
// Returns string containing all params.
wxString GetAllParams() const;
// return true if this there is matching ending tag
inline bool HasEnding() const {return m_End1 >= 0;}
// returns beginning position of _internal_ block of text
// See explanation (returned value is marked with *):
// bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
inline int GetBeginPos() const {return m_Begin;}
// returns ending position of _internal_ block of text.
// bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
inline int GetEndPos1() const {return m_End1;}
// returns end position 2 :
// bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
inline int GetEndPos2() const {return m_End2;}
private:
wxString m_Name;
int m_Begin, m_End1, m_End2;
wxArrayString m_ParamNames, m_ParamValues;
// DOM tree relations:
wx28HtmlTag *m_Next;
wx28HtmlTag *m_Prev;
wx28HtmlTag *m_FirstChild, *m_LastChild;
wx28HtmlTag *m_Parent;
wxDECLARE_NO_COPY_CLASS(wx28HtmlTag);
};
#endif // _WX_HTMLTAG_H_

View File

@@ -0,0 +1,192 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META NAME="GENERATOR" CONTENT="Mozilla/4.06 [en] (X11; I; Linux 2.0.35 i686) [Netscape]">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
<H3>
This is TABLES
tests page...</H3>
(yes, really, see below:)
<BR>Click <a href="test.htm">here</a> to go to original testing page...
<BR>Click <a href="../../docs/html/man.htm">here</a> to go to manuals...
<BR>&nbsp;
<CENTER><TABLE CELLSPACING=5 BORDER COLS=2 WIDTH="40%" NOSAVE >
<TR ALIGN=CENTER NOSAVE>
<TD WIDTH="40%" NOSAVE>Top left
<BR>(two lines expression)
<P>paragraph done</TD>
<TD NOSAVE>Top right</TD>
</TR>
<TR>
<TD>Bottom left</TD>
<TD>Bottom right</TD>
</TR>
</TABLE></CENTER>
<P>Subsampling is shown there:
<BR>&nbsp;
<TABLE BORDER COLS=2 WIDTH="100%" NOSAVE >
<TR NOSAVE>
<TD VALIGN=BOTTOM NOSAVE>
<TABLE BORDER COLS=2 WIDTH="50%" NOSAVE >
<TR ALIGN=CENTER BGCOLOR="#3366FF" NOSAVE>
<TD>a</TD>
<TD WIDTH="10%" NOSAVE>b</TD>
</TR>
<TR NOSAVE>
<TD>c</TD>
<TD NOSAVE>d</TD>
</TR>
</TABLE>
</TD>
<TD VALIGN=BOTTOM NOSAVE>2</TD>
</TR>
<TR NOSAVE>
<TD>3 dflkj lkjfl dkjldkfjl flk jflkf lkjflkj ljlf ajlfj alff h khg hgj
gjg jg gjhfg fg gjh gjf jgf jgj f gjfgj kfajg&nbsp;</TD>
<TD ALIGN=CENTER VALIGN=BOTTOM BGCOLOR="#FFFF99" NOSAVE>4
<BR>gh
<BR>gfh
<BR>gh
<BR>hg
<BR>5</TD>
</TR>
</TABLE>
<P>This is "default" table - with no sizes givev:
<BR>&nbsp;
<TABLE BORDER COLS=4 WIDTH="100%" NOSAVE >
<TR NOSAVE>
<TD>Hello</TD>
<TD NOSAVE>lkfdsjlk fj dlfj lkfj lkjflk jlfk lk fjlk elwkf lkejflek f jlekjflkj
ljlk lk jlkf lefjl j flkj ljl lf lfj lfjl lj lwe lekf;eh kfejh lkh kjh
kjhkj hkj hkj lkh kjh kjlh kj</TD>
<TD>shortebn formo lr lk</TD>
<TD>djsf lkjlf poer oi pjr po kpk&nbsp;</TD>
</TR>
<TR>
<TD>a</TD>
<TD>b</TD>
<TD>c</TD>
<TD>d</TD>
</TR>
<TR NOSAVE>
<TD>1</TD>
<TD>2</TD>
<TD COLSPAN="2" ROWSPAN="2" NOSAVE>3</TD>
</TR>
<TR>
<TD>A</TD>
<TD>B</Td>
</TR>
</TABLE>
<p>
</p>
<hr size="8"/>
<table cellspacing='0' cellpadding='0'>
<tr align='left'>
<td width="30%" valign='top'>Error:</td>
<td width='5'></td>
<td>Sex sells better than <b>truth and honour</b></td><td align='right'>X For President is my agenda!</td>
</tr>
<tr align='left'>
<td valign='top'>Command:</td>
<td width='5'></td>
<td>Go out and spread the word, <b>we shall prevail!</b></td><td>X</td>
</tr>
</table>
<br><br>
<table cellspacing='0' cellpadding='0'>
<tr align='left'>
<td valign='top'>Error:</td>
<td width='5'></td>
<td>Sex sells better than <b>truth and honour</b></td><td align='right'>X For President is my agenda!</td>
</tr>
<tr align='left'>
<td valign='top'>Command:</td>
<td width='5'></td>
<td>Go out and spread the word, <b>we shall prevail!</b></td><td>X</td>
</tr>
</table>
<br><br>
<table width="200" cellspacing='0' cellpadding='0'>
<tr align='left'>
<td valign='top'>Error:</td>
<td width='5'></td>
<td nowrap>Sex sells better than <b>truth and honour</b></td><td align='right'>X For President is my agenda!</td>
</tr>
<tr align='left'>
<td valign='top'>Command:</td>
<td width='5'></td>
<td>Go out and spread the word, <b>we shall prevail!</b></td><td>X</td>
</tr>
</table>
<br><br>
<table cellspacing='0' cellpadding='0'>
<tr align='left'>
<td valign='top'>Error:</td>
<td width='5'></td>
<td>
<table cellspacing='0' cellpadding='0'>
<tr align='left'>
<td valign='top'>Error:</td>
<td width='5'></td>
<td>Sex sells better than <b>truth and honour</b></td><td align='right'>X For President is my agenda!</td>
</tr>
<tr align='left'>
<td valign='top'>Command:</td>
<td width='5'></td>
<td>Go out and spread the word, <b>we shall prevail!</b></td>
<td>X</td>
</tr>
</table>
</td>
<td align='right'>X For President is my agenda!</td>
</tr>
<tr align='left'>
<td valign='top'>Command:</td>
<td width='5'></td>
<td>Go out and spread the word, <b>we shall prevail!</b></td>
<td>X</td>
</tr>
</table>
<br><br>
<table cellspacing='0' cellpadding='0'>
<tr>
<td><ul><li>Just a small test</li></ul></td>
<td>Really, a test!</td>
</tr>
</table>

View File

@@ -0,0 +1,120 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/image.cpp
// Purpose: wxImage benchmarks
// Author: Vadim Zeitlin
// Created: 2013-06-30
// Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/image.h"
#include "bench.h"
BENCHMARK_FUNC(LoadBMP)
{
wxImage image;
return image.LoadFile("horse.bmp");
}
BENCHMARK_FUNC(LoadJPEG)
{
static bool s_handlerAdded = false;
if ( !s_handlerAdded )
{
s_handlerAdded = true;
wxImage::AddHandler(new wxJPEGHandler);
}
wxImage image;
return image.LoadFile("horse.jpg");
}
BENCHMARK_FUNC(LoadPNG)
{
static bool s_handlerAdded = false;
if ( !s_handlerAdded )
{
s_handlerAdded = true;
wxImage::AddHandler(new wxPNGHandler);
}
wxImage image;
return image.LoadFile("horse.png");
}
#if wxUSE_LIBTIFF
BENCHMARK_FUNC(LoadTIFF)
{
static bool s_handlerAdded = false;
if ( !s_handlerAdded )
{
s_handlerAdded = true;
wxImage::AddHandler(new wxTIFFHandler);
}
wxImage image;
return image.LoadFile("horse.tif");
}
#endif // wxUSE_LIBTIFF
static const wxImage& GetTestImage()
{
static wxImage s_image;
static bool s_triedToLoad = false;
if ( !s_triedToLoad )
{
s_triedToLoad = true;
s_image.LoadFile(Bench::GetStringParameter("horse.bmp"));
}
return s_image;
}
BENCHMARK_FUNC(EnlargeNormal)
{
const wxImage& image = GetTestImage();
const double factor = Bench::GetNumericParameter(150) / 100.;
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
wxIMAGE_QUALITY_NORMAL).IsOk();
}
BENCHMARK_FUNC(EnlargeBoxAverage)
{
const wxImage& image = GetTestImage();
const double factor = Bench::GetNumericParameter(150) / 100.;
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
wxIMAGE_QUALITY_BOX_AVERAGE).IsOk();
}
BENCHMARK_FUNC(EnlargeHighQuality)
{
const wxImage& image = GetTestImage();
const double factor = Bench::GetNumericParameter(150) / 100.;
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
wxIMAGE_QUALITY_HIGH).IsOk();
}
BENCHMARK_FUNC(ShrinkNormal)
{
const wxImage& image = GetTestImage();
const double factor = Bench::GetNumericParameter(50) / 100.;
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
wxIMAGE_QUALITY_NORMAL).IsOk();
}
BENCHMARK_FUNC(ShrinkBoxAverage)
{
const wxImage& image = GetTestImage();
const double factor = Bench::GetNumericParameter(50) / 100.;
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
wxIMAGE_QUALITY_BOX_AVERAGE).IsOk();
}
BENCHMARK_FUNC(ShrinkHighQuality)
{
const wxImage& image = GetTestImage();
const double factor = Bench::GetNumericParameter(50) / 100.;
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
wxIMAGE_QUALITY_HIGH).IsOk();
}

View File

@@ -0,0 +1,169 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/ipcclient.cpp
// Purpose: wxIPC client side benchmarks
// Author: Vadim Zeitlin
// Created: 2008-10-13
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "bench.h"
#include "wx/evtloop.h"
// do this before including wx/ipc.h under Windows to use TCP even there
#define wxUSE_DDE_FOR_IPC 0
#include "wx/ipc.h"
#include "../../samples/ipc/ipcsetup.h"
namespace
{
class PokeAdviseConn : public wxConnection
{
public:
PokeAdviseConn() { m_gotAdvised = false; }
bool GotAdvised()
{
if ( !m_gotAdvised )
return false;
m_gotAdvised = false;
return true;
}
const wxString& GetItem() const { return m_item; }
virtual bool OnAdvise(const wxString& topic,
const wxString& item,
const void *data,
size_t size,
wxIPCFormat format)
{
m_gotAdvised = true;
if ( topic != IPC_BENCHMARK_TOPIC ||
item != IPC_BENCHMARK_ITEM ||
!IsTextFormat(format) )
{
m_item = "ERROR";
return false;
}
m_item = GetTextFromData(data, size, format);
return true;
}
private:
wxString m_item;
bool m_gotAdvised;
wxDECLARE_NO_COPY_CLASS(PokeAdviseConn);
};
class PokeAdviseClient : public wxClient
{
public:
// provide a convenient helper taking care of connecting to the right
// server/service/topic and returning the connection of the derived type
// (or nullptr if we failed to connect)
PokeAdviseConn *Connect()
{
wxString host = Bench::GetStringParameter();
if ( host.empty() )
host = IPC_HOST;
wxString service;
int port = Bench::GetNumericParameter();
if ( !port )
service = IPC_SERVICE;
else
service.Printf("%d", port);
return static_cast<PokeAdviseConn *>(
MakeConnection(host, service, IPC_BENCHMARK_TOPIC));
}
// override base class virtual to use a custom connection class
virtual wxConnectionBase *OnMakeConnection()
{
return new PokeAdviseConn;
}
};
class PokeAdvisePersistentConnection
{
public:
PokeAdvisePersistentConnection()
{
m_client = new PokeAdviseClient;
m_conn = m_client->Connect();
if ( m_conn )
m_conn->StartAdvise(IPC_BENCHMARK_ITEM);
}
~PokeAdvisePersistentConnection()
{
if ( m_conn )
{
m_conn->StopAdvise(IPC_BENCHMARK_ITEM);
m_conn->Disconnect();
}
delete m_client;
}
PokeAdviseConn *Get() const { return m_conn; }
private:
PokeAdviseClient *m_client;
PokeAdviseConn *m_conn;
wxDECLARE_NO_COPY_CLASS(PokeAdvisePersistentConnection);
};
PokeAdvisePersistentConnection *theConnection = nullptr;
bool ConnInit()
{
theConnection = new PokeAdvisePersistentConnection;
if ( !theConnection->Get() )
{
delete theConnection;
theConnection = nullptr;
return false;
}
return true;
}
void ConnDone()
{
delete theConnection;
}
} // anonymous namespace
BENCHMARK_FUNC_WITH_INIT(IPCPokeAdvise, ConnInit, ConnDone)
{
wxEventLoop loop;
PokeAdviseConn * const conn = theConnection->Get();
const wxString s(1024, '@');
if ( !conn->Poke(IPC_BENCHMARK_ITEM, s) )
return false;
while ( !conn->GotAdvised() )
loop.Dispatch();
if ( conn->GetItem() != s )
return false;
return true;
}

View File

@@ -0,0 +1,108 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/log.cpp
// Purpose: Log-related benchmarks
// Author: Vadim Zeitlin
// Created: 2012-01-21
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "bench.h"
#include "wx/log.h"
// This class is used to check that the arguments of log functions are not
// evaluated.
struct NotCreated
{
NotCreated() { wxAbort(); }
const char* AsStr() const { return "unreachable"; }
};
// Temporarily change the log level to the given one.
class LogLevelSetter
{
public:
LogLevelSetter(wxLogLevel levelNew)
: m_levelOld(wxLog::GetLogLevel())
{
wxLog::SetLogLevel(levelNew);
}
~LogLevelSetter()
{
wxLog::SetLogLevel(m_levelOld);
}
private:
const wxLogLevel m_levelOld;
wxDECLARE_NO_COPY_CLASS(LogLevelSetter);
};
BENCHMARK_FUNC(LogDebugDisabled)
{
LogLevelSetter level(wxLOG_Info);
wxLogDebug("Ignored debug message: %s", NotCreated().AsStr());
return true;
}
BENCHMARK_FUNC(LogTraceDisabled)
{
LogLevelSetter level(wxLOG_Info);
wxLogTrace("", NotCreated().AsStr());
return true;
}
BENCHMARK_FUNC(LogTraceActive)
{
static bool s_added = false;
if ( !s_added )
{
s_added = true;
wxLog::AddTraceMask("logbench");
}
// Remove the actual logging overhead by simply throwing away the log
// messages.
class NulLog : public wxLog
{
public:
NulLog()
: m_logOld(wxLog::SetActiveTarget(this))
{
}
virtual ~NulLog()
{
wxLog::SetActiveTarget(m_logOld);
}
protected:
virtual void DoLogRecord(wxLogLevel,
const wxString&,
const wxLogRecordInfo&)
{
}
wxLog* m_logOld;
};
NulLog nulLog;
wxLogTrace("logbench", "Trace message");
return true;
}
BENCHMARK_FUNC(LogTraceInactive)
{
wxLogTrace("bloordyblop", "Trace message");
return true;
}

View File

@@ -0,0 +1,346 @@
# =========================================================================
# This makefile was generated by
# Bakefile 0.2.13 (http://www.bakefile.org)
# Do not modify, all changes will be overwritten!
# =========================================================================
include ../../build/msw/config.gcc
# -------------------------------------------------------------------------
# Do not modify the rest of this file!
# -------------------------------------------------------------------------
### Variables: ###
CPPDEPS = -MT$@ -MF$@.d -MD -MP
WX_RELEASE_NODOT = 33
COMPILER_PREFIX = gcc
OBJS = \
$(COMPILER_PREFIX)$(COMPILER_VERSION)_$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)$(WXDLLFLAG)$(CFG)
LIBDIRNAME = \
.\..\..\lib\$(COMPILER_PREFIX)$(COMPILER_VERSION)_$(LIBTYPE_SUFFIX)$(CFG)
SETUPHDIR = $(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)
BENCH_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) -D__WXMSW__ \
$(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
-I$(SETUPHDIR) -I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) -W -Wall \
-I. $(__DLLFLAG_p) -DwxUSE_GUI=0 $(__RTTIFLAG) $(__EXCEPTIONSFLAG) \
-Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
BENCH_OBJECTS = \
$(OBJS)\bench_bench.o \
$(OBJS)\bench_datetime.o \
$(OBJS)\bench_htmlpars.o \
$(OBJS)\bench_htmltag.o \
$(OBJS)\bench_ipcclient.o \
$(OBJS)\bench_log.o \
$(OBJS)\bench_mbconv.o \
$(OBJS)\bench_regex.o \
$(OBJS)\bench_strings.o \
$(OBJS)\bench_tls.o \
$(OBJS)\bench_printfbench.o
BENCH_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \
-D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
-I$(SETUPHDIR) -I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) -W -Wall \
-I. $(__DLLFLAG_p) -I.\..\..\samples -DNOPCH $(__RTTIFLAG) \
$(__EXCEPTIONSFLAG) -Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
BENCH_GUI_OBJECTS = \
$(OBJS)\bench_gui_sample_rc.o \
$(OBJS)\bench_gui_bench.o \
$(OBJS)\bench_gui_display.o \
$(OBJS)\bench_gui_image.o
BENCH_GRAPHICS_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \
-D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
-I$(SETUPHDIR) -I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) -W -Wall \
-I. $(__DLLFLAG_p) -I.\..\..\samples -DNOPCH $(__RTTIFLAG) \
$(__EXCEPTIONSFLAG) -Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
BENCH_GRAPHICS_OBJECTS = \
$(OBJS)\bench_graphics_sample_rc.o \
$(OBJS)\bench_graphics_graphics.o
### Conditionally set variables: ###
ifeq ($(USE_GUI),0)
PORTNAME = base
endif
ifeq ($(USE_GUI),1)
PORTNAME = msw$(TOOLKIT_VERSION)
endif
ifeq ($(OFFICIAL_BUILD),1)
COMPILER_VERSION = ERROR-COMPILER-VERSION-MUST-BE-SET-FOR-OFFICIAL-BUILD
endif
ifeq ($(BUILD),debug)
WXDEBUGFLAG = d
endif
ifeq ($(WXUNIV),1)
WXUNIVNAME = univ
endif
ifeq ($(SHARED),1)
WXDLLFLAG = dll
endif
ifeq ($(SHARED),0)
LIBTYPE_SUFFIX = lib
endif
ifeq ($(SHARED),1)
LIBTYPE_SUFFIX = dll
endif
ifeq ($(MONOLITHIC),0)
EXTRALIBS_FOR_BASE =
endif
ifeq ($(MONOLITHIC),1)
EXTRALIBS_FOR_BASE =
endif
ifeq ($(MONOLITHIC),0)
__WXLIB_NET_p = \
-lwxbase$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net
endif
ifeq ($(MONOLITHIC),1)
__LIB_PNG_IF_MONO_p = $(__LIB_PNG_p)
endif
ifeq ($(USE_GUI),1)
__bench_gui___depname = $(OBJS)\bench_gui.exe
endif
ifeq ($(MONOLITHIC),1)
ifeq ($(USE_STC),1)
__LIB_LEXILLA_IF_MONO_p = $(__LIB_LEXILLA_p)
endif
endif
ifeq ($(USE_GUI),1)
__bench_graphics___depname = $(OBJS)\bench_graphics.exe
endif
ifeq ($(MONOLITHIC),1)
ifeq ($(USE_STC),1)
__LIB_LEXILLA_IF_MONO_p_1 = $(__LIB_LEXILLA_p)
endif
endif
ifeq ($(BUILD),debug)
__OPTIMIZEFLAG = -O0
endif
ifeq ($(BUILD),release)
__OPTIMIZEFLAG = -O2
endif
ifeq ($(USE_RTTI),0)
__RTTIFLAG = -fno-rtti
endif
ifeq ($(USE_RTTI),1)
__RTTIFLAG =
endif
ifeq ($(USE_EXCEPTIONS),0)
__EXCEPTIONSFLAG = -fno-exceptions
endif
ifeq ($(USE_EXCEPTIONS),1)
__EXCEPTIONSFLAG =
endif
ifeq ($(WXUNIV),1)
__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__
endif
ifeq ($(WXUNIV),1)
__WXUNIV_DEFINE_p_0 = --define __WXUNIVERSAL__
endif
ifeq ($(DEBUG_FLAG),0)
__DEBUG_DEFINE_p = -DwxDEBUG_LEVEL=0
endif
ifeq ($(DEBUG_FLAG),0)
__DEBUG_DEFINE_p_0 = --define wxDEBUG_LEVEL=0
endif
ifeq ($(BUILD),release)
__NDEBUG_DEFINE_p = -DNDEBUG
endif
ifeq ($(BUILD),release)
__NDEBUG_DEFINE_p_0 = --define NDEBUG
endif
ifeq ($(USE_EXCEPTIONS),0)
__EXCEPTIONS_DEFINE_p = -DwxNO_EXCEPTIONS
endif
ifeq ($(USE_EXCEPTIONS),0)
__EXCEPTIONS_DEFINE_p_0 = --define wxNO_EXCEPTIONS
endif
ifeq ($(USE_RTTI),0)
__RTTI_DEFINE_p = -DwxNO_RTTI
endif
ifeq ($(USE_RTTI),0)
__RTTI_DEFINE_p_0 = --define wxNO_RTTI
endif
ifeq ($(USE_THREADS),0)
__THREAD_DEFINE_p = -DwxNO_THREADS
endif
ifeq ($(USE_THREADS),0)
__THREAD_DEFINE_p_0 = --define wxNO_THREADS
endif
ifeq ($(USE_CAIRO),1)
____CAIRO_INCLUDEDIR_FILENAMES = -I$(CAIRO_ROOT)\include\cairo
endif
ifeq ($(USE_CAIRO),1)
__CAIRO_INCLUDEDIR_p = --include-dir $(CAIRO_ROOT)/include/cairo
endif
ifeq ($(SHARED),1)
__DLLFLAG_p = -DWXUSINGDLL
endif
ifeq ($(SHARED),1)
__DLLFLAG_p_0 = --define WXUSINGDLL
endif
ifeq ($(MONOLITHIC),0)
__WXLIB_CORE_p = \
-lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core
endif
ifeq ($(MONOLITHIC),0)
__WXLIB_BASE_p = -lwxbase$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)
endif
ifeq ($(MONOLITHIC),1)
__WXLIB_MONO_p = \
-lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)
endif
ifeq ($(MONOLITHIC),1)
ifeq ($(USE_STC),1)
__LIB_SCINTILLA_IF_MONO_p = -lwxscintilla$(WXDEBUGFLAG)
endif
endif
ifeq ($(USE_STC),1)
__LIB_LEXILLA_p = -lwxlexilla$(WXDEBUGFLAG)
endif
ifeq ($(USE_GUI),1)
__LIB_TIFF_p = -lwxtiff$(WXDEBUGFLAG)
endif
ifeq ($(USE_GUI),1)
__LIB_JPEG_p = -lwxjpeg$(WXDEBUGFLAG)
endif
ifeq ($(USE_GUI),1)
__LIB_PNG_p = -lwxpng$(WXDEBUGFLAG)
endif
ifeq ($(USE_GUI),1)
__LIB_WEBP_p = -lwxwebp$(WXDEBUGFLAG)
endif
ifeq ($(USE_CAIRO),1)
__CAIRO_LIB_p = -lcairo
endif
ifeq ($(USE_CAIRO),1)
____CAIRO_LIBDIR_FILENAMES = -L$(CAIRO_ROOT)\lib
endif
ifeq ($(BUILD),debug)
ifeq ($(DEBUG_INFO),default)
__DEBUGINFO = -g
endif
endif
ifeq ($(BUILD),release)
ifeq ($(DEBUG_INFO),default)
__DEBUGINFO =
endif
endif
ifeq ($(DEBUG_INFO),0)
__DEBUGINFO =
endif
ifeq ($(DEBUG_INFO),1)
__DEBUGINFO = -g
endif
ifeq ($(USE_THREADS),0)
__THREADSFLAG =
endif
ifeq ($(USE_THREADS),1)
__THREADSFLAG = -mthreads
endif
all: $(OBJS)
$(OBJS):
-if not exist $(OBJS) mkdir $(OBJS)
### Targets: ###
all: $(OBJS)\bench.exe data $(__bench_gui___depname) $(__bench_graphics___depname) data-image
clean:
-if exist $(OBJS)\*.o del $(OBJS)\*.o
-if exist $(OBJS)\*.d del $(OBJS)\*.d
-if exist $(OBJS)\bench.exe del $(OBJS)\bench.exe
-if exist $(OBJS)\bench_gui.exe del $(OBJS)\bench_gui.exe
-if exist $(OBJS)\bench_graphics.exe del $(OBJS)\bench_graphics.exe
$(OBJS)\bench.exe: $(BENCH_OBJECTS)
$(foreach f,$(subst \,/,$(BENCH_OBJECTS)),$(shell echo $f >> $(subst \,/,$@).rsp.tmp))
@move /y $@.rsp.tmp $@.rsp >nul
$(CXX) -o $@ @$@.rsp $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_PNG_IF_MONO_p) -lwxzlib$(WXDEBUGFLAG) -lwxregexu$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) -lkernel32 -luser32 -lgdi32 -lgdiplus -lmsimg32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lversion -lws2_32 -lwininet -loleacc -luxtheme
@-del $@.rsp
data:
if not exist $(OBJS) mkdir $(OBJS)
for %%f in (htmltest.html) do if not exist $(OBJS)\%%f copy .\%%f $(OBJS)
ifeq ($(USE_GUI),1)
$(OBJS)\bench_gui.exe: $(BENCH_GUI_OBJECTS) $(OBJS)\bench_gui_sample_rc.o
$(foreach f,$(subst \,/,$(BENCH_GUI_OBJECTS)),$(shell echo $f >> $(subst \,/,$@).rsp.tmp))
@move /y $@.rsp.tmp $@.rsp >nul
$(CXX) -o $@ @$@.rsp $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_LEXILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) -lwxzlib$(WXDEBUGFLAG) -lwxregexu$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) -lkernel32 -luser32 -lgdi32 -lgdiplus -lmsimg32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lversion -lws2_32 -lwininet -loleacc -luxtheme
@-del $@.rsp
endif
ifeq ($(USE_GUI),1)
$(OBJS)\bench_graphics.exe: $(BENCH_GRAPHICS_OBJECTS) $(OBJS)\bench_graphics_sample_rc.o
$(foreach f,$(subst \,/,$(BENCH_GRAPHICS_OBJECTS)),$(shell echo $f >> $(subst \,/,$@).rsp.tmp))
@move /y $@.rsp.tmp $@.rsp >nul
$(CXX) -o $@ @$@.rsp $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) -lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl -lopengl32 $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_LEXILLA_IF_MONO_p_1) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) -lwxzlib$(WXDEBUGFLAG) -lwxregexu$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) -lkernel32 -luser32 -lgdi32 -lgdiplus -lmsimg32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lversion -lws2_32 -lwininet -loleacc -luxtheme
@-del $@.rsp
endif
data-image:
if not exist $(OBJS) mkdir $(OBJS)
for %%f in (../../samples/image/horse.bmp ../../samples/image/horse.jpg ../../samples/image/horse.png ../../samples/image/horse.tif) do if not exist $(OBJS)\%%f copy .\%%f $(OBJS)
$(OBJS)\bench_bench.o: ./bench.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_datetime.o: ./datetime.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_htmlpars.o: ./htmlparser/htmlpars.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_htmltag.o: ./htmlparser/htmltag.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_ipcclient.o: ./ipcclient.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_log.o: ./log.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_mbconv.o: ./mbconv.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_regex.o: ./regex.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_strings.o: ./strings.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_tls.o: ./tls.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_printfbench.o: ./printfbench.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_gui_sample_rc.o: ./../../samples/sample.rc
$(WINDRES) -i$< -o$@ --define __WXMSW__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__NDEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) --include-dir $(SETUPHDIR) --include-dir ./../../include $(__CAIRO_INCLUDEDIR_p) --include-dir . $(__DLLFLAG_p_0) --define wxUSE_DPI_AWARE_MANIFEST=$(USE_DPI_AWARE_MANIFEST) --include-dir ./../../samples --define NOPCH
$(OBJS)\bench_gui_bench.o: ./bench.cpp
$(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_gui_display.o: ./display.cpp
$(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_gui_image.o: ./image.cpp
$(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_graphics_sample_rc.o: ./../../samples/sample.rc
$(WINDRES) -i$< -o$@ --define __WXMSW__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__NDEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) --include-dir $(SETUPHDIR) --include-dir ./../../include $(__CAIRO_INCLUDEDIR_p) --include-dir . $(__DLLFLAG_p_0) --define wxUSE_DPI_AWARE_MANIFEST=$(USE_DPI_AWARE_MANIFEST) --include-dir ./../../samples --define NOPCH
$(OBJS)\bench_graphics_graphics.o: ./graphics.cpp
$(CXX) -c -o $@ $(BENCH_GRAPHICS_CXXFLAGS) $(CPPDEPS) $<
.PHONY: all clean data data-image
SHELL := $(COMSPEC)
# Dependencies tracking:
-include $(OBJS)/*.d

View File

@@ -0,0 +1,603 @@
# =========================================================================
# This makefile was generated by
# Bakefile 0.2.13 (http://www.bakefile.org)
# Do not modify, all changes will be overwritten!
# =========================================================================
!include <../../build/msw/config.vc>
# -------------------------------------------------------------------------
# Do not modify the rest of this file!
# -------------------------------------------------------------------------
### Variables: ###
WX_RELEASE_NODOT = 33
COMPILER_PREFIX = vc
OBJS = \
$(COMPILER_PREFIX)$(COMPILER_VERSION)$(ARCH_SUFFIX)_$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)$(WXDLLFLAG)$(CFG)
LIBDIRNAME = \
.\..\..\lib\$(COMPILER_PREFIX)$(COMPILER_VERSION)$(ARCH_SUFFIX)_$(LIBTYPE_SUFFIX)$(CFG)
SETUPHDIR = $(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)
BENCH_CXXFLAGS = /M$(__RUNTIME_LIBS_10)$(__DEBUGRUNTIME) /DWIN32 \
$(__DEBUGINFO) /Fd$(OBJS)\bench.pdb $(____DEBUGRUNTIME) $(__OPTIMIZEFLAG) \
/D_CRT_SECURE_NO_DEPRECATE=1 /D_CRT_NON_CONFORMING_SWPRINTFS=1 \
/D_SCL_SECURE_NO_WARNINGS=1 $(__NO_VC_CRTDBG_p) $(__TARGET_CPU_COMPFLAG_p) \
/D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
/I$(SETUPHDIR) /I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) /W4 /I. \
$(__DLLFLAG_p) /D_CONSOLE /DwxUSE_GUI=0 $(__RTTIFLAG) $(__EXCEPTIONSFLAG) \
$(CPPFLAGS) $(CXXFLAGS)
BENCH_OBJECTS = \
$(OBJS)\bench_bench.obj \
$(OBJS)\bench_datetime.obj \
$(OBJS)\bench_htmlpars.obj \
$(OBJS)\bench_htmltag.obj \
$(OBJS)\bench_ipcclient.obj \
$(OBJS)\bench_log.obj \
$(OBJS)\bench_mbconv.obj \
$(OBJS)\bench_regex.obj \
$(OBJS)\bench_strings.obj \
$(OBJS)\bench_tls.obj \
$(OBJS)\bench_printfbench.obj
BENCH_GUI_CXXFLAGS = /M$(__RUNTIME_LIBS_26)$(__DEBUGRUNTIME) /DWIN32 \
$(__DEBUGINFO) /Fd$(OBJS)\bench_gui.pdb $(____DEBUGRUNTIME) \
$(__OPTIMIZEFLAG) /D_CRT_SECURE_NO_DEPRECATE=1 \
/D_CRT_NON_CONFORMING_SWPRINTFS=1 /D_SCL_SECURE_NO_WARNINGS=1 \
$(__NO_VC_CRTDBG_p) $(__TARGET_CPU_COMPFLAG_p) /D__WXMSW__ \
$(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
/I$(SETUPHDIR) /I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) /W4 /I. \
$(__DLLFLAG_p) /I.\..\..\samples /DNOPCH /D_CONSOLE $(__RTTIFLAG) \
$(__EXCEPTIONSFLAG) $(CPPFLAGS) $(CXXFLAGS)
BENCH_GUI_OBJECTS = \
$(OBJS)\bench_gui_bench.obj \
$(OBJS)\bench_gui_display.obj \
$(OBJS)\bench_gui_image.obj
BENCH_GUI_RESOURCES = \
$(OBJS)\bench_gui_sample.res
BENCH_GRAPHICS_CXXFLAGS = /M$(__RUNTIME_LIBS_42)$(__DEBUGRUNTIME) /DWIN32 \
$(__DEBUGINFO) /Fd$(OBJS)\bench_graphics.pdb $(____DEBUGRUNTIME) \
$(__OPTIMIZEFLAG) /D_CRT_SECURE_NO_DEPRECATE=1 \
/D_CRT_NON_CONFORMING_SWPRINTFS=1 /D_SCL_SECURE_NO_WARNINGS=1 \
$(__NO_VC_CRTDBG_p) $(__TARGET_CPU_COMPFLAG_p) /D__WXMSW__ \
$(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
/I$(SETUPHDIR) /I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) /W4 /I. \
$(__DLLFLAG_p) /I.\..\..\samples /DNOPCH /D_CONSOLE $(__RTTIFLAG) \
$(__EXCEPTIONSFLAG) $(CPPFLAGS) $(CXXFLAGS)
BENCH_GRAPHICS_OBJECTS = \
$(OBJS)\bench_graphics_graphics.obj
BENCH_GRAPHICS_RESOURCES = \
$(OBJS)\bench_graphics_sample.res
### Conditionally set variables: ###
!if "$(TARGET_CPU)" == "AMD64"
ARCH_SUFFIX = _x64
!endif
!if "$(TARGET_CPU)" == "ARM"
ARCH_SUFFIX = _arm
!endif
!if "$(TARGET_CPU)" == "ARM64"
ARCH_SUFFIX = _arm64
!endif
!if "$(TARGET_CPU)" == "IA64"
ARCH_SUFFIX = _ia64
!endif
!if "$(TARGET_CPU)" == "X64"
ARCH_SUFFIX = _x64
!endif
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "X64"
ARCH_SUFFIX = _x64
!endif
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "x64"
ARCH_SUFFIX = _x64
!endif
!if "$(TARGET_CPU)" == "amd64"
ARCH_SUFFIX = _x64
!endif
!if "$(TARGET_CPU)" == "arm"
ARCH_SUFFIX = _arm
!endif
!if "$(TARGET_CPU)" == "arm64"
ARCH_SUFFIX = _arm64
!endif
!if "$(TARGET_CPU)" == "ia64"
ARCH_SUFFIX = _ia64
!endif
!if "$(TARGET_CPU)" == "x64"
ARCH_SUFFIX = _x64
!endif
!if "$(USE_GUI)" == "0"
PORTNAME = base
!endif
!if "$(USE_GUI)" == "1"
PORTNAME = msw$(TOOLKIT_VERSION)
!endif
!if "$(OFFICIAL_BUILD)" == "1"
COMPILER_VERSION = ERROR-COMPILER-VERSION-MUST-BE-SET-FOR-OFFICIAL-BUILD
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
WXDEBUGFLAG = d
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
WXDEBUGFLAG = d
!endif
!if "$(WXUNIV)" == "1"
WXUNIVNAME = univ
!endif
!if "$(SHARED)" == "1"
WXDLLFLAG = dll
!endif
!if "$(SHARED)" == "0"
LIBTYPE_SUFFIX = lib
!endif
!if "$(SHARED)" == "1"
LIBTYPE_SUFFIX = dll
!endif
!if "$(TARGET_CPU)" == "AMD64"
LINK_TARGET_CPU = /MACHINE:X64
!endif
!if "$(TARGET_CPU)" == "ARM"
LINK_TARGET_CPU = /MACHINE:ARM
!endif
!if "$(TARGET_CPU)" == "ARM64"
LINK_TARGET_CPU = /MACHINE:ARM64
!endif
!if "$(TARGET_CPU)" == "IA64"
LINK_TARGET_CPU = /MACHINE:IA64
!endif
!if "$(TARGET_CPU)" == "X64"
LINK_TARGET_CPU = /MACHINE:X64
!endif
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "X64"
LINK_TARGET_CPU = /MACHINE:X64
!endif
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "x64"
LINK_TARGET_CPU = /MACHINE:X64
!endif
!if "$(TARGET_CPU)" == "amd64"
LINK_TARGET_CPU = /MACHINE:X64
!endif
!if "$(TARGET_CPU)" == "arm"
LINK_TARGET_CPU = /MACHINE:ARM
!endif
!if "$(TARGET_CPU)" == "arm64"
LINK_TARGET_CPU = /MACHINE:ARM64
!endif
!if "$(TARGET_CPU)" == "ia64"
LINK_TARGET_CPU = /MACHINE:IA64
!endif
!if "$(TARGET_CPU)" == "x64"
LINK_TARGET_CPU = /MACHINE:X64
!endif
!if "$(USE_DPI_AWARE_MANIFEST)" == "1" && "$(VISUALSTUDIOVERSION)" == "14.0"
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware.manifest
!endif
!if "$(USE_DPI_AWARE_MANIFEST)" == "1" && "$(VISUALSTUDIOVERSION)" == "15.0"
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware.manifest
!endif
!if "$(USE_DPI_AWARE_MANIFEST)" == "1" && "$(VISUALSTUDIOVERSION)" == "16.0"
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware.manifest
!endif
!if "$(USE_DPI_AWARE_MANIFEST)" == "1" && "$(VISUALSTUDIOVERSION)" == "17.0"
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware.manifest
!endif
!if "$(USE_DPI_AWARE_MANIFEST)" == "2" && "$(VISUALSTUDIOVERSION)" == "14.0"
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware_pmv2.manifest
!endif
!if "$(USE_DPI_AWARE_MANIFEST)" == "2" && "$(VISUALSTUDIOVERSION)" == "15.0"
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware_pmv2.manifest
!endif
!if "$(USE_DPI_AWARE_MANIFEST)" == "2" && "$(VISUALSTUDIOVERSION)" == "16.0"
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware_pmv2.manifest
!endif
!if "$(USE_DPI_AWARE_MANIFEST)" == "2" && "$(VISUALSTUDIOVERSION)" == "17.0"
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware_pmv2.manifest
!endif
!if "$(MONOLITHIC)" == "0"
EXTRALIBS_FOR_BASE =
!endif
!if "$(MONOLITHIC)" == "1"
EXTRALIBS_FOR_BASE =
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_2 = $(__DEBUGRUNTIME_1)
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_2 =
!endif
!if "$(DEBUG_INFO)" == "0"
__DEBUGINFO_2 =
!endif
!if "$(DEBUG_INFO)" == "1"
__DEBUGINFO_2 = $(__DEBUGRUNTIME_1)
!endif
!if "$(RUNTIME_LIBS)" == "dynamic"
__RUNTIME_LIBS_10 = D
!endif
!if "$(RUNTIME_LIBS)" == "static"
__RUNTIME_LIBS_10 = $(__THREADSFLAG)
!endif
!if "$(MONOLITHIC)" == "0"
__WXLIB_NET_p = \
wxbase$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net.lib
!endif
!if "$(MONOLITHIC)" == "1"
__LIB_PNG_IF_MONO_p = $(__LIB_PNG_p)
!endif
!if "$(USE_GUI)" == "1"
__bench_gui___depname = $(OBJS)\bench_gui.exe
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_18 = $(__DEBUGRUNTIME_1)
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_18 =
!endif
!if "$(DEBUG_INFO)" == "0"
__DEBUGINFO_18 =
!endif
!if "$(DEBUG_INFO)" == "1"
__DEBUGINFO_18 = $(__DEBUGRUNTIME_1)
!endif
!if "$(RUNTIME_LIBS)" == "dynamic"
__RUNTIME_LIBS_26 = D
!endif
!if "$(RUNTIME_LIBS)" == "static"
__RUNTIME_LIBS_26 = $(__THREADSFLAG)
!endif
!if "$(MONOLITHIC)" == "1" && "$(USE_STC)" == "1"
__LIB_LEXILLA_IF_MONO_p = $(__LIB_LEXILLA_p)
!endif
!if "$(USE_GUI)" == "1"
__bench_graphics___depname = $(OBJS)\bench_graphics.exe
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_34 = $(__DEBUGRUNTIME_1)
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_34 =
!endif
!if "$(DEBUG_INFO)" == "0"
__DEBUGINFO_34 =
!endif
!if "$(DEBUG_INFO)" == "1"
__DEBUGINFO_34 = $(__DEBUGRUNTIME_1)
!endif
!if "$(RUNTIME_LIBS)" == "dynamic"
__RUNTIME_LIBS_42 = D
!endif
!if "$(RUNTIME_LIBS)" == "static"
__RUNTIME_LIBS_42 = $(__THREADSFLAG)
!endif
!if "$(MONOLITHIC)" == "1" && "$(USE_STC)" == "1"
__LIB_LEXILLA_IF_MONO_p_1 = $(__LIB_LEXILLA_p)
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO = /Zi
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO =
!endif
!if "$(DEBUG_INFO)" == "0"
__DEBUGINFO =
!endif
!if "$(DEBUG_INFO)" == "1"
__DEBUGINFO = /Zi
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_3 = /DEBUG
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
__DEBUGINFO_3 =
!endif
!if "$(DEBUG_INFO)" == "0"
__DEBUGINFO_3 =
!endif
!if "$(DEBUG_INFO)" == "1"
__DEBUGINFO_3 = /DEBUG
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
____DEBUGRUNTIME = /D_DEBUG
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
____DEBUGRUNTIME =
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
____DEBUGRUNTIME =
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
____DEBUGRUNTIME = /D_DEBUG
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
____DEBUGRUNTIME_0 = /d _DEBUG
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
____DEBUGRUNTIME_0 =
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
____DEBUGRUNTIME_0 =
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
____DEBUGRUNTIME_0 = /d _DEBUG
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
__DEBUGRUNTIME = d
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
__DEBUGRUNTIME =
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
__DEBUGRUNTIME =
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
__DEBUGRUNTIME = d
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
__DEBUGRUNTIME_1 =
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
__DEBUGRUNTIME_1 = /opt:ref /opt:icf
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
__DEBUGRUNTIME_1 = /opt:ref /opt:icf
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
__DEBUGRUNTIME_1 =
!endif
!if "$(BUILD)" == "debug"
__OPTIMIZEFLAG = /Od
!endif
!if "$(BUILD)" == "release"
__OPTIMIZEFLAG = /O2
!endif
!if "$(USE_THREADS)" == "0"
__THREADSFLAG = L
!endif
!if "$(USE_THREADS)" == "1"
__THREADSFLAG = T
!endif
!if "$(USE_RTTI)" == "0"
__RTTIFLAG = /GR-
!endif
!if "$(USE_RTTI)" == "1"
__RTTIFLAG = /GR
!endif
!if "$(USE_EXCEPTIONS)" == "0"
__EXCEPTIONSFLAG =
!endif
!if "$(USE_EXCEPTIONS)" == "1"
__EXCEPTIONSFLAG = /EHsc
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
__NO_VC_CRTDBG_p = /D__NO_VC_CRTDBG__
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_FLAG)" == "1"
__NO_VC_CRTDBG_p = /D__NO_VC_CRTDBG__
!endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
__NO_VC_CRTDBG_p_0 = /d __NO_VC_CRTDBG__
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_FLAG)" == "1"
__NO_VC_CRTDBG_p_0 = /d __NO_VC_CRTDBG__
!endif
!if "$(TARGET_CPU)" == ""
__TARGET_CPU_COMPFLAG_p = /DTARGET_CPU_COMPFLAG=0
!endif
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "X64"
__TARGET_CPU_COMPFLAG_p =
!endif
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "x64"
__TARGET_CPU_COMPFLAG_p =
!endif
!if "$(TARGET_CPU)" == ""
__TARGET_CPU_COMPFLAG_p_0 = /d TARGET_CPU_COMPFLAG=0
!endif
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "X64"
__TARGET_CPU_COMPFLAG_p_0 =
!endif
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "x64"
__TARGET_CPU_COMPFLAG_p_0 =
!endif
!if "$(WXUNIV)" == "1"
__WXUNIV_DEFINE_p = /D__WXUNIVERSAL__
!endif
!if "$(WXUNIV)" == "1"
__WXUNIV_DEFINE_p_0 = /d __WXUNIVERSAL__
!endif
!if "$(DEBUG_FLAG)" == "0"
__DEBUG_DEFINE_p = /DwxDEBUG_LEVEL=0
!endif
!if "$(DEBUG_FLAG)" == "0"
__DEBUG_DEFINE_p_0 = /d wxDEBUG_LEVEL=0
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
__NDEBUG_DEFINE_p = /DNDEBUG
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
__NDEBUG_DEFINE_p = /DNDEBUG
!endif
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
__NDEBUG_DEFINE_p_0 = /d NDEBUG
!endif
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
__NDEBUG_DEFINE_p_0 = /d NDEBUG
!endif
!if "$(USE_EXCEPTIONS)" == "0"
__EXCEPTIONS_DEFINE_p = /DwxNO_EXCEPTIONS
!endif
!if "$(USE_EXCEPTIONS)" == "0"
__EXCEPTIONS_DEFINE_p_0 = /d wxNO_EXCEPTIONS
!endif
!if "$(USE_RTTI)" == "0"
__RTTI_DEFINE_p = /DwxNO_RTTI
!endif
!if "$(USE_RTTI)" == "0"
__RTTI_DEFINE_p_0 = /d wxNO_RTTI
!endif
!if "$(USE_THREADS)" == "0"
__THREAD_DEFINE_p = /DwxNO_THREADS
!endif
!if "$(USE_THREADS)" == "0"
__THREAD_DEFINE_p_0 = /d wxNO_THREADS
!endif
!if "$(USE_CAIRO)" == "1"
____CAIRO_INCLUDEDIR_FILENAMES = /I$(CAIRO_ROOT)\include\cairo
!endif
!if "$(USE_CAIRO)" == "1"
____CAIRO_INCLUDEDIR_FILENAMES_0 = /i $(CAIRO_ROOT)\include\cairo
!endif
!if "$(SHARED)" == "1"
__DLLFLAG_p = /DWXUSINGDLL
!endif
!if "$(SHARED)" == "1"
__DLLFLAG_p_0 = /d WXUSINGDLL
!endif
!if "$(MONOLITHIC)" == "0"
__WXLIB_CORE_p = \
wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core.lib
!endif
!if "$(MONOLITHIC)" == "0"
__WXLIB_BASE_p = \
wxbase$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR).lib
!endif
!if "$(MONOLITHIC)" == "1"
__WXLIB_MONO_p = \
wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR).lib
!endif
!if "$(MONOLITHIC)" == "1" && "$(USE_STC)" == "1"
__LIB_SCINTILLA_IF_MONO_p = wxscintilla$(WXDEBUGFLAG).lib
!endif
!if "$(USE_STC)" == "1"
__LIB_LEXILLA_p = wxlexilla$(WXDEBUGFLAG).lib
!endif
!if "$(USE_GUI)" == "1"
__LIB_TIFF_p = wxtiff$(WXDEBUGFLAG).lib
!endif
!if "$(USE_GUI)" == "1"
__LIB_JPEG_p = wxjpeg$(WXDEBUGFLAG).lib
!endif
!if "$(USE_GUI)" == "1"
__LIB_PNG_p = wxpng$(WXDEBUGFLAG).lib
!endif
!if "$(USE_GUI)" == "1"
__LIB_WEBP_p = wxwebp$(WXDEBUGFLAG).lib
!endif
!if "$(USE_CAIRO)" == "1"
__CAIRO_LIB_p = cairo.lib
!endif
!if "$(USE_CAIRO)" == "1"
____CAIRO_LIBDIR_FILENAMES = /LIBPATH:$(CAIRO_ROOT)\lib
!endif
all: $(OBJS)
$(OBJS):
-if not exist $(OBJS) mkdir $(OBJS)
### Targets: ###
all: $(OBJS)\bench.exe data $(__bench_gui___depname) $(__bench_graphics___depname) data-image
clean:
-if exist $(OBJS)\*.obj del $(OBJS)\*.obj
-if exist $(OBJS)\*.res del $(OBJS)\*.res
-if exist $(OBJS)\*.pch del $(OBJS)\*.pch
-if exist $(OBJS)\bench.exe del $(OBJS)\bench.exe
-if exist $(OBJS)\bench.ilk del $(OBJS)\bench.ilk
-if exist $(OBJS)\bench.pdb del $(OBJS)\bench.pdb
-if exist $(OBJS)\bench_gui.exe del $(OBJS)\bench_gui.exe
-if exist $(OBJS)\bench_gui.ilk del $(OBJS)\bench_gui.ilk
-if exist $(OBJS)\bench_gui.pdb del $(OBJS)\bench_gui.pdb
-if exist $(OBJS)\bench_graphics.exe del $(OBJS)\bench_graphics.exe
-if exist $(OBJS)\bench_graphics.ilk del $(OBJS)\bench_graphics.ilk
-if exist $(OBJS)\bench_graphics.pdb del $(OBJS)\bench_graphics.pdb
$(OBJS)\bench.exe: $(BENCH_OBJECTS)
link /NOLOGO /OUT:$@ $(__DEBUGINFO_3) /pdb:"$(OBJS)\bench.pdb" $(__DEBUGINFO_2) $(LINK_TARGET_CPU) /LIBPATH:$(LIBDIRNAME) /SUBSYSTEM:CONSOLE $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @<<
$(BENCH_OBJECTS) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_PNG_IF_MONO_p) wxzlib$(WXDEBUGFLAG).lib wxregexu$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib gdiplus.lib msimg32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib shlwapi.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib version.lib ws2_32.lib wininet.lib
<<
data:
if not exist $(OBJS) mkdir $(OBJS)
for %f in (htmltest.html) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
!if "$(USE_GUI)" == "1"
$(OBJS)\bench_gui.exe: $(BENCH_GUI_OBJECTS) $(OBJS)\bench_gui_sample.res
link /NOLOGO /OUT:$@ $(__DEBUGINFO_3) /pdb:"$(OBJS)\bench_gui.pdb" $(__DEBUGINFO_18) $(LINK_TARGET_CPU) /LIBPATH:$(LIBDIRNAME) $(WIN32_DPI_LINKFLAG) /SUBSYSTEM:CONSOLE $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @<<
$(BENCH_GUI_OBJECTS) $(BENCH_GUI_RESOURCES) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_LEXILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) wxzlib$(WXDEBUGFLAG).lib wxregexu$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib gdiplus.lib msimg32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib shlwapi.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib version.lib ws2_32.lib wininet.lib
<<
!endif
!if "$(USE_GUI)" == "1"
$(OBJS)\bench_graphics.exe: $(BENCH_GRAPHICS_OBJECTS) $(OBJS)\bench_graphics_sample.res
link /NOLOGO /OUT:$@ $(__DEBUGINFO_3) /pdb:"$(OBJS)\bench_graphics.pdb" $(__DEBUGINFO_34) $(LINK_TARGET_CPU) /LIBPATH:$(LIBDIRNAME) $(WIN32_DPI_LINKFLAG) /SUBSYSTEM:CONSOLE $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @<<
$(BENCH_GRAPHICS_OBJECTS) $(BENCH_GRAPHICS_RESOURCES) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib opengl32.lib $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_LEXILLA_IF_MONO_p_1) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) wxzlib$(WXDEBUGFLAG).lib wxregexu$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib gdiplus.lib msimg32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib shlwapi.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib version.lib ws2_32.lib wininet.lib
<<
!endif
data-image:
if not exist $(OBJS) mkdir $(OBJS)
for %f in (../../samples/image/horse.bmp ../../samples/image/horse.jpg ../../samples/image/horse.png ../../samples/image/horse.tif) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
$(OBJS)\bench_bench.obj: .\bench.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\bench.cpp
$(OBJS)\bench_datetime.obj: .\datetime.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\datetime.cpp
$(OBJS)\bench_htmlpars.obj: .\htmlparser\htmlpars.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\htmlparser\htmlpars.cpp
$(OBJS)\bench_htmltag.obj: .\htmlparser\htmltag.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\htmlparser\htmltag.cpp
$(OBJS)\bench_ipcclient.obj: .\ipcclient.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\ipcclient.cpp
$(OBJS)\bench_log.obj: .\log.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\log.cpp
$(OBJS)\bench_mbconv.obj: .\mbconv.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\mbconv.cpp
$(OBJS)\bench_regex.obj: .\regex.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\regex.cpp
$(OBJS)\bench_strings.obj: .\strings.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\strings.cpp
$(OBJS)\bench_tls.obj: .\tls.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\tls.cpp
$(OBJS)\bench_printfbench.obj: .\printfbench.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\printfbench.cpp
$(OBJS)\bench_gui_sample.res: .\..\..\samples\sample.rc
rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_0) /d _CRT_SECURE_NO_DEPRECATE=1 /d _CRT_NON_CONFORMING_SWPRINTFS=1 /d _SCL_SECURE_NO_WARNINGS=1 $(__NO_VC_CRTDBG_p_0) $(__TARGET_CPU_COMPFLAG_p_0) /d __WXMSW__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__NDEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) /i $(SETUPHDIR) /i .\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES_0) /i . $(__DLLFLAG_p_0) /i .\..\..\samples /d NOPCH /d _CONSOLE .\..\..\samples\sample.rc
$(OBJS)\bench_gui_bench.obj: .\bench.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\bench.cpp
$(OBJS)\bench_gui_display.obj: .\display.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\display.cpp
$(OBJS)\bench_gui_image.obj: .\image.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\image.cpp
$(OBJS)\bench_graphics_sample.res: .\..\..\samples\sample.rc
rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_0) /d _CRT_SECURE_NO_DEPRECATE=1 /d _CRT_NON_CONFORMING_SWPRINTFS=1 /d _SCL_SECURE_NO_WARNINGS=1 $(__NO_VC_CRTDBG_p_0) $(__TARGET_CPU_COMPFLAG_p_0) /d __WXMSW__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__NDEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) /i $(SETUPHDIR) /i .\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES_0) /i . $(__DLLFLAG_p_0) /i .\..\..\samples /d NOPCH /d _CONSOLE .\..\..\samples\sample.rc
$(OBJS)\bench_graphics_graphics.obj: .\graphics.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GRAPHICS_CXXFLAGS) .\graphics.cpp

View File

@@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/mbconv.cpp
// Purpose: MB<->WC conversion benchmarks
// Author: Vadim Zeitlin
// Created: 2008-10-17
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/strconv.h"
#include "wx/string.h"
#include "bench.h"
namespace
{
const wchar_t *TEST_STRING =
L"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"
L"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim"
L"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea"
L"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate"
L"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint"
L"occaecat cupidatat non proident, sunt in culpa qui officia deserunt"
L"mollit anim id est laborum."
;
// just compute the length of the resulting multibyte string
bool ComputeMBLength(const wxMBConv& conv)
{
// we suppose a fixed length encoding here (which happens to cover UTF-8
// too as long as the test string is ASCII)
return conv.FromWChar(nullptr, 0, TEST_STRING)
== (wcslen(TEST_STRING) + 1)*conv.GetMBNulLen();
}
// perform the conversion
bool ConvertToMB(const wxMBConv& conv)
{
const size_t outlen = (wcslen(TEST_STRING) + 1)*conv.GetMBNulLen();
wxCharBuffer buf(outlen - 1); // it adds 1 internally
return conv.FromWChar(buf.data(), outlen, TEST_STRING) == outlen;
}
} // anonymous namespace
BENCHMARK_FUNC(UTF16InitWX)
{
wxMBConvUTF16 conv;
return true;
}
BENCHMARK_FUNC(UTF16InitSys)
{
wxCSConv conv("UTF-16LE");
return conv.IsOk();
}
BENCHMARK_FUNC(UTF16LenWX)
{
return ComputeMBLength(wxMBConvUTF16());
}
BENCHMARK_FUNC(UTF16LenSys)
{
return ComputeMBLength(wxCSConv("UTF-16LE"));
}
BENCHMARK_FUNC(UTF16WX)
{
return ConvertToMB(wxMBConvUTF16());
}
BENCHMARK_FUNC(UTF16Sys)
{
return ConvertToMB(wxCSConv("UTF-16LE"));
}

View File

@@ -0,0 +1,134 @@
/////////////////////////////////////////////////////////////////////////////
// Name: printfbench.cpp
// Purpose: benchmarks for wx*Printf*() functions
// Author: Francesco Montorsi
// Created: 27/3/2006
// Copyright: (c) 2006-2009 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*
TODO: revise the benchmarking functions below to allow valid comparisons
between the wx implementation and the system's implementation of
the tested functions (e.g. adding tests which use the wxS macro to
avoid runtime encoding conversions, etc etc).
*/
//
// Profiling under Linux:
// =====================
//
// 1) configure wxWidgets in release mode
// 2) make sure that HAVE_UNIX98_PRINTF is undefined (just #defining it to zero
// does not work; you must comment out the entire #define) in your setup.h;
// and also that wxUSE_PRINTF_POS_PARAMS is set to 1; this will force the
// use of wx's own implementation of wxVsnprintf()
// 3) compile wx
// 4) set wxTEST_WX_ONLY to 1 and compile tests as well
//
// Now you have two main choices:
//
// - using gprof:
// 5) add to the Makefile of this test program the -pg option both to
// CXXFLAGS and to LDFLAGS
// 6) run the test
// 7) look at the gmon.out file with gprof utility
//
// - using valgrind:
// 4) run "valgrind --tool=callgrind ./printfbench"
// 5) run "kcachegrind dump_file_generated_by_callgrind"
//
#include "wx/string.h"
#include "bench.h"
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
#define BUFSIZE 10000
const wxString g_verylongString =
"very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very "
"very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long string!\n\n\n";
// ----------------------------------------------------------------------------
// benchmarking helpers
// ----------------------------------------------------------------------------
#define DO_LONG_BENCHMARK(fnc, prefix) \
fnc(buffer, BUFSIZE, \
prefix##"This is a reasonably long string with various %s arguments, exactly %d, " \
prefix##"and is used as benchmark for %s - %% %.2f %d %s", \
prefix##"(many!!)", 6, "this program", 23.342f, 999, \
(const char*)g_verylongString.c_str());
#define DO_LONG_POSITIONAL_BENCHMARK(fnc, prefix) \
fnc(buffer, BUFSIZE, \
prefix##"This is a %2$s and thus is harder to parse... let's %1$s " \
prefix##"for our benchmarking aims - %% %3$f %5$d %4$s", \
prefix##"test it", "string with positional arguments", 23.342f, \
(const char*)g_verylongString.c_str(), 999);
#define DO_BENCHMARK(fnc, prefix) \
fnc(buffer, BUFSIZE, prefix##"This is a short %s string with very few words", "test");
#define DO_POSITIONAL_BENCHMARK(fnc, prefix) \
fnc(buffer, BUFSIZE, \
prefix##"This is a %2$s and thus is harder to parse... nonetheless, %1$s !", \
"test it", "string with positional arguments");
// the configure script of wxWidgets will define HAVE_UNIX98_PRINTF on those
// system with a *printf() family of functions conformant to Unix 98 standard;
// systems without the configure script as build system (e.g. Windows) do not
// have positional support anyway
#ifdef HAVE_UNIX98_PRINTF
#define wxSYSTEM_HAS_POSPARAM_SUPPORT 1
#else
#define wxSYSTEM_HAS_POSPARAM_SUPPORT 1
#endif
// we need to avoid the use of wxPrintf() here since it could have been mapped
// to wxWidgets' implementation of wxVsnPrintf() !
#define sys_printf swprintf
// ----------------------------------------------------------------------------
// main
// ----------------------------------------------------------------------------
BENCHMARK_FUNC(SnprintfWithPositionals)
{
wxChar buffer[BUFSIZE];
#if wxUSE_PRINTF_POS_PARAMS
DO_LONG_POSITIONAL_BENCHMARK(wxSnprintf, )
DO_POSITIONAL_BENCHMARK(wxSnprintf, )
#endif
return true;
}
BENCHMARK_FUNC(Snprintf)
{
wxChar buffer[BUFSIZE];
DO_LONG_BENCHMARK(wxSnprintf, )
DO_BENCHMARK(wxSnprintf, )
return true;
}
BENCHMARK_FUNC(SystemSnprintfWithPositionals)
{
wxChar buffer[BUFSIZE];
DO_LONG_POSITIONAL_BENCHMARK(sys_printf, L)
DO_POSITIONAL_BENCHMARK(sys_printf, L)
return true;
}
BENCHMARK_FUNC(SystemSnprintf)
{
wxChar buffer[BUFSIZE];
DO_LONG_BENCHMARK(sys_printf, L)
DO_BENCHMARK(sys_printf, L)
return true;
}

View File

@@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/regex.cpp
// Purpose: wxRegEx benchmarks
// Author: Vadim Zeitlin
// Created: 2018-11-15
// Copyright: (c) 2018 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/ffile.h"
#include "wx/regex.h"
#include "bench.h"
// ----------------------------------------------------------------------------
// Benchmark relative costs of compiling and matching for a simple regex
// ----------------------------------------------------------------------------
static const char* const RE_SIMPLE = ".";
BENCHMARK_FUNC(RECompile)
{
return wxRegEx(RE_SIMPLE).IsValid();
}
BENCHMARK_FUNC(REMatch)
{
static wxRegEx re(RE_SIMPLE);
return re.Matches("foo");
}
BENCHMARK_FUNC(RECompileAndMatch)
{
return wxRegEx(RE_SIMPLE).Matches("foo");
}
// ----------------------------------------------------------------------------
// Benchmark the cost of using a more complicated regex
// ----------------------------------------------------------------------------
namespace
{
// Use the contents of an already existing test file.
const wxString& GetTestText()
{
static wxString text;
if ( text.empty() )
{
wxFFile("htmltest.html").ReadAll(&text);
}
return text;
}
} // anonymous namespace
BENCHMARK_FUNC(REFindTD)
{
// This is too simplistic, but good enough for benchmarking.
static wxRegEx re("<td>[^<]*</td>", wxRE_ICASE | wxRE_NEWLINE);
int matches = 0;
for ( const wxChar* p = GetTestText().c_str(); re.Matches(p); ++matches )
{
size_t start, len;
if ( !re.GetMatch(&start, &len) )
return false;
p += start + len;
}
return matches == 21; // result of "grep -c"
}

View File

@@ -0,0 +1,770 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/strings.cpp
// Purpose: String-related benchmarks
// Author: Vadim Zeitlin
// Created: 2008-07-19
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/string.h"
#include "wx/ffile.h"
#include "wx/arrstr.h"
#include "bench.h"
#include "htmlparser/htmlpars.h"
static const char asciistr[] =
"This is just the first line of a very long 7 bit ASCII string"
"This is just the second line of a very long 7 bit ASCII string"
"This is just the third line of a very long 7 bit ASCII string"
"This is just the fourth line of a very long 7 bit ASCII string"
"This is just the fifth line of a very long 7 bit ASCII string"
"This is just the sixth line of a very long 7 bit ASCII string"
"This is just the seventh line of a very long 7 bit ASCII string"
"This is just the eighth line of a very long 7 bit ASCII string"
"This is just the ninth line of a very long 7 bit ASCII string"
"This is just the tenth line of a very long 7 bit ASCII string"
;
static const char utf8str[] =
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 0"
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 1"
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 2"
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 3"
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 4"
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 5"
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 6"
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 7"
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 8"
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 9"
;
namespace
{
const wxString& GetTestAsciiString()
{
static wxString testString;
if ( testString.empty() )
{
long num = Bench::GetNumericParameter();
if ( !num )
num = 1;
for ( long n = 0; n < num; n++ )
testString += wxString::FromAscii(asciistr);
}
return testString;
}
} // anonymous namespace
// this is just a baseline
BENCHMARK_FUNC(Strlen)
{
if ( strlen(utf8str) != WXSIZEOF(utf8str) - 1 )
return false;
if ( strlen(asciistr) != WXSIZEOF(asciistr) - 1 )
return false;
return true;
}
// ----------------------------------------------------------------------------
// FromUTF8() benchmarks
// ----------------------------------------------------------------------------
BENCHMARK_FUNC(FromUTF8)
{
wxString s = wxString::FromUTF8(utf8str);
if ( s.empty() )
return false;
s = wxString::FromUTF8(asciistr);
if ( s.empty() )
return false;
return true;
}
BENCHMARK_FUNC(FromUTF8WithNpos)
{
wxString s = wxString::FromUTF8(utf8str, wxString::npos);
if ( s.empty() )
return false;
s = wxString::FromUTF8(asciistr, wxString::npos);
if ( s.empty() )
return false;
return true;
}
BENCHMARK_FUNC(FromUTF8WithLen)
{
wxString s = wxString::FromUTF8(utf8str, WXSIZEOF(utf8str));
if ( s.empty() )
return false;
s = wxString::FromUTF8(asciistr, WXSIZEOF(asciistr));
if ( s.empty() )
return false;
return true;
}
// ----------------------------------------------------------------------------
// FromUTF8Unchecked() benchmarks
// ----------------------------------------------------------------------------
BENCHMARK_FUNC(FromUTF8Unchecked)
{
wxString s = wxString::FromUTF8Unchecked(utf8str);
if ( s.empty() )
return false;
s = wxString::FromUTF8Unchecked(asciistr);
if ( s.empty() )
return false;
return true;
}
BENCHMARK_FUNC(FromUTF8UncheckedWithNpos)
{
wxString s = wxString::FromUTF8Unchecked(utf8str, wxString::npos);
if ( s.empty() )
return false;
s = wxString::FromUTF8Unchecked(asciistr, wxString::npos);
if ( s.empty() )
return false;
return true;
}
BENCHMARK_FUNC(FromUTF8UncheckedWithLen)
{
wxString s = wxString::FromUTF8Unchecked(utf8str, WXSIZEOF(utf8str));
if ( s.empty() )
return false;
s = wxString::FromUTF8Unchecked(asciistr, WXSIZEOF(asciistr));
if ( s.empty() )
return false;
return true;
}
// ----------------------------------------------------------------------------
// FromAscii() benchmarks
// ----------------------------------------------------------------------------
BENCHMARK_FUNC(FromAscii)
{
wxString s = wxString::FromAscii(asciistr);
if ( s.empty() )
return false;
return true;
}
BENCHMARK_FUNC(FromAsciiWithNpos)
{
wxString s = wxString::FromAscii(asciistr);
if ( s.empty() )
return false;
return true;
}
BENCHMARK_FUNC(FromAsciiWithLen)
{
wxString s = wxString::FromAscii(asciistr, WXSIZEOF(asciistr));
if ( s.empty() )
return false;
return true;
}
// ----------------------------------------------------------------------------
// simple string iteration
// ----------------------------------------------------------------------------
// baseline
BENCHMARK_FUNC(ForCString)
{
for ( size_t n = 0; n < WXSIZEOF(asciistr); n++ )
{
if ( asciistr[n] == '~' )
return false;
}
return true;
}
BENCHMARK_FUNC(ForStringIndex)
{
const wxString& s = GetTestAsciiString();
const size_t len = s.length();
for ( size_t n = 0; n < len; n++ )
{
if ( s[n] == '~' )
return false;
}
return true;
}
BENCHMARK_FUNC(ForStringIter)
{
const wxString& s = GetTestAsciiString();
const wxString::const_iterator end = s.end();
for ( wxString::const_iterator i = s.begin(); i != end; ++i )
{
if ( *i == '~' )
return false;
}
return true;
}
BENCHMARK_FUNC(ForStringRIter)
{
const wxString& s = GetTestAsciiString();
const wxString::const_reverse_iterator rend = s.rend();
for ( wxString::const_reverse_iterator i = s.rbegin(); i != rend; ++i )
{
if ( *i == '~' )
return false;
}
return true;
}
// ----------------------------------------------------------------------------
// wxString::Replace()
// ----------------------------------------------------------------------------
const size_t ASCIISTR_LEN = strlen(asciistr);
BENCHMARK_FUNC(ReplaceLoop)
{
wxString str('x', ASCIISTR_LEN);
for ( size_t n = 0; n < ASCIISTR_LEN; n++ )
{
if ( str[n] == 'a' )
str[n] = 'z';
}
return str.length() != 0;
}
BENCHMARK_FUNC(ReplaceNone)
{
wxString str('x', ASCIISTR_LEN);
return str.Replace("a", "z") == 0;
}
BENCHMARK_FUNC(ReplaceSome)
{
wxString str(asciistr);
return str.Replace("7", "8") != 0;
}
BENCHMARK_FUNC(ReplaceAll)
{
wxString str('x', ASCIISTR_LEN);
return str.Replace("x", "y") != 0;
}
BENCHMARK_FUNC(ReplaceLonger)
{
wxString str('x', ASCIISTR_LEN);
return str.Replace("x", "yy") != 0;
}
BENCHMARK_FUNC(ReplaceShorter)
{
wxString str('x', ASCIISTR_LEN);
return str.Replace("xx", "y") != 0;
}
// ----------------------------------------------------------------------------
// string arrays
// ----------------------------------------------------------------------------
BENCHMARK_FUNC(ArrStrPushBack)
{
wxArrayString a;
for (int i = 0; i < 100; ++i)
{
a.push_back(wxString(asciistr));
a.push_back(wxString(utf8str));
}
return !a.empty();
}
BENCHMARK_FUNC(ArrStrInsert)
{
wxArrayString a;
for (int i = 0; i < 100; ++i)
{
a.insert(a.begin(), wxString(asciistr));
a.insert(a.begin(), wxString(utf8str));
}
return !a.empty();
}
BENCHMARK_FUNC(ArrStrSort)
{
wxArrayString a;
a.reserve(100);
for (int i = 0; i < 100; ++i)
a.push_back(wxString(asciistr + i));
a.Sort();
return !a.empty();
}
BENCHMARK_FUNC(VectorStrPushBack)
{
std::vector<wxString> v;
for (int i = 0; i < 100; ++i)
{
v.push_back(wxString(asciistr));
v.push_back(wxString(utf8str));
}
return !v.empty();
}
BENCHMARK_FUNC(VectorStrInsert)
{
std::vector<wxString> v;
for (int i = 0; i < 100; ++i)
{
v.insert(v.begin(), wxString(asciistr));
v.insert(v.begin(), wxString(utf8str));
}
return !v.empty();
}
BENCHMARK_FUNC(VectorStrSort)
{
std::vector<wxString> v;
v.reserve(100);
for (int i = 0; i < 100; ++i)
v.push_back(wxString(asciistr + i));
std::sort(v.begin(), v.end());
return !v.empty();
}
// ----------------------------------------------------------------------------
// string case conversion
// ----------------------------------------------------------------------------
BENCHMARK_FUNC(Lower)
{
return GetTestAsciiString().Lower().length() > 0;
}
BENCHMARK_FUNC(Upper)
{
return GetTestAsciiString().Upper().length() > 0;
}
// ----------------------------------------------------------------------------
// string comparison
// ----------------------------------------------------------------------------
BENCHMARK_FUNC(StrcmpA)
{
const wxString& s = GetTestAsciiString();
return wxCRT_StrcmpA(s.c_str(), s.c_str()) == 0;
}
BENCHMARK_FUNC(StrcmpW)
{
const wxString& s = GetTestAsciiString();
return wxCRT_StrcmpW(s.wc_str(), s.wc_str()) == 0;
}
BENCHMARK_FUNC(StricmpA)
{
const wxString& s = GetTestAsciiString();
return wxCRT_StricmpA(s.c_str(), s.c_str()) == 0;
}
BENCHMARK_FUNC(StricmpW)
{
const wxString& s = GetTestAsciiString();
return wxCRT_StricmpW(s.wc_str(), s.wc_str()) == 0;
}
BENCHMARK_FUNC(StringCmp)
{
const wxString& s = GetTestAsciiString();
return s.Cmp(s) == 0;
}
BENCHMARK_FUNC(StringCmpNoCase)
{
const wxString& s = GetTestAsciiString();
return s.CmpNoCase(s) == 0;
}
// Also benchmark various native functions under MSW. Surprisingly/annoyingly
// they sometimes have vastly better performance than alternatives, especially
// for case-sensitive comparison (see #10375).
#ifdef __WINDOWS__
#include "wx/msw/wrapwin.h"
BENCHMARK_FUNC(MSWlstrcmp)
{
const wxString& s = GetTestAsciiString();
return lstrcmp(s.t_str(), s.t_str()) == 0;
}
BENCHMARK_FUNC(MSWlstrcmpi)
{
const wxString& s = GetTestAsciiString();
return lstrcmpi(s.t_str(), s.t_str()) == 0;
}
BENCHMARK_FUNC(MSWCompareString)
{
const wxString& s = GetTestAsciiString();
return ::CompareString
(
LOCALE_USER_DEFAULT,
0,
s.t_str(), s.length(),
s.t_str(), s.length()
) == CSTR_EQUAL;
}
BENCHMARK_FUNC(MSWCompareStringIgnoreCase)
{
const wxString& s = GetTestAsciiString();
return ::CompareString
(
LOCALE_USER_DEFAULT,
NORM_IGNORECASE,
s.t_str(), s.length(),
s.t_str(), s.length()
) == CSTR_EQUAL;
}
#endif // __WINDOWS__
// ----------------------------------------------------------------------------
// string buffers: wx[W]CharBuffer
// ----------------------------------------------------------------------------
BENCHMARK_FUNC(CharBuffer)
{
wxString str(asciistr);
// NB: wxStrlen() is here to simulate some use of the returned buffer.
// Both mb_str() and wc_str() are used so that this code does something
// nontrivial in any build.
return wxStrlen(str.mb_str()) == ASCIISTR_LEN &&
wxStrlen(str.wc_str()) == ASCIISTR_LEN;
}
// ----------------------------------------------------------------------------
// wxString::operator[] - parse large HTML page
// ----------------------------------------------------------------------------
class DummyParser : public wx28HtmlParser
{
public:
virtual wxObject* GetProduct() { return nullptr; }
virtual void AddText(const wxChar*) {}
};
BENCHMARK_FUNC(ParseHTML)
{
// static so that construction time is not counted
static DummyParser parser;
static wxString html;
if ( html.empty() )
{
wxString html1;
wxFFile("htmltest.html").ReadAll(&html1, wxConvUTF8);
// this is going to make for some invalid HTML, of course, but it
// doesn't really matter
long num = Bench::GetNumericParameter();
if ( !num )
num = 1;
for ( long n = 0; n < num; n++ )
html += html1;
}
parser.Parse(html);
return true;
}
// ----------------------------------------------------------------------------
// conversions between strings and numbers
// ----------------------------------------------------------------------------
namespace
{
const struct ToDoubleData
{
const char *str;
double value;
bool ok;
} toDoubleData[] =
{
{ "1", 1, true },
{ "1.23", 1.23, true },
{ ".1", .1, true },
{ "1.", 1, true },
{ "1..", 0, false },
{ "0", 0, true },
{ "a", 0, false },
{ "12345", 12345, true },
{ "-1", -1, true },
{ "--1", 0, false },
{ "-3E-5", -3E-5, true },
{ "-3E-abcde5", 0, false },
};
const struct FromDoubleData
{
double value;
int prec;
const char *str;
} fromDoubleData[] =
{
{ 1.23, -1, "1.23" },
{ -0.45678, -1, "-0.45678" },
{ 1.2345678, 0, "1" },
{ 1.2345678, 1, "1.2" },
{ 1.2345678, 2, "1.23" },
{ 1.2345678, 3, "1.235" },
};
} // anonymous namespace
BENCHMARK_FUNC(StringToDouble)
{
double d = 0.;
for ( const auto& data : toDoubleData )
{
if ( wxString(data.str).ToDouble(&d) != data.ok )
return false;
if ( data.ok && d != data.value )
return false;
}
return true;
}
BENCHMARK_FUNC(StringToCDouble)
{
double d = 0.;
for ( const auto& data : toDoubleData )
{
if ( wxString(data.str).ToCDouble(&d) != data.ok )
return false;
if ( data.ok && d != data.value )
return false;
}
return true;
}
BENCHMARK_FUNC(StringFromDouble)
{
for ( const auto& data : fromDoubleData )
{
const wxString& s = wxString::FromDouble(data.value, data.prec);
if ( wxStrcmp(s.utf8_str(), data.str) != 0 )
return false;
}
return true;
}
BENCHMARK_FUNC(StringFromCDouble)
{
for ( const auto& data : fromDoubleData )
{
const wxString& s = wxString::FromCDouble(data.value, data.prec);
if ( wxStrcmp(s.utf8_str(), data.str) != 0 )
return false;
}
return true;
}
BENCHMARK_FUNC(Strtod)
{
double d = 0.;
char* end = nullptr;
for ( const auto& data : toDoubleData )
{
d = strtod(data.str, &end);
if ( (end && *end == '\0') != data.ok )
return false;
if ( data.ok && d != data.value )
return false;
}
return true;
}
BENCHMARK_FUNC(PrintfDouble)
{
char buf[64];
for ( const auto& data : fromDoubleData )
{
if ( data.prec == -1 )
{
if ( !snprintf(buf, sizeof(buf), "%g", data.value) )
return false;
}
else
{
if ( !snprintf(buf, sizeof(buf), "%.*f", data.prec, data.value) )
return false;
}
if ( strcmp(buf, data.str) != 0 )
return false;
}
return true;
}
BENCHMARK_FUNC(AppendString)
{
static wxString s;
long num = Bench::GetNumericParameter();
if ( !num )
num = 1;
s.clear();
for ( int n = 0; n < num; n++ )
{
s << wxS("123");
}
return true;
}
BENCHMARK_FUNC(AppendIntDirect)
{
static wxString s;
long num = Bench::GetNumericParameter();
if ( !num )
num = 1;
s.clear();
for ( int n = 0; n < num; n++ )
{
s << n;
}
return true;
}
BENCHMARK_FUNC(AppendIntViaString)
{
static wxString s;
long num = Bench::GetNumericParameter();
if ( !num )
num = 1;
s.clear();
for ( int n = 0; n < num; n++ )
{
#if wxUSE_UNICODE_WCHAR
s << std::to_wstring(n);
#else
s << std::to_string(n);
#endif
}
return true;
}
#if wxHAS_CXX17_INCLUDE(<charconv>)
#include <charconv>
#ifdef __cpp_lib_to_chars
BENCHMARK_FUNC(StdFromChars)
{
double d = 0.;
for ( const auto& data : toDoubleData )
{
const auto end = data.str + strlen(data.str);
const auto res = std::from_chars(data.str, end, d);
if ( (res.ptr == end && res.ec == std::errc{}) != data.ok )
return false;
if ( data.ok && d != data.value )
return false;
}
return true;
}
BENCHMARK_FUNC(StdToChars)
{
char buf[64];
std::to_chars_result res;
for ( const auto& data : fromDoubleData )
{
if ( data.prec == -1 )
{
res = std::to_chars(buf, buf + sizeof(buf), data.value);
}
else
{
res = std::to_chars(buf, buf + sizeof(buf), data.value,
std::chars_format::fixed, data.prec);
}
if ( res.ec != std::errc{} )
return false;
*res.ptr = '\0';
if ( strcmp(buf, data.str) != 0 )
return false;
}
return true;
}
#endif // __cpp_lib_to_chars
#endif // wxHAS_CXX17_INCLUDE(<charconv>)

View File

@@ -0,0 +1,189 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/strings.cpp
// Purpose: String-related benchmarks
// Author: Vadim Zeitlin
// Created: 2008-07-19
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "bench.h"
#include "wx/tls.h"
#if defined(__UNIX__)
#define HAVE_PTHREAD
#include <pthread.h>
#elif defined(__WIN32__)
#define HAVE_WIN32_THREAD
#include "wx/msw/wrapwin.h"
#endif
#ifdef __GNUC__
#define HAVE_COMPILER_THREAD
#define wxTHREAD_SPECIFIC __thread
#elif defined(__VISUALC__)
#define HAVE_COMPILER_THREAD
#define wxTHREAD_SPECIFIC __declspec(thread)
#endif
// uncomment this to also test Boost version (you will also need to link with
// libboost_threads)
//#define HAVE_BOOST_THREAD
#ifdef HAVE_BOOST_THREAD
#include <boost/thread/tss.hpp>
#endif
static const int NUM_ITER = 1000;
// this is just a baseline
BENCHMARK_FUNC(DummyTLS)
{
static int s_global = 0;
for ( int n = 0; n < NUM_ITER; n++ )
{
if ( n % 2 )
s_global = 0;
else
s_global = n;
}
return !s_global;
}
#ifdef HAVE_COMPILER_THREAD
BENCHMARK_FUNC(CompilerTLS)
{
static wxTHREAD_SPECIFIC int s_global = 0;
for ( int n = 0; n < NUM_ITER; n++ )
{
if ( n % 2 )
s_global = 0;
else
s_global = n;
}
return !s_global;
}
#endif // HAVE_COMPILER_THREAD
#ifdef HAVE_PTHREAD
class PthreadKey
{
public:
PthreadKey()
{
pthread_key_create(&m_key, nullptr);
}
~PthreadKey()
{
pthread_key_delete(m_key);
}
operator pthread_key_t() const { return m_key; }
private:
pthread_key_t m_key;
wxDECLARE_NO_COPY_CLASS(PthreadKey);
};
BENCHMARK_FUNC(PosixTLS)
{
static PthreadKey s_key;
for ( int n = 0; n < NUM_ITER; n++ )
{
if ( n % 2 )
pthread_setspecific(s_key, 0);
else
pthread_setspecific(s_key, &n);
}
return !pthread_getspecific(s_key);
}
#endif // HAVE_PTHREAD
#ifdef HAVE_WIN32_THREAD
class TlsSlot
{
public:
TlsSlot()
{
m_slot = ::TlsAlloc();
}
~TlsSlot()
{
::TlsFree(m_slot);
}
operator DWORD() const { return m_slot; }
private:
DWORD m_slot;
wxDECLARE_NO_COPY_CLASS(TlsSlot);
};
BENCHMARK_FUNC(Win32TLS)
{
static TlsSlot s_slot;
for ( int n = 0; n < NUM_ITER; n++ )
{
if ( n % 2 )
::TlsSetValue(s_slot, 0);
else
::TlsSetValue(s_slot, &n);
}
return !::TlsGetValue(s_slot);
}
#endif // HAVE_WIN32_THREAD
#ifdef HAVE_BOOST_THREAD
BENCHMARK_FUNC(BoostTLS)
{
static boost::thread_specific_ptr<int> s_ptr;
if ( !s_ptr.get() )
s_ptr.reset(new int(0));
for ( int n = 0; n < NUM_ITER; n++ )
{
if ( n % 2 )
*s_ptr = 0;
else
*s_ptr = n;
}
return !*s_ptr;
}
#endif // HAVE_BOOST_THREAD
BENCHMARK_FUNC(wxTLS)
{
static wxTHREAD_SPECIFIC_DECL int s_global;
for ( int n = 0; n < NUM_ITER; n++ )
{
if ( n % 2 )
s_global = 0;
else
s_global = n;
}
return !s_global;
}