mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
Merge the code of v3.3.1 platform adaptation layer into the development branch (#3958)
* 1、Merge platform adaptation layer code into the development branch 2、It passed the test in windows and ohos system * 1、Merge platform adaptation layer code into the development branch 2、It passed the test in windows and ohos system * 1、Fix github compile windows error * 1、Fix github compile windows error * 1. Adjust the code format; 2. Fix js automatic generation binding 3. Adjust github CI compilation * 1. Adjust the code format; 2. Fix js automatic generation binding 3. Adjust github CI compilation * Solve mac and ios compilation failure * Fix the problem of compilation of Windows-side simulator * 1. Adapt the simulator to a new adaptation layer; 2. Fix the compilation warning of ios, and the implicit conversion failed; 3. Fix the mac compilation error, due to the problem of adding the link identification -all_load; * 1.Add the isDisplayStats and setDisplayStats method to the screen interface * Fix clang-tidy compilation warning * Fix clang-tidy compilation warning * Repair the emulator, compatible with mac and win * 1、Repair detailed errors, including name modification and calling method modification 2、Delete redundant files in the template directory 3、Change the vibrate interface to vibrator 4、Fix word spelling errors * Rename interfaces to modules * Replace CC_ASSERT with CCASSERT * Replace CC_ASSERT with CCASSERT Co-authored-by: qiuguohua <>
This commit is contained in:
@@ -32,8 +32,7 @@
|
||||
#include <cstdio>
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
|
||||
#include "platform/Application.h"
|
||||
#include "application/ApplicationManager.h"
|
||||
#include "platform/FileUtils.h"
|
||||
#include "platform/java/jni/JniHelper.h"
|
||||
|
||||
@@ -86,9 +85,6 @@ public:
|
||||
explicit HttpURLConnection(HttpClient *httpClient)
|
||||
: _client(httpClient),
|
||||
_httpURLConnection(nullptr),
|
||||
_requestmethod(""),
|
||||
_responseCookies(""),
|
||||
_cookieFileName(""),
|
||||
_contentLength(0) {
|
||||
}
|
||||
|
||||
@@ -98,7 +94,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void setRequestMethod(const char *method) {
|
||||
void setRequestMethod(const char *method) { // NOLINT
|
||||
_requestmethod = method;
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
@@ -142,7 +138,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
int connect() {
|
||||
int connect() { // NOLINT
|
||||
int suc = 0;
|
||||
JniMethodInfo methodInfo;
|
||||
if (JniHelper::getStaticMethodInfo(methodInfo,
|
||||
@@ -159,7 +155,7 @@ public:
|
||||
return suc;
|
||||
}
|
||||
|
||||
void disconnect() {
|
||||
void disconnect() { // NOLINT
|
||||
JniMethodInfo methodInfo;
|
||||
if (JniHelper::getStaticMethodInfo(methodInfo,
|
||||
JCLS_HTTPCLIENT,
|
||||
@@ -173,7 +169,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int getResponseCode() {
|
||||
int getResponseCode() { // NOLINT
|
||||
int responseCode = 0;
|
||||
JniMethodInfo methodInfo;
|
||||
if (JniHelper::getStaticMethodInfo(methodInfo,
|
||||
@@ -190,7 +186,7 @@ public:
|
||||
return responseCode;
|
||||
}
|
||||
|
||||
char *getResponseMessage() {
|
||||
char *getResponseMessage() { // NOLINT
|
||||
char * message = nullptr;
|
||||
JniMethodInfo methodInfo;
|
||||
if (JniHelper::getStaticMethodInfo(methodInfo,
|
||||
@@ -211,7 +207,7 @@ public:
|
||||
return message;
|
||||
}
|
||||
|
||||
void sendRequest(HttpRequest *request) {
|
||||
void sendRequest(HttpRequest *request) { // NOLINT
|
||||
JniMethodInfo methodInfo;
|
||||
if (JniHelper::getStaticMethodInfo(methodInfo,
|
||||
JCLS_HTTPCLIENT,
|
||||
@@ -230,7 +226,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
size_t saveResponseCookies(const char *responseCookies, size_t count) {
|
||||
size_t saveResponseCookies(const char *responseCookies, size_t count) { // NOLINT
|
||||
if (nullptr == responseCookies || strlen(responseCookies) == 0 || count == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -252,7 +248,7 @@ public:
|
||||
return count;
|
||||
}
|
||||
|
||||
char *getResponseHeaders() {
|
||||
char *getResponseHeaders() { // NOLINT
|
||||
char * headers = nullptr;
|
||||
JniMethodInfo methodInfo;
|
||||
if (JniHelper::getStaticMethodInfo(methodInfo,
|
||||
@@ -273,7 +269,7 @@ public:
|
||||
return headers;
|
||||
}
|
||||
|
||||
char *getResponseContent(HttpResponse *response) {
|
||||
char *getResponseContent(HttpResponse *response) { // NOLINT
|
||||
if (nullptr == response) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -370,7 +366,7 @@ public:
|
||||
_cookieFileName = filename;
|
||||
}
|
||||
|
||||
int getContentLength() {
|
||||
int getContentLength() const {
|
||||
return _contentLength;
|
||||
}
|
||||
|
||||
@@ -570,7 +566,7 @@ private:
|
||||
return _responseCookies;
|
||||
}
|
||||
|
||||
private:
|
||||
private: // NOLINT(readability-redundant-access-specifiers)
|
||||
HttpClient *_client;
|
||||
jobject _httpURLConnection;
|
||||
std::string _requestmethod;
|
||||
@@ -582,7 +578,7 @@ private:
|
||||
|
||||
// Process Response
|
||||
void HttpClient::processResponse(HttpResponse *response, char *responseMessage) {
|
||||
auto request = response->getHttpRequest();
|
||||
auto * request = response->getHttpRequest();
|
||||
HttpRequest::Type requestType = request->getRequestType();
|
||||
|
||||
if (HttpRequest::Type::GET != requestType &&
|
||||
@@ -728,7 +724,7 @@ void HttpClient::networkThread() {
|
||||
|
||||
_schedulerMutex.lock();
|
||||
if (auto sche = _scheduler.lock()) {
|
||||
sche->performFunctionInCocosThread(CC_CALLBACK_0(HttpClient::dispatchResponseCallbacks, this));
|
||||
sche->performFunctionInCocosThread(CC_CALLBACK_0(HttpClient::dispatchResponseCallbacks, this)); // NOLINT
|
||||
}
|
||||
_schedulerMutex.unlock();
|
||||
}
|
||||
@@ -787,7 +783,7 @@ void HttpClient::destroyInstance() {
|
||||
|
||||
CC_LOG_DEBUG("HttpClient::destroyInstance ...");
|
||||
|
||||
auto thiz = gHttpClient;
|
||||
auto *thiz = gHttpClient;
|
||||
gHttpClient = nullptr;
|
||||
|
||||
if (auto sche = thiz->_scheduler.lock()) {
|
||||
@@ -830,7 +826,7 @@ HttpClient::HttpClient()
|
||||
_requestSentinel(new HttpRequest()) {
|
||||
CC_LOG_DEBUG("In the constructor of HttpClient!");
|
||||
increaseThreadCount();
|
||||
_scheduler = Application::getInstance()->getScheduler();
|
||||
_scheduler = CC_CURRENT_ENGINE()->getScheduler();
|
||||
}
|
||||
|
||||
HttpClient::~HttpClient() {
|
||||
@@ -844,7 +840,7 @@ bool HttpClient::lazyInitThreadSemaphore() {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto t = std::thread(CC_CALLBACK_0(HttpClient::networkThread, this));
|
||||
auto t = std::thread(CC_CALLBACK_0(HttpClient::networkThread, this)); // NOLINT
|
||||
t.detach();
|
||||
_isInited = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user