Просмотр исходного кода

Fix some warnings

- Fix warnings due to Lua wrapper generator
- Fix missing return values in some methods
- Remove unreferenced variables
- Fix call to trackPhysicsChild
Remi Gillig 13 лет назад
Родитель
Сommit
023a413d34

+ 4 - 2
Bindings/Scripts/create_lua_library/create_lua_library.py

@@ -355,6 +355,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 							wrappersHeaderOut += "\t%s *inst = (%s*) *((PolyBase**)lua_touserdata(L, 1));\n" % (ckey, ckey)
 
 							outfunc = "this_shouldnt_happen"
+							outfuncsuffix = ""
 							if pp["type"] == "Number":
 								outfunc = "lua_tonumber"
 							if pp["type"] == "String":
@@ -365,8 +366,9 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 								outfunc = "(PolyKEY)lua_tointeger"
 							if pp["type"] == "bool":
 								outfunc = "lua_toboolean"
+								outfuncsuffix = " != 0"
 
-							wrappersHeaderOut += "\t%s param = %s(L, 2);\n" % (pp["type"], outfunc)
+							wrappersHeaderOut += "\t%s param = %s(L, 2)%s;\n" % (pp["type"], outfunc, outfuncsuffix)
 							wrappersHeaderOut += "\tinst->%s = param;\n" % (pp["name"])
 
 							wrappersHeaderOut += "\treturn 0;\n"
@@ -533,7 +535,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 									luafunc = "lua_toboolean"
 									luatype = "LUA_TBOOLEAN"
 									checkfunc = "lua_isboolean"
-									luafuncsuffix = ""
+									luafuncsuffix = " != 0"
 									lend = ""
 								if param["type"] == "Number" or param["type"] == "float" or param["type"] == "double":
 									luatype = "LUA_TNUMBER"

+ 187 - 190
Core/Contents/PolycodeView/MSVC/PolycodeView.cpp

@@ -1,192 +1,189 @@
-
-#include "PolycodeView.h"
-#include "PolyWinCore.h"
-#include "PolyCoreServices.h"
-#include "PolyCoreInput.h"
-#include "PolyRenderer.h"
-#include <io.h>
+
+#include "PolycodeView.h"
+#include "PolyWinCore.h"
+#include "PolyCoreServices.h"
+#include "PolyCoreInput.h"
+#include "PolyRenderer.h"
+#include <io.h>
 #include <fcntl.h>
