enabled console for WinRT

This commit is contained in:
Dale Stammen 2014-10-14 14:14:12 -07:00
parent 52fc6d618b
commit c8e4fe1fbf
3 changed files with 7 additions and 23 deletions

View File

@ -40,7 +40,7 @@
#include <WS2tcpip.h>
#include <Winsock2.h>
#define bzero(a, b) memset(a, 0, b);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
#include "inet_ntop_winrt.h"
#include "CCWinRTUtils.h"
#endif
@ -111,8 +111,6 @@ static bool isFloat( std::string myString ) {
return iss.eof() && !iss.fail();
}
#if CC_TARGET_PLATFORM != CC_PLATFORM_WINRT
// helper free functions
// dprintf() is not defined in Android
@ -183,7 +181,6 @@ static void printFileUtils(int fd)
}
sendPrompt(fd);
}
#endif
#if defined(__MINGW32__)
@ -231,9 +228,7 @@ static void _log(const char *format, va_list args)
fflush(stdout);
#endif
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
Director::getInstance()->getConsole()->log(buf);
#endif
}
@ -254,8 +249,6 @@ void log(const char * format, ...)
va_end(args);
}
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
//
// Console code
//
@ -328,7 +321,7 @@ bool Console::listenOnTCP(int port)
hints.ai_family = AF_INET; // AF_UNSPEC: Do we need IPv6 ?
hints.ai_socktype = SOCK_STREAM;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
WSADATA wsaData;
n = WSAStartup(MAKEWORD(2, 2),&wsaData);
@ -354,7 +347,7 @@ bool Console::listenOnTCP(int port)
break; /* success */
/* bind error, close and try next one */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
closesocket(listenfd);
#else
close(listenfd);
@ -441,7 +434,7 @@ void Console::commandExit(int fd, const std::string &args)
{
FD_CLR(fd, &_read_set);
_fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end());
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
closesocket(fd);
#else
close(fd);
@ -1074,7 +1067,7 @@ void Console::loop()
//receive a SIGPIPE, which will cause linux system shutdown the sending process.
//Add this ioctl code to check if the socket has been closed by peer.
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
u_long n = 0;
ioctlsocket(fd, FIONREAD, &n);
#else
@ -1119,14 +1112,14 @@ void Console::loop()
// clean up: ignore stdin, stdout and stderr
for(const auto &fd: _fds )
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
closesocket(fd);
#else
close(fd);
#endif
}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
closesocket(_listenfd);
WSACleanup();
#else
@ -1135,7 +1128,6 @@ void Console::loop()
_running = false;
}
#endif /* #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) */
NS_CC_END

View File

@ -72,7 +72,6 @@ void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2);
```
*/
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
class CC_DLL Console
: public Ref
{
@ -148,7 +147,6 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(Console);
};
#endif /* #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) */
NS_CC_END
#endif /* defined(__CCCONSOLE_H__) */

View File

@ -59,9 +59,7 @@ class TextureCache;
class Renderer;
class Camera;
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
class Console;
#endif
/**
@brief Class that creates and handles the main Window and manages how
@ -391,9 +389,7 @@ public:
/** Returns the Console
@since v3.0
*/
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
Console* getConsole() const { return _console; }
#endif
/* Gets delta time since last tick to main loop */
float getDeltaTime() const;
@ -503,10 +499,8 @@ protected:
/* Renderer for the Director */
Renderer *_renderer;
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
/* Console for the director */
Console *_console;
#endif
// GLView will recreate stats labels to fit visible rect
friend class GLView;