-
Notifications
You must be signed in to change notification settings - Fork 144
[winrt support] Disabling usage of some banned APIs for the Windows Runtime #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cfc1c9a
6ca0868
88a2ece
81ea5a4
212fdb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| // Boost | ||
| #include <boost/cstdlib.hpp> // for exit codes | ||
| #include <boost/config.hpp> // for workarounds | ||
| #include <boost/predef/platform.h> | ||
|
|
||
| // STL | ||
| #include <iostream> | ||
|
|
@@ -69,7 +70,11 @@ prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char | |
| int result = 0; | ||
|
|
||
| try { | ||
| boost::unit_test::const_string p( std::getenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS" ) ); | ||
| boost::unit_test::const_string p; | ||
| #if BOOST_PLAT_WINDOWS_DESKTOP | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be to enable the functionality on all platforms except the ones that do not support the environment variables (CE + winRT). What do you think? |
||
| p = std::getenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS" ); | ||
| #endif | ||
|
|
||
| ::boost::execution_monitor ex_mon; | ||
|
|
||
| ex_mon.p_catch_system_errors.value = p != "no"; | ||
|
|
@@ -102,7 +107,10 @@ prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char | |
| // like the clutter. Use an environment variable to avoid command | ||
| // line argument modifications; for use in production programs | ||
| // that's a no-no in some organizations. | ||
| ::boost::unit_test::const_string p( std::getenv( "BOOST_PRG_MON_CONFIRM" ) ); | ||
| ::boost::unit_test::const_string p; | ||
| #if BOOST_PLAT_WINDOWS_DESKTOP | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (same remark here) |
||
| p = std::getenv( "BOOST_PRG_MON_CONFIRM" ); | ||
| #endif | ||
| if( p != "no" ) { | ||
| std::cerr << std::flush << "no errors detected" << std::endl; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
|
|
||
| #include <boost/test/debug.hpp> | ||
| #include <boost/test/debug_config.hpp> | ||
| #include <boost/predef/platform.h> | ||
|
|
||
| // Implementation on Windows | ||
| #if defined(_WIN32) && !defined(UNDER_CE) && !defined(BOOST_DISABLE_WIN32) // ******* WIN32 | ||
|
|
@@ -30,7 +31,9 @@ | |
|
|
||
| // SYSTEM API | ||
| # include <windows.h> | ||
| # if !BOOST_PLAT_WINDOWS_RUNTIME | ||
| # include <winreg.h> | ||
| # endif | ||
| # include <cstdio> | ||
| # include <cstring> | ||
|
|
||
|
|
@@ -113,6 +116,8 @@ namespace debug { | |
|
|
||
| using unit_test::const_string; | ||
|
|
||
| #ifdef BOOST_TEST_HAS_DEBUG_SUPPORT | ||
|
|
||
| // ************************************************************************** // | ||
| // ************** debug::info_t ************** // | ||
| // ************************************************************************** // | ||
|
|
@@ -913,6 +918,8 @@ attach_debugger( bool break_or_continue ) | |
|
|
||
| //____________________________________________________________________________// | ||
|
|
||
| #endif // BOOST_TEST_HAS_DEBUG_SUPPORT | ||
|
|
||
| // ************************************************************************** // | ||
| // ************** switch on/off detect memory leaks feature ************** // | ||
| // ************************************************************************** // | ||
|
|
@@ -934,8 +941,7 @@ detect_memory_leaks( bool on_off, unit_test::const_string report_file ) | |
| if( report_file.is_empty() ) | ||
| _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); | ||
| else { | ||
| HANDLE hreport_f = ::CreateFileA( report_file.begin(), | ||
| GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); | ||
| HANDLE hreport_f = ::fopen(report_file.begin(), "w"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you changing this? Is the memory leak detection available on winRT? |
||
| _CrtSetReportFile(_CRT_WARN, hreport_f ); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ | |
| #define BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER | ||
|
|
||
| // Boost.Test | ||
|
|
||
| #include <boost/test/unit_test_parameters.hpp> | ||
| #include <boost/test/utils/basic_cstring/basic_cstring.hpp> | ||
| #include <boost/test/utils/basic_cstring/compare.hpp> | ||
|
|
@@ -32,17 +31,9 @@ | |
| #include <boost/test/utils/runtime/cla/dual_name_parameter.hpp> | ||
| #include <boost/test/utils/runtime/cla/parser.hpp> | ||
|
|
||
| namespace rt = boost::runtime; | ||
| namespace cla = rt::cla; | ||
|
|
||
| #ifndef UNDER_CE | ||
| #include <boost/test/utils/runtime/env/variable.hpp> | ||
|
|
||
| namespace env = rt::env; | ||
| #endif | ||
|
|
||
| // Boost | ||
| #include <boost/config.hpp> | ||
| #include <boost/predef/platform.h> | ||
| #include <boost/test/detail/suppress_warnings.hpp> | ||
| #include <boost/lexical_cast.hpp> | ||
| #include <boost/test/detail/enable_warnings.hpp> | ||
|
|
@@ -53,6 +44,17 @@ namespace env = rt::env; | |
| #include <iostream> | ||
| #include <fstream> | ||
|
|
||
| namespace rt = boost::runtime; | ||
| namespace cla = rt::cla; | ||
|
|
||
| #ifndef UNDER_CE | ||
| #if BOOST_PLAT_WINDOWS_DESKTOP | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this last line is erroneous, since we want the environment variable support on eg linux or OSX. Could be replaced by ? |
||
| #include <boost/test/utils/runtime/env/variable.hpp> | ||
|
|
||
| namespace env = rt::env; | ||
| #endif | ||
| #endif | ||
|
|
||
| #include <boost/test/detail/suppress_warnings.hpp> | ||
|
|
||
| //____________________________________________________________________________// | ||
|
|
@@ -244,7 +246,9 @@ retrieve_parameter( const_string parameter_name, cla::parser const& s_cla_parser | |
| boost::optional<T> v; | ||
|
|
||
| #ifndef UNDER_CE | ||
| #if BOOST_PLAT_WINDOWS_DESKTOP | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same remark as for line 74 in file |
||
| env::get( parameter_2_env_var(parameter_name), v ); | ||
| #endif | ||
| #endif | ||
|
|
||
| if( v ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
|
|
||
| // Boost | ||
| #include <boost/config.hpp> | ||
| #include <boost/predef/platform.h> | ||
| #ifdef BOOST_MSVC | ||
| # pragma warning(disable: 4511) // copy constructor could not be generated | ||
| # pragma warning(disable: 4512) // assignment operator could not be generated | ||
|
|
@@ -77,6 +78,7 @@ extern "C" int putenv( const char * ); | |
| #endif | ||
|
|
||
| #ifndef UNDER_CE | ||
| #if BOOST_PLAT_WINDOWS_DESKTOP | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be instead? Could be also replaced by What do you think? |
||
| #if defined(__COMO__) && 0 | ||
| inline void | ||
| putenv_impl( cstring name, cstring value ) | ||
|
|
@@ -100,15 +102,18 @@ putenv_impl( cstring name, cstring value ) | |
| } | ||
| #endif | ||
| #endif | ||
| #endif | ||
|
|
||
| #ifdef BOOST_MSVC | ||
| #pragma warning(pop) | ||
| #endif | ||
|
|
||
| #define BOOST_RT_PARAM_LITERAL( l ) l | ||
| #define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( l, sizeof( l ) - 1 ) | ||
| #if BOOST_PLAT_WINDOWS_DESKTOP | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean ? |
||
| #define BOOST_RT_PARAM_GETENV getenv | ||
| #define BOOST_RT_PARAM_PUTENV ::boost::BOOST_RT_PARAM_NAMESPACE::putenv_impl | ||
| #endif | ||
| #define BOOST_RT_PARAM_EXCEPTION_INHERIT_STD | ||
|
|
||
| //____________________________________________________________________________// | ||
|
|
@@ -123,6 +128,7 @@ typedef wrap_wstringstream format_stream; | |
| typedef std::wostream out_stream; | ||
|
|
||
| #ifndef UNDER_CE | ||
| #if BOOST_PLAT_WINDOWS_DESKTOP | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same remark as line 81 here |
||
| inline void | ||
| putenv_impl( cstring name, cstring value ) | ||
| { | ||
|
|
@@ -136,11 +142,14 @@ putenv_impl( cstring name, cstring value ) | |
| wputenv( const_cast<wchar_t*>( fs.str().c_str() ) ); | ||
| } | ||
| #endif | ||
| #endif | ||
|
|
||
| #define BOOST_RT_PARAM_LITERAL( l ) L ## l | ||
| #define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( L ## l, sizeof( L ## l )/sizeof(wchar_t) - 1 ) | ||
| #if BOOST_PLAT_WINDOWS_DESKTOP | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same remark as line 121 here |
||
| #define BOOST_RT_PARAM_GETENV wgetenv | ||
| #define BOOST_RT_PARAM_PUTENV putenv_impl | ||
| #endif | ||
|
|
||
| # endif | ||
| #endif | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to add definitions like
and then to propagate these macros in the code, like in
cpp_main.cpp