Correct Windows unicode build issues.
This commit is contained in:
parent
b04e01cda7
commit
3bdd79a3fd
@ -89,9 +89,45 @@ namespace chaiscript
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
std::string GetErrorMessage(DWORD err)
|
|
||||||
|
struct Loadable_Module
|
||||||
{
|
{
|
||||||
LPSTR lpMsgBuf = 0;
|
template<typename T>
|
||||||
|
static std::wstring towstring(const T &str)
|
||||||
|
{
|
||||||
|
return std::wstring(str.begin(), str.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static std::string tostring(const T &str)
|
||||||
|
{
|
||||||
|
return std::string(str.begin(), str.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
template<typename T>
|
||||||
|
static std::wstring toproperstring(const T &str)
|
||||||
|
{
|
||||||
|
return towstring(str);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
template<typename T>
|
||||||
|
static std::string toproperstring(const T &str)
|
||||||
|
{
|
||||||
|
return tostring(str);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static std::string GetErrorMessage(DWORD err)
|
||||||
|
{
|
||||||
|
#ifdef _UNICODE
|
||||||
|
typedef LPWSTR StringType;
|
||||||
|
std::wstring retval = L"Unknown Error";
|
||||||
|
#else
|
||||||
|
typedef LPSTR StringType;
|
||||||
|
std::string retval = "Unknown Error";
|
||||||
|
#endif
|
||||||
|
StringType lpMsgBuf = 0;
|
||||||
|
|
||||||
FormatMessage(
|
FormatMessage(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
@ -100,28 +136,22 @@ namespace chaiscript
|
|||||||
NULL,
|
NULL,
|
||||||
err,
|
err,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
(LPSTR)&lpMsgBuf,
|
(StringType)&lpMsgBuf,
|
||||||
0, NULL );
|
0, NULL );
|
||||||
|
|
||||||
std::string retval;
|
|
||||||
|
|
||||||
if (lpMsgBuf)
|
if (lpMsgBuf)
|
||||||
{
|
{
|
||||||
retval = lpMsgBuf;
|
retval = lpMsgBuf;
|
||||||
} else {
|
|
||||||
retval = "Unknown error occured";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
return retval;
|
return tostring(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Loadable_Module
|
|
||||||
{
|
|
||||||
struct DLModule
|
struct DLModule
|
||||||
{
|
{
|
||||||
DLModule(const std::string &t_filename)
|
DLModule(const std::string &t_filename)
|
||||||
: m_data(LoadLibrary(t_filename.c_str()))
|
: m_data(LoadLibrary(toproperstring(t_filename).c_str()))
|
||||||
{
|
{
|
||||||
if (!m_data)
|
if (!m_data)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="C:\Programming\chaiscript\trunk\include"
|
AdditionalIncludeDirectories=""$(ProjectDir)\..\..\include""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@ -117,6 +117,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="2"
|
Optimization="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
|
AdditionalIncludeDirectories=""$(ProjectDir)\..\..\include""
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
InheritedPropertySheets=".\Boost.vsprops"
|
InheritedPropertySheets=".\Boost.vsprops"
|
||||||
UseOfMFC="2"
|
UseOfMFC="2"
|
||||||
CharacterSet="0"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
@ -100,7 +100,7 @@
|
|||||||
IntermediateDirectory="$(ConfigurationName)"
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
InheritedPropertySheets=".\Boost.vsprops"
|
InheritedPropertySheets=".\Boost.vsprops"
|
||||||
CharacterSet="0"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="C:\Programming\chaiscript\trunk\include"
|
AdditionalIncludeDirectories=""$(ProjectDir)\..\..\include""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TEST_MODULE_EXPORTS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TEST_MODULE_EXPORTS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@ -118,6 +118,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="2"
|
Optimization="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
|
AdditionalIncludeDirectories=""$(ProjectDir)\..\..\include""
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TEST_MODULE_EXPORTS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TEST_MODULE_EXPORTS"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
|
@ -149,7 +149,7 @@ int main(int argc, char *argv[]) {
|
|||||||
//Dynamic objects test
|
//Dynamic objects test
|
||||||
chai.add(chaiscript::Proxy_Function(new Dynamic_Object_Function("TestType", fun(&hello_world))), "hello_world");
|
chai.add(chaiscript::Proxy_Function(new Dynamic_Object_Function("TestType", fun(&hello_world))), "hello_world");
|
||||||
chai.add(chaiscript::Proxy_Function(new Dynamic_Object_Constructor("TestType", fun(&hello_constructor))), "TestType");
|
chai.add(chaiscript::Proxy_Function(new Dynamic_Object_Constructor("TestType", fun(&hello_constructor))), "TestType");
|
||||||
chai.add(fun(boost::function<Boxed_Value (Dynamic_Object &)>(boost::bind(&dynamic_object_attribute, "TestType", "attr", _1))), "attr");
|
chai.add(fun(boost::function<Boxed_Value (Dynamic_Object &)>(boost::bind(&Dynamic_Object_Attribute::func, "TestType", "attr", _1))), "attr");
|
||||||
|
|
||||||
chai.eval("var x = TestType()");
|
chai.eval("var x = TestType()");
|
||||||
chai.eval("x.attr = \"hi\"");
|
chai.eval("x.attr = \"hi\"");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user