void set(JSString* str, JSContext* cx) {
     this->cx = cx;
     string = str;
     // Not suppored in SpiderMonkey v19
     //buffer = JS_EncodeString(cx, string);
     
     const jschar *chars = JS_GetStringCharsZ(cx, string);
     size_t l = JS_GetStringLength(string);
     char* pUTF8Str = cc_utf16_to_utf8((const unsigned short*)chars, l, NULL, NULL);
     buffer = pUTF8Str;
 }
Beispiel #2
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

#ifdef USE_WIN32_CONSOLE
    AllocConsole();
    freopen("CONIN$", "r", stdin);
    freopen("CONOUT$", "w", stdout);
    freopen("CONOUT$", "w", stderr);
#else
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif

	int nWidth = 1136;
	int nHeight = 640;
	float fFactor = 0.8f;
	int nShowFPS = 0;

	wchar_t szWChar[1024];

	g_SimulateFileName = new char[1024];

	swscanf( lpCmdLine, L"%d %d %f %s", &nWidth, &nHeight, &fFactor, &szWChar);
	int size = wcslen(szWChar);
	sprintf(g_SimulateFileName, "%s", cc_utf16_to_utf8((unsigned short*)szWChar, size, NULL, NULL));

    // create the application instance
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    eglView->setFrameSize(nWidth, nHeight);

	eglView->setFrameZoomFactor(fFactor);

	// ÊÇ·ñÏÔʾfps
	CCDirector *pDirector = CCDirector::sharedDirector();
	pDirector->setDisplayStats((nShowFPS == 1));

    int ret = CCApplication::sharedApplication()->run();

#ifdef USE_WIN32_CONSOLE
    FreeConsole();
#endif

    return ret;
}
Beispiel #3
0
static bool_t CC_CALL _send_header(cc_event_t *e, cckit_http_t *h)
{
	cc_url_t *u = NULL;
    int32_t head_len = 0;
    tchar_t buff_head[10240] = {0};
#ifdef CC_UNICODE
    char_t send_head[10240] = {0};
#else
	char_t* send_head = NULL;
#endif

	bool_t ret = TRUE;

	u = h->address;
    
    if(h->cb.cb_before_send) {
        head_len = cc_countof(buff_head);
        if (h->cb.cb_before_send(u, buff_head, &head_len, h->cb.args) == FALSE) {
            head_len = 0;
        }
    }
    
    if (head_len <= 0) {
        head_len = _sntprintf(buff_head, cc_countof(buff_head), default_http_template,
                              u->path, u->host, _user_agent[rand()%cc_countof(_user_agent)]);
    }
    
#ifdef CC_UNICODE
    head_len = cc_utf16_to_utf8((uint16_t*)buff_head, (uint16_t*)(buff_head + head_len),
                                 (uint8_t*)(send_head), (uint8_t*)(send_head + cc_countof(send_head)), FALSE);
#else
    send_head = (char_t*)buff_head;
#endif

#ifdef CC_OPENSSL_HTTPS
    if (u->scheme == CC_SCHEME_HTTPS && h->ssl) {
        if (_sendSSL(h->ssl, (byte_t*)send_head, head_len) != head_len) {
            h->cb.cb_error(h->cb.args, CCKIT_HTTP_SOCKET_SEND_FAILED);
            ret = FALSE;
        }
    } else
#endif
	if (cc_send(e->io_handle, (byte_t*)send_head, head_len) < 0) {
		h->cb.cb_error(h->cb.args, CCKIT_HTTP_SOCKET_SEND_FAILED);
		ret = FALSE;
	}

	return ret;
}
Beispiel #4
0
std::string Label::getDescription() const
{
    return StringUtils::format("<Label | Tag = %d, Label = '%s'>", _tag, cc_utf16_to_utf8(_currentUTF16String,-1,nullptr,nullptr));
}