-#include <ios>
-
-using namespace Polycode;
-
-Win32Core *core = NULL;
-
-
-static void OpenConsole()
-{
-    int outHandle, errHandle, inHandle;
-    FILE *outFile, *errFile, *inFile;
-    AllocConsole();
-    CONSOLE_SCREEN_BUFFER_INFO coninfo;
-    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
-    coninfo.dwSize.Y = 9999;
-    SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
-
-    outHandle = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
-    errHandle = _open_osfhandle((long)GetStdHandle(STD_ERROR_HANDLE),_O_TEXT);
-    inHandle = _open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE),_O_TEXT );
-
-    outFile = _fdopen(outHandle, "w" );
-    errFile = _fdopen(errHandle, "w");
-    inFile =  _fdopen(inHandle, "r");
-
-    *stdout = *outFile;
-    *stderr = *errFile;
-    *stdin = *inFile;
-
-    setvbuf( stdout, NULL, _IONBF, 0 );
-    setvbuf( stderr, NULL, _IONBF, 0 );
-    setvbuf( stdin, NULL, _IONBF, 0 );
-
-    std::ios::sync_with_stdio();
-
-}
-
-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
-	int wmId, wmEvent;
-	PAINTSTRUCT ps;
-	HDC hdc;		
-	int nWidth, nHeight;
-	bool useDefault = false;
-
-	if(!core)
-		return DefWindowProc(hWnd, message, wParam, lParam);
-
-	switch (message)
-	{
-	case WM_SIZE:
-		nWidth = LOWORD(lParam); 
-		nHeight = HIWORD(lParam);
-		if(core) {
-			core->handleViewResize(nWidth, nHeight);
-		}
-	break;
-
-	case WM_MOUSEMOVE:
-		if(core)
-			core->handleMouseMove(lParam,wParam);
-	break;
-
-	case WM_MOUSEWHEEL:
-		if(core)
-			core->handleMouseWheel(lParam,wParam);
-	break;
-
-	case WM_LBUTTONDOWN:
-		if(core)
-			core->handleMouseDown(CoreInput::MOUSE_BUTTON1, lParam,wParam);
-	break;
-	case WM_LBUTTONUP:
-		if(core)
-			core->handleMouseUp(CoreInput::MOUSE_BUTTON1, lParam,wParam);
-	break;
-
-	case WM_RBUTTONDOWN:
-		if(core)
-			core->handleMouseDown(CoreInput::MOUSE_BUTTON2, lParam,wParam);
-	break;
-	case WM_RBUTTONUP:
-		if(core)
-			core->handleMouseUp(CoreInput::MOUSE_BUTTON2, lParam,wParam);
-	break;
-
-#ifndef NO_TOUCH_API
-	case WM_TOUCH:
-		if(core) {
-			if(core->isMultiTouchEnabled()) {
-				core->handleTouchEvent(lParam, wParam);
-			}
-		}
-	break;
-#endif
-
-	case WM_MBUTTONDOWN:
-		if(core)
-			core->handleMouseDown(CoreInput::MOUSE_BUTTON3, lParam,wParam);
-	break;
-	case WM_MBUTTONUP:
-		if(core)
-			core->handleMouseUp(CoreInput::MOUSE_BUTTON3, lParam,wParam);
-	break;
-	case WM_KEYDOWN:
-		if(core) {
-				wchar_t unicodeChar = 0;
-				MSG m;
-				m.hwnd = hWnd;
-				m.message = message;
-				m.wParam = wParam;
-				m.lParam = lParam;
-				m.time = 0;
-				if ( PeekMessage(&m, hWnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR) ) {
-					GetMessage(&m, hWnd, 0, WM_USER);
-			    		unicodeChar = (wchar_t)m.wParam;
-				}
-
-			core->handleKeyDown(lParam,wParam, unicodeChar);
-		}
-	break;
-	case WM_KEYUP:
-		if(core)
-			core->handleKeyUp(lParam,wParam);
-	break;
-	case WM_CLOSE:
-		if(core)
-			core->Shutdown();
-		useDefault = true;
-	break;
-	case WM_DESTROY:
-		PostQuitMessage(0);
-		break;
-	default:
-		useDefault = true;
-		break;
-	}
-	
-	if (useDefault)
-		return DefWindowProc(hWnd, message, wParam, lParam);
-	else
-		return 0;
-}
-
-
-PolycodeView::PolycodeView(HINSTANCE hInstance, int nCmdShow, LPCTSTR windowTitle, bool resizable, bool showDebugConsole) : PolycodeViewBase() {
-
-WNDCLASSEX wcex;
-
-	wcex.cbSize = sizeof(WNDCLASSEX);
-	wcex.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
-	wcex.lpfnWndProc	= WndProc;
-	wcex.cbClsExtra		= 0;
-	wcex.cbWndExtra		= 0;
-	wcex.hInstance		= hInstance;
-	wcex.hIcon			= LoadIcon(hInstance, IDI_APPLICATION);
-	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
-	wcex.hbrBackground	= NULL;
-	wcex.lpszMenuName	= NULL;
-	wcex.lpszClassName	= L"POLYCODEAPPLICATION";
-	wcex.hIconSm		= LoadIcon(hInstance, IDI_APPLICATION);
-
-	RegisterClassEx(&wcex);
-
-	if(resizable) {
-		hwnd = CreateWindowEx(WS_EX_APPWINDOW, L"POLYCODEAPPLICATION", windowTitle, WS_OVERLAPPEDWINDOW|WS_SYSMENU, 0, 0, 640, 480, NULL, NULL, hInstance, NULL);
-	} else {
-		hwnd = CreateWindowEx(WS_EX_APPWINDOW, L"POLYCODEAPPLICATION", windowTitle, WS_OVERLAPPED|WS_SYSMENU, 0, 0, 640, 480, NULL, NULL, hInstance, NULL);
-	}
-
-  windowData = (void*)&hwnd;
-
-   ShowWindow(hwnd, nCmdShow);
-   UpdateWindow(hwnd);
-
-   if(showDebugConsole) {
-		OpenConsole();
-   }
-
-}
-
-PolycodeView::~PolycodeView() {
-
+#include <ios>
+
+using namespace Polycode;
+
+Win32Core *core = NULL;
+
+
+static void OpenConsole()
+{
+    int outHandle, errHandle, inHandle;
+    FILE *outFile, *errFile, *inFile;
+    AllocConsole();
+    CONSOLE_SCREEN_BUFFER_INFO coninfo;
+    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
+    coninfo.dwSize.Y = 9999;
+    SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
+
+    outHandle = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
+    errHandle = _open_osfhandle((long)GetStdHandle(STD_ERROR_HANDLE),_O_TEXT);
+    inHandle = _open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE),_O_TEXT );
+
+    outFile = _fdopen(outHandle, "w" );
+    errFile = _fdopen(errHandle, "w");
+    inFile =  _fdopen(inHandle, "r");
+
+    *stdout = *outFile;
+    *stderr = *errFile;
+    *stdin = *inFile;
+
+    setvbuf( stdout, NULL, _IONBF, 0 );
+    setvbuf( stderr, NULL, _IONBF, 0 );
+    setvbuf( stdin, NULL, _IONBF, 0 );
+
+    std::ios::sync_with_stdio();
+
+}
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+	int nWidth, nHeight;
+	bool useDefault = false;
+
+	if(!core)
+		return DefWindowProc(hWnd, message, wParam, lParam);
+
+	switch (message)
+	{
+	case WM_SIZE:
+		nWidth = LOWORD(lParam); 
+		nHeight = HIWORD(lParam);
+		if(core) {
+			core->handleViewResize(nWidth, nHeight);
+		}
+	break;
+
+	case WM_MOUSEMOVE:
+		if(core)
+			core->handleMouseMove(lParam,wParam);
+	break;
+
+	case WM_MOUSEWHEEL:
+		if(core)
+			core->handleMouseWheel(lParam,wParam);
+	break;
+
+	case WM_LBUTTONDOWN:
+		if(core)
+			core->handleMouseDown(CoreInput::MOUSE_BUTTON1, lParam,wParam);
+	break;
+	case WM_LBUTTONUP:
+		if(core)
+			core->handleMouseUp(CoreInput::MOUSE_BUTTON1, lParam,wParam);
+	break;
+
+	case WM_RBUTTONDOWN:
+		if(core)
+			core->handleMouseDown(CoreInput::MOUSE_BUTTON2, lParam,wParam);
+	break;
+	case WM_RBUTTONUP:
+		if(core)
+			core->handleMouseUp(CoreInput::MOUSE_BUTTON2, lParam,wParam);
+	break;
+
+#ifndef NO_TOUCH_API
+	case WM_TOUCH:
+		if(core) {
+			if(core->isMultiTouchEnabled()) {
+				core->handleTouchEvent(lParam, wParam);
+			}
+		}
+	break;
+#endif
+
+	case WM_MBUTTONDOWN:
+		if(core)
+			core->handleMouseDown(CoreInput::MOUSE_BUTTON3, lParam,wParam);
+	break;
+	case WM_MBUTTONUP:
+		if(core)
+			core->handleMouseUp(CoreInput::MOUSE_BUTTON3, lParam,wParam);
+	break;
+	case WM_KEYDOWN:
+		if(core) {
+				wchar_t unicodeChar = 0;
+				MSG m;
+				m.hwnd = hWnd;
+				m.message = message;
+				m.wParam = wParam;
+				m.lParam = lParam;
+				m.time = 0;
+				if ( PeekMessage(&m, hWnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR) ) {
+					GetMessage(&m, hWnd, 0, WM_USER);
+			    		unicodeChar = (wchar_t)m.wParam;
+				}
+
+			core->handleKeyDown(lParam,wParam, unicodeChar);
+		}
+	break;
+	case WM_KEYUP:
+		if(core)
+			core->handleKeyUp(lParam,wParam);
+	break;
+	case WM_CLOSE:
+		if(core)
+			core->Shutdown();
+		useDefault = true;
+	break;
+	case WM_DESTROY:
+		PostQuitMessage(0);
+		break;
+	default:
+		useDefault = true;
+		break;
+	}
+	
+	if (useDefault)
+		return DefWindowProc(hWnd, message, wParam, lParam);
+	else
+		return 0;
+}
+
+
+PolycodeView::PolycodeView(HINSTANCE hInstance, int nCmdShow, LPCTSTR windowTitle, bool resizable, bool showDebugConsole) : PolycodeViewBase() {
+
+WNDCLASSEX wcex;
+
+	wcex.cbSize = sizeof(WNDCLASSEX);
+	wcex.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+	wcex.lpfnWndProc	= WndProc;
+	wcex.cbClsExtra		= 0;
+	wcex.cbWndExtra		= 0;
+	wcex.hInstance		= hInstance;
+	wcex.hIcon			= LoadIcon(hInstance, IDI_APPLICATION);
+	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
+	wcex.hbrBackground	= NULL;
+	wcex.lpszMenuName	= NULL;
+	wcex.lpszClassName	= L"POLYCODEAPPLICATION";
+	wcex.hIconSm		= LoadIcon(hInstance, IDI_APPLICATION);
+
+	RegisterClassEx(&wcex);
+
+	if(resizable) {
+		hwnd = CreateWindowEx(WS_EX_APPWINDOW, L"POLYCODEAPPLICATION", windowTitle, WS_OVERLAPPEDWINDOW|WS_SYSMENU, 0, 0, 640, 480, NULL, NULL, hInstance, NULL);
+	} else {
+		hwnd = CreateWindowEx(WS_EX_APPWINDOW, L"POLYCODEAPPLICATION", windowTitle, WS_OVERLAPPED|WS_SYSMENU, 0, 0, 640, 480, NULL, NULL, hInstance, NULL);
+	}
+
+  windowData = (void*)&hwnd;
+
+   ShowWindow(hwnd, nCmdShow);
+   UpdateWindow(hwnd);
+
+   if(showDebugConsole) {
+		OpenConsole();
+   }
+
+}
+
+PolycodeView::~PolycodeView() {
+
 }

