From ec9b5c982e8a31ff592724eb6400b4438c3da716 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Sat, 9 Jun 2007 02:40:48 +0000 Subject: [PATCH] Replaced Windows SpiderMonkey library with a threadsafe build of version 1.6. Fixed linking with wxWidgets. Enabled RTTI for non-engine packages. Fixed wxJS for Windows. Fixed failure to load on Windows 2000 due to IsWow64Process import. Fixed trivial warnings. This was SVN commit r5155. --- build/premake/premake.lua | 11 +++++++++-- source/gui/scripting/JSInterface_IGUIObject.cpp | 2 +- source/lib/sysdep/win/wutil.cpp | 2 +- source/tools/atlas/AtlasScript/ScriptInterface.cpp | 14 +++++++++----- source/tools/atlas/wxJS/ext/ext_main.cpp | 8 +++++--- source/tools/atlas/wxJS/ext/wxjs_ext.h | 6 +++--- source/tools/atlas/wxJS/gui/gui_main.cpp | 2 ++ source/tools/atlas/wxJS/io/io_main.cpp | 2 ++ source/tools/atlas/wxJS/precompiled.h | 6 ++++++ 9 files changed, 38 insertions(+), 15 deletions(-) diff --git a/build/premake/premake.lua b/build/premake/premake.lua index cee4b383d4..1d3851922b 100755 --- a/build/premake/premake.lua +++ b/build/premake/premake.lua @@ -89,10 +89,10 @@ function package_set_build_flags() -- various platform-specific build flags if OS == "windows" then - tinsert(package.buildflags, "no-rtti") -- use native wchar_t type (not typedef to unsigned short) tinsert(package.buildflags, "native-wchar_t") + else -- *nix if options["icc"] then tinsert(package.buildoptions, { @@ -266,6 +266,10 @@ function setup_static_lib_package (package_name, rel_source_dirs, extern_libs, e tinsert(static_lib_names, package_name) + if OS == "windows" then + tinsert(package.buildflags, "no-rtti") + end + -- Precompiled Headers -- rationale: we need one PCH per static lib, since one global header would -- increase dependencies. To that end, we can either include them as @@ -473,6 +477,8 @@ function setup_main_exe () tinsert(package.files, source_root.."lib/sysdep/win/manifest.rc") end + tinsert(package.buildflags, "no-rtti") + package.linkoptions = { -- wraps main thread in a __try block(see wseh.cpp). replace with mainCRTStartup if that's undesired. "/ENTRY:wseh_EntryPoint", @@ -546,7 +552,7 @@ function setup_atlas_package(package_name, target_type, rel_source_dirs, rel_inc tinsert(package.defines, "_UNICODE") -- Link to required libraries - package.links = { "winmm", "comctl32", "rpcrt4", "delayimp" } + package.links = { "winmm", "comctl32", "rpcrt4", "delayimp", "ws2_32" } -- required to use WinMain() on Windows, otherwise will default to main() tinsert(package.buildflags, "no-main") @@ -588,6 +594,7 @@ function setup_atlas_packages() },{ -- include ".." },{ -- extern_libs + "boost", "spidermonkey", "wxwidgets" },{ -- extra_params diff --git a/source/gui/scripting/JSInterface_IGUIObject.cpp b/source/gui/scripting/JSInterface_IGUIObject.cpp index cb70e8fd2e..095834fe91 100644 --- a/source/gui/scripting/JSInterface_IGUIObject.cpp +++ b/source/gui/scripting/JSInterface_IGUIObject.cpp @@ -249,7 +249,7 @@ JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsval id, jsval { JSString* s = StringConvert::wchars_to_jsstring(cx, value.m_Items[i].GetRawString().c_str()); jsval val = STRING_TO_JSVAL(s); - JS_SetElement(cx, obj, i, &val); + JS_SetElement(cx, obj, (jsint)i, &val); } break; diff --git a/source/lib/sysdep/win/wutil.cpp b/source/lib/sysdep/win/wutil.cpp index 69af4a9c1d..b3caac9066 100644 --- a/source/lib/sysdep/win/wutil.cpp +++ b/source/lib/sysdep/win/wutil.cpp @@ -291,7 +291,7 @@ static void DetectWow64() } BOOL isWow64Process = FALSE; - const BOOL ok = IsWow64Process(GetCurrentProcess(), &isWow64Process); + const BOOL ok = pIsWow64Process(GetCurrentProcess(), &isWow64Process); WARN_IF_FALSE(ok); isWow64 = (isWow64Process == TRUE); } diff --git a/source/tools/atlas/AtlasScript/ScriptInterface.cpp b/source/tools/atlas/AtlasScript/ScriptInterface.cpp index 8807eb4a02..f828f8aa34 100644 --- a/source/tools/atlas/AtlasScript/ScriptInterface.cpp +++ b/source/tools/atlas/AtlasScript/ScriptInterface.cpp @@ -4,6 +4,10 @@ #include "js/jsapi.h" +#ifdef _WIN32 +# pragma warning(disable: 4996) // avoid complaints about deprecated localtime +#endif + #include "wx/wx.h" #include "wxJS/common/main.h" @@ -42,7 +46,7 @@ template<> bool ScriptInterface::FromJSVal(JSContext* cx, jsval v, bool& o { JSBool ret; if (! JS_ValueToBoolean(cx, v, &ret)) return false; - out = ret; + out = (ret ? true : false); return true; } @@ -144,7 +148,7 @@ namespace wxPrintf(_T("wxJS %s: %s\n--------\n"), isWarning ? _T("warning") : _T("error"), logMessage.c_str()); } - JSBool LoadScript(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval) + JSBool LoadScript(JSContext* cx, JSObject* WXUNUSED(obj), uintN WXUNUSED(argc), jsval* argv, jsval* rval) { if (! ( JSVAL_IS_STRING(argv[0]) && JSVAL_IS_STRING(argv[1]) )) return JS_FALSE; @@ -159,7 +163,7 @@ namespace jsval scriptRval; JSBool ok = JS_EvaluateUCScript( - cx, scriptObj, JS_GetStringChars(code), JS_GetStringLength(code), + cx, scriptObj, JS_GetStringChars(code), (uintN)JS_GetStringLength(code), JS_GetStringBytes(name), 1, &scriptRval); if (! ok) return JS_FALSE; @@ -234,7 +238,7 @@ void ScriptInterface_impl::LoadScript(const wxString& filename, const wxString& wxMBConvUTF16 conv; wxCharBuffer codeUTF16 = conv.cWC2MB(code.c_str(), code.length()+1, &codeLength); jsval rval; - JS_EvaluateUCScript(m_cx, m_glob, reinterpret_cast(codeUTF16.data()), codeLength/2, filename.ToAscii(), 1, &rval); + JS_EvaluateUCScript(m_cx, m_glob, reinterpret_cast(codeUTF16.data()), (uintN)(codeLength/2), filename.ToAscii(), 1, &rval); } void ScriptInterface_impl::Register(const char* name, JSNative fptr, uintN nargs) @@ -254,7 +258,7 @@ ScriptInterface::~ScriptInterface() void ScriptInterface::Register(const char* name, JSNative fptr, size_t nargs) { - m->Register(name, fptr, nargs); + m->Register(name, fptr, (uintN)nargs); } void ScriptInterface::LoadScript(const wxString& filename, const wxString& code) diff --git a/source/tools/atlas/wxJS/ext/ext_main.cpp b/source/tools/atlas/wxJS/ext/ext_main.cpp index 9969140ccd..46f60db271 100644 --- a/source/tools/atlas/wxJS/ext/ext_main.cpp +++ b/source/tools/atlas/wxJS/ext/ext_main.cpp @@ -35,6 +35,7 @@ using namespace wxjs; using namespace wxjs::ext; +/* #ifdef __WXMSW__ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { @@ -67,8 +68,9 @@ WXJSAPI bool wxJS_EXTInitClass(JSContext *cx, JSObject *obj) WXJSAPI void wxJS_EXTDestroy() { } +*/ -WXJSAPI JSObject *wxjs::ext::CreateMemoryBuffer(JSContext *cx, void *buffer, int size) +JSObject *wxjs::ext::CreateMemoryBuffer(JSContext *cx, void *buffer, int size) { wxMemoryBuffer *membuf = new wxMemoryBuffer(size); membuf->AppendData(buffer, size); @@ -77,12 +79,12 @@ WXJSAPI JSObject *wxjs::ext::CreateMemoryBuffer(JSContext *cx, void *buffer, int return obj; } -WXJSAPI wxMemoryBuffer* wxjs::ext::GetMemoryBuffer(JSContext *cx, JSObject *obj) +wxMemoryBuffer* wxjs::ext::GetMemoryBuffer(JSContext *cx, JSObject *obj) { return MemoryBuffer::GetPrivate(cx, obj); } -WXJSAPI wxMemoryBuffer* wxjs::ext::NewMemoryBuffer(void *buffer, int size) +wxMemoryBuffer* wxjs::ext::NewMemoryBuffer(void *buffer, int size) { wxMemoryBuffer *membuf = new wxMemoryBuffer(size); membuf->AppendData(buffer, size); diff --git a/source/tools/atlas/wxJS/ext/wxjs_ext.h b/source/tools/atlas/wxJS/ext/wxjs_ext.h index 975725b612..6713928884 100644 --- a/source/tools/atlas/wxJS/ext/wxjs_ext.h +++ b/source/tools/atlas/wxJS/ext/wxjs_ext.h @@ -43,9 +43,9 @@ namespace wxjs { namespace ext { - WXJSAPI wxMemoryBuffer* NewMemoryBuffer(void *buffer, int size); - WXJSAPI JSObject *CreateMemoryBuffer(JSContext *cx, void *buffer, int size); - WXJSAPI wxMemoryBuffer* GetMemoryBuffer(JSContext *cx, JSObject *obj); + wxMemoryBuffer* NewMemoryBuffer(void *buffer, int size); + JSObject *CreateMemoryBuffer(JSContext *cx, void *buffer, int size); + wxMemoryBuffer* GetMemoryBuffer(JSContext *cx, JSObject *obj); }; }; diff --git a/source/tools/atlas/wxJS/gui/gui_main.cpp b/source/tools/atlas/wxJS/gui/gui_main.cpp index 0c1bef91c2..2e81416d8d 100644 --- a/source/tools/atlas/wxJS/gui/gui_main.cpp +++ b/source/tools/atlas/wxJS/gui/gui_main.cpp @@ -42,6 +42,7 @@ #include "init.h" +/* #if defined( __WXMSW__) void WXDLLEXPORT wxEntryCleanup(); extern "C" @@ -89,3 +90,4 @@ WXJSAPI void wxJS_Destroy() { wxjs::gui::Destroy(); } +*/ \ No newline at end of file diff --git a/source/tools/atlas/wxJS/io/io_main.cpp b/source/tools/atlas/wxJS/io/io_main.cpp index 997c64d528..b2bcad2b26 100644 --- a/source/tools/atlas/wxJS/io/io_main.cpp +++ b/source/tools/atlas/wxJS/io/io_main.cpp @@ -44,6 +44,7 @@ class wxJSIOApp : public wxAppConsole virtual int OnRun() { return 0; } }; +/* IMPLEMENT_APP_NO_MAIN(wxJSIOApp) #ifdef __WXMSW__ @@ -86,3 +87,4 @@ WXJSAPI void wxJS_Destroy() { Destroy(); } +*/ \ No newline at end of file diff --git a/source/tools/atlas/wxJS/precompiled.h b/source/tools/atlas/wxJS/precompiled.h index 7078eec30f..8ce0969ffe 100644 --- a/source/tools/atlas/wxJS/precompiled.h +++ b/source/tools/atlas/wxJS/precompiled.h @@ -11,6 +11,12 @@ #define JS_THREADSAFE + +#ifdef _WIN32 +# pragma warning (disable: 4100) // "unreferenced formal parameter" +# pragma warning (disable: 4267 4311 4312) // conversions between ints/pointers/etc +#endif + // Precompiled headers: #ifdef USING_PCH