Skip to content

Commit

Permalink
Upgrade to ndk 26b and fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Jani Hautakangas committed Apr 23, 2024
1 parent 42978f4 commit fdb0a9c
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion wpe/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
android {
namespace 'com.wpe.wpe'
compileSdk 34
ndkVersion '25.2.9519653'
ndkVersion '26.1.10909125'

defaultConfig {
minSdk 31
Expand Down
6 changes: 4 additions & 2 deletions wpe/src/main/cpp/Browser/Browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ class JNIBrowserCache final : public JNI::TypedClass<JNIBrowser> {
private:
mutable JNI::ProtectedType<JNIBrowser> m_browserJavaInstance;

// NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members)
const JNI::Method<void(jlong, jint, jint)> m_launchProcessMethod;
const JNI::Method<void(jlong)> m_terminateProcessMethod;
// NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members)
};

const JNIBrowserCache& getJNIBrowserCache()
Expand Down Expand Up @@ -116,8 +118,8 @@ int64_t wpeLaunchProcess(void* /*backend*/, wpe_process_type wpeProcessType, voi
if ((options == nullptr) || (options[0] == nullptr) || (options[1] == nullptr))
return -1;

jlong pid = std::strtoll(options[0], nullptr, 10); // NOLINT(cppcoreguidelines-avoid-magic-numbers)
jint fileDesc = std::stoi(options[1]);
const jlong pid = std::strtoll(options[0], nullptr, 10); // NOLINT(cppcoreguidelines-avoid-magic-numbers)
const jint fileDesc = std::stoi(options[1]);

auto processType = ProcessType::TypesCount;
if (wpeProcessType == WPE_PROCESS_TYPE_WEB) {
Expand Down
4 changes: 2 additions & 2 deletions wpe/src/main/cpp/Browser/MessagePump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ MessagePump::~MessagePump()
{
flush();

for (int fileDesc : m_looperAttachedPollFds)
for (const int fileDesc : m_looperAttachedPollFds)
ALooper_removeFd(m_looper, fileDesc);
m_looperAttachedPollFds.clear();

Expand Down Expand Up @@ -206,7 +206,7 @@ void MessagePump::prepare()
}
}

for (int fileDesc : unusedAttachedFds) {
for (const int fileDesc : unusedAttachedFds) {
ALooper_removeFd(m_looper, fileDesc);
m_looperAttachedPollFds.erase(fileDesc);
}
Expand Down
14 changes: 8 additions & 6 deletions wpe/src/main/cpp/Browser/Page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class JNIPageCache final : public JNI::TypedClass<JNIPage> {
}
}

// NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members)
const JNI::Method<void()> m_onClose;
const JNI::Method<void(jint)> m_onLoadChanged;
const JNI::Method<void(jdouble)> m_onLoadProgress;
Expand All @@ -124,6 +125,7 @@ class JNIPageCache final : public JNI::TypedClass<JNIPage> {
const JNI::Method<void()> m_onInputMethodContextOut;
const JNI::Method<void()> m_onEnterFullscreenMode;
const JNI::Method<void()> m_onExitFullscreenMode;
// NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members)

static jlong nativeInit(
JNIEnv* env, jobject obj, jlong wkWebContextPtr, jint width, jint height, jboolean headless);
Expand Down Expand Up @@ -280,8 +282,8 @@ void JNIPageCache::nativeSurfaceChanged(
Logging::logDebug("Page::nativeSurfaceChanged(%d, %d, %d) [tid %d]", format, width, height, gettid());
Page* page = reinterpret_cast<Page*>(pagePtr); // NOLINT(performance-no-int-to-ptr)
if ((page != nullptr) && (page->m_viewBackend != nullptr) && page->m_renderer) {
uint32_t uWidth = std::max(0, width);
uint32_t uHeight = std::max(0, height);
const uint32_t uWidth = std::max(0, width);
const uint32_t uHeight = std::max(0, height);
wpe_view_backend_dispatch_set_size(
WPEAndroidViewBackend_getWPEViewBackend(page->m_viewBackend), uWidth, uHeight);
page->m_renderer->onSurfaceChanged(format, uWidth, uHeight);
Expand Down Expand Up @@ -335,7 +337,7 @@ void JNIPageCache::nativeOnTouchEvent(
break;
}

wpe_input_touch_event_raw touchEventRaw = {.type = touchEventType,
const wpe_input_touch_event_raw touchEventRaw = {.type = touchEventType,
.time = static_cast<uint32_t>(time),
.id = 0,
.x = static_cast<int32_t>(xCoord),
Expand Down Expand Up @@ -393,8 +395,8 @@ Page::Page(JNIEnv* env, JNIPage jniPage, WKWebContext* wkWebContext, int width,
, m_inputMethodContext(this)
, m_isHeadless(headless)
{
uint32_t uWidth = std::max(0, width);
uint32_t uHeight = std::max(0, height);
const uint32_t uWidth = std::max(0, width);
const uint32_t uHeight = std::max(0, height);

m_viewBackend = WPEAndroidViewBackend_create(uWidth, uHeight);

Expand Down Expand Up @@ -451,7 +453,7 @@ void Page::onInputMethodContextIn() noexcept { getJNIPageCache().onInputMethodCo

void Page::onInputMethodContextOut() noexcept { getJNIPageCache().onInputMethodContextOut(m_pageJavaInstance.get()); }

void Page::commitBuffer(WPEAndroidBuffer* buffer, int fenceFD) noexcept
void Page::commitBuffer(WPEAndroidBuffer* buffer, int fenceFD) noexcept // NOLINT(bugprone-exception-escape)
{
auto scopedFenceFD = std::make_shared<ScopedFD>(fenceFD);
if (m_viewBackend != nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion wpe/src/main/cpp/Browser/Page.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Page final : public InputMethodContextObserver {
void onInputMethodContextIn() noexcept override;
void onInputMethodContextOut() noexcept override;

void commitBuffer(WPEAndroidBuffer* buffer, int fenceFD) noexcept;
void commitBuffer(WPEAndroidBuffer* buffer, int fenceFD) noexcept; // NOLINT(bugprone-exception-escape)

private:
friend class JNIPageCache;
Expand Down
2 changes: 1 addition & 1 deletion wpe/src/main/cpp/Browser/ScopedFD.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ScopedFD final {

int release()
{
int releasedFD = m_fd;
const int releasedFD = m_fd;
m_fd = -1;
return releasedFD;
}
Expand Down
2 changes: 2 additions & 0 deletions wpe/src/main/cpp/Browser/WKWebContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class JNIWKWebContextCache final : public JNI::TypedClass<JNIWKWebContext> {
}

private:
// NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members)
const JNI::Method<jlong()> m_createPageForAutomation;
// NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members)

static jlong nativeInit(JNIEnv* env, jobject obj, jlong nativeWebsiteDataManagerPtr, jboolean automationMode);
static void nativeDestroy(JNIEnv* env, jobject obj, jlong wkWebContextPtr) noexcept;
Expand Down
4 changes: 3 additions & 1 deletion wpe/src/main/cpp/Browser/WKWebsiteDataManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class JNIWKWebsiteDataManagerCallbackHolderCache final : public JNI::TypedClass<
}

private:
// NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members)
const JNI::Method<void(jboolean)> m_commitResult;
// NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members)
};

const JNIWKWebsiteDataManagerCallbackHolderCache& getJNIWKWebsiteDataManagerCallbackHolderCache()
Expand All @@ -56,7 +58,7 @@ class JNIWKWebsiteDataManagerCache final : public JNI::TypedClass<JNIWKWebsiteDa
static void onRemoveAllCookiesReady(
WebKitWebsiteDataManager* manager, GAsyncResult* result, JNIWKWebsiteDataManagerCallbackHolder callbackHolder)
{
gboolean clearResult = webkit_website_data_manager_clear_finish(manager, result, nullptr);
const gboolean clearResult = webkit_website_data_manager_clear_finish(manager, result, nullptr);
getJNIWKWebsiteDataManagerCallbackHolderCache().onResult(callbackHolder, static_cast<jboolean>(clearResult));
}

Expand Down
6 changes: 4 additions & 2 deletions wpe/src/main/cpp/Common/JNI/JNINativeMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ struct GenericNativeMethod<Ret(Params...), U,
{
}

// NOLINTBEGIN(misc-non-private-member-variables-in-classes, readability-identifier-naming)
// NOLINTBEGIN(misc-non-private-member-variables-in-classes, readability-identifier-naming,
// cppcoreguidelines-avoid-const-or-ref-data-members)
const char* const methodName;
const FunctionPtrType nativeFunction;
// NOLINTEND(misc-non-private-member-variables-in-classes, readability-identifier-naming)
// NOLINTEND(misc-non-private-member-variables-in-classes, readability-identifier-naming,
// cppcoreguidelines-avoid-const-or-ref-data-members)
};

template <typename T> using NativeMethod = GenericNativeMethod<T, jobject>;
Expand Down
6 changes: 5 additions & 1 deletion wpe/src/main/cpp/Common/JNI/JNIObjectArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ template <typename T> class ConstObjectSpan final {
{
}

// NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members)
const ConstObjectSpan& m_span;
// NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members)
size_t m_currentIndex;
};

Expand All @@ -102,7 +104,9 @@ template <typename T> class ConstObjectSpan final {
{
}

// NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members)
const size_t m_size;
// NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members)
ProtectedArrayType<T> m_javaArrayRef;
};

Expand Down Expand Up @@ -166,7 +170,7 @@ template <typename T> class ObjectArray<T, EnableIfObjectType<T>> final {
return {0, {}};

auto* env = getCurrentThreadJNIEnv();
jsize size = env->GetArrayLength(m_javaArrayRef.get());
const jsize size = env->GetArrayLength(m_javaArrayRef.get());
checkJavaException(env);
if (size <= 0)
return {0, {}};
Expand Down
2 changes: 1 addition & 1 deletion wpe/src/main/cpp/Common/JNI/JNIString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ size_t JNI::String::getLength() const
return 0;

auto* env = getCurrentThreadJNIEnv();
jsize length = env->GetStringUTFLength(m_javaStringRef.get());
const jsize length = env->GetStringUTFLength(m_javaStringRef.get());
checkJavaException(env);
return (length > 0) ? static_cast<size_t>(length) : 0;
}
Expand Down

0 comments on commit fdb0a9c

Please sign in to comment.