+ 2 - 2
Core/Contents/Source/PolyObject.cpp

@@ -251,11 +251,11 @@ void Object::createFromXMLElement(TiXmlElement *element, ObjectEntry *entry) {
 		if (endResult == success) { // If integer part exhausts string
 			entry->type = ObjectEntry::INT_ENTRY;
 			entry->NumberVal = entry->intVal;
-			entry->boolVal = entry->intVal;
+			entry->boolVal = entry->intVal != 0;
 		} else {
 			entry->NumberVal = strtod(rawVal, &endResult);
 			entry->intVal = entry->NumberVal;
-			entry->boolVal = entry->NumberVal;
+			entry->boolVal = entry->NumberVal != 0.0;
 			if (endResult == success) {
 				entry->type = ObjectEntry::FLOAT_ENTRY;
 			}

+ 1 - 0
Core/Contents/Source/PolyRenderer.cpp

@@ -343,6 +343,7 @@ void *Renderer::getDataPointerForName(const String &name) {
 	if(name == "ambient_color") {
 		return (void*)&ambientColor;
 	}
+	return NULL;
 }
 
 void Renderer::setRendererShaderParams(Shader *shader, ShaderBinding *binding) {

+ 2 - 1
Core/Contents/Source/PolyString.cpp

@@ -210,7 +210,7 @@ void utf8toWStr(WStr& dest, const Str& src){
 	dest.clear();
 	wchar_t w = 0;
 	int bytes = 0;
-	wchar_t err = L'';
+	wchar_t err = L'\uFFFD';
 	for (size_t i = 0; i < src.size(); i++){
 		unsigned char c = (unsigned char)src[i];
 		if (c <= 0x7f){//first byte
@@ -267,6 +267,7 @@ void wstrToUtf8(Str& dest, const WStr& src){
 			dest.push_back(0x80| (w & 0x3f));
 		}
 		else if (w <= 0x10ffff){
+			// FIXME: wchar_t is 16 bits on some platforms, should convert from UTF16 to UTF8
 			dest.push_back(0xf0 | ((w >> 18)& 0x07));
 			dest.push_back(0x80| ((w >> 12) & 0x3f));
 			dest.push_back(0x80| ((w >> 6) & 0x3f));

+ 1 - 1
Modules/Contents/2DPhysics/Source/PolyPhysicsScreen.cpp

@@ -326,7 +326,7 @@ PhysicsScreenEntity *PhysicsScreen::addCollisionChild(ScreenEntity *newEntity, i
 
 PhysicsScreenEntity *PhysicsScreen::trackCollisionChild(ScreenEntity *newEntity, int entType, int groupIndex) {
 	PhysicsScreenEntity *ret;
-	ret = trackPhysicsChild(newEntity, entType, false, 0,0.0,0, true, groupIndex);
+	ret = trackPhysicsChild(newEntity, entType, false, 0,0.0,0, true, false, groupIndex);
 	ret->collisionOnly = true; 
 	return ret;
 }

+ 1 - 1
Modules/Contents/3DPhysics/Include/PolyPhysicsScene.h

@@ -26,7 +26,7 @@ THE SOFTWARE.
 #include <vector>
 
 class btDiscreteDynamicsWorld;
-class btDbvtBroadphase;
+struct btDbvtBroadphase;
 class btSequentialImpulseConstraintSolver;
 class btGhostPairCallback;
 class btTypedConstraint;

+ 1 - 1
Modules/Contents/TUIO/Source/TuioClient.cpp

@@ -80,7 +80,7 @@ TuioClient::TuioClient(int port)
 {
 	try {
 		socket = new UdpListeningReceiveSocket(IpEndpointName( IpEndpointName::ANY_ADDRESS, port ), this );
-	} catch (std::exception &e) { 
+	} catch (std::exception&) {
 		std::cerr << "could not bind to UDP port " << port << std::endl;
 		socket = NULL;
 	}

+ 1 - 1
Modules/Contents/TUIO/Source/TuioServer.cpp

@@ -184,7 +184,7 @@ void TuioServer::initialize(const char *host, int port, int size) {
 		oscPacket = new osc::OutboundPacketStream(oscBuffer,size);
 		fullBuffer = new char[size];
 		fullPacket = new osc::OutboundPacketStream(fullBuffer,size);
-	} catch (std::exception &e) { 
+	} catch (std::exception&) {
 		std::cout << "could not create socket" << std::endl;
 		socket = NULL;
 	}

+ 0 - 1
Tools/Contents/polybuild/Source/polybuild.cpp

@@ -47,7 +47,6 @@ uLong filetime(
     uLong *dt)
 {
   int ret=0;
-  struct stat s;        /* results of stat() */
   struct tm* filedate;
   time_t tm_t=0;
 

+ 1 - 0
Tools/Contents/polyimport/Include/polyimport.h

@@ -71,6 +71,7 @@ class ISkeleton {
 				return i;
 			}
 		}
+		return -1;
 	}
 
 	void saveToFile(const char *fileName, bool swapZY) {