Skip to content

Commit 9985765

Browse files
committed
Clean up warnings
1 parent eda0769 commit 9985765

10 files changed

Lines changed: 29 additions & 85 deletions

File tree

android/CMakeLists.txt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
project(OPServer)
2-
cmake_minimum_required(VERSION 3.9.0)
2+
cmake_minimum_required(VERSION 3.22.1)
33

44
set (PACKAGE_NAME "op-server")
55

6+
include_directories(
7+
../cpp
8+
src/main/cpp
9+
)
10+
611
file(GLOB_RECURSE shared_files RELATIVE ${CMAKE_SOURCE_DIR}
712
"../cpp/**.cpp"
813
)
14+
915
file(GLOB_RECURSE android_files RELATIVE ${CMAKE_SOURCE_DIR}
1016
"src/main/cpp/**.cpp"
1117
)
@@ -17,16 +23,6 @@ add_library(
1723
${android_files}
1824
)
1925

20-
include_directories(
21-
../cpp
22-
# Android-specific C++ includes
23-
src/main/cpp/core
24-
src/main/cpp/registry
25-
src/main/cpp/turbomodule
26-
src/main/cpp/platform
27-
src/main/cpp/utils
28-
src/main/cpp/views
29-
)
3026

3127
find_package(ReactAndroid REQUIRED CONFIG)
3228
find_package(fbjni REQUIRED CONFIG)

android/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ android {
6969
}
7070
}
7171

72-
7372
prefab {
7473
"op-server" {
7574
headers "${project.buildDir}/headers/op-server/"

cpp/Request.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,4 @@ jsi::Value Request::get(jsi::Runtime &rt, const jsi::PropNameID &propNameID) {
6565
return jsi::Value::undefined();
6666
}
6767

68-
void Request::set(jsi::Runtime &rt, const jsi::PropNameID &name,
69-
const jsi::Value &value) {
70-
// Request is read-only from JS side
71-
throw jsi::JSError(rt, "Request object is read-only");
72-
}
73-
7468
} // namespace opserver

cpp/Request.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ namespace jsi = facebook::jsi;
1111

1212
class JSI_EXPORT Request : public jsi::HostObject {
1313
public:
14-
Request(const httplib::Request &req);
14+
explicit Request(const httplib::Request &req);
1515

1616
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
1717
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propNameID) override;
18-
void set(jsi::Runtime &rt, const jsi::PropNameID &name,
19-
const jsi::Value &value) override;
2018

2119
private:
2220
std::string method;

cpp/Response.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#pragma clang diagnostic push
2+
#pragma clang diagnostic ignored "-Wunused-parameter"
3+
14
#include "Response.hpp"
25
#include "macros.hpp"
36

@@ -23,7 +26,7 @@ jsi::Value Response::get(jsi::Runtime &rt, const jsi::PropNameID &propNameID) {
2326
const auto name = propNameID.utf8(rt);
2427

2528
if (name == "statusCode") {
26-
return jsi::Value(statusCode);
29+
return {statusCode};
2730
}
2831

2932
if (name == "content") {
@@ -90,11 +93,13 @@ void Response::set(jsi::Runtime &rt, const jsi::PropNameID &propNameID,
9093

9194
void Response::applyTo(httplib::Response &res) {
9295
res.status = statusCode;
93-
res.set_content(content, contentType.c_str());
96+
res.set_content(content, contentType);
9497

9598
for (const auto &header : headers) {
96-
res.set_header(header.first.c_str(), header.second.c_str());
99+
res.set_header(header.first, header.second);
97100
}
98101
}
99102

100103
} // namespace opserver
104+
105+
#pragma clang diagnostic pop

cpp/Server.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#pragma once
1+
#pragma clang diagnostic push
2+
#pragma clang diagnostic ignored "-Wunused-parameter"
23

34
#include "Server.hpp"
45
#include "Request.hpp"
@@ -12,14 +13,13 @@ namespace opserver {
1213
namespace jsi = facebook::jsi;
1314
namespace react = facebook::react;
1415

15-
Server::Server(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker) {
16-
16+
Server::Server(jsi::Runtime &rt, const std::shared_ptr<react::CallInvoker>& invoker) {
1717
function_map["callback"] = HFN2(this, invoker) {
1818
const std::string method = args[0].asString(rt).utf8(rt);
1919
const std::string path = args[1].asString(rt).utf8(rt);
2020
auto callback = std::make_shared<jsi::Value>(rt, args[2]);
2121

22-
auto handleRequest = [this, &rt, invoker,
22+
auto handleRequest = [invoker,
2323
callback](const httplib::Request &req,
2424
httplib::Response &res) {
2525
auto responseDone = std::make_shared<std::promise<void>>();
@@ -148,15 +148,8 @@ jsi::Value Server::get(jsi::Runtime &rt, const jsi::PropNameID &propNameID) {
148148
return {rt, function_map[name]};
149149
}
150150

151-
void Server::set(jsi::Runtime &_rt, const jsi::PropNameID &name,
152-
const jsi::Value &value) {
153-
throw std::runtime_error("You cannot write to this object!");
154-
}
155-
156151
void Server::stop() { server.stop(); }
157152

158-
Server::~Server() {
159-
160-
};
161-
162153
} // namespace opserver
154+
155+
#pragma clang diagnostic pop

cpp/Server.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ namespace react = facebook::react;
1313

1414
class JSI_EXPORT Server : public jsi::HostObject {
1515
public:
16-
Server(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker);
16+
Server(jsi::Runtime &rt, const std::shared_ptr<react::CallInvoker>& invoker);
1717
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
1818
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propNameID) override;
19-
void set(jsi::Runtime &rt, const jsi::PropNameID &name,
20-
const jsi::Value &value) override;
2119
void stop();
22-
~Server() override;
2320

2421
private:
2522
httplib::Server server;

cpp/bindings.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <unordered_map>
66
#include <vector>
77

8+
#pragma clang diagnostic push
9+
#pragma clang diagnostic ignored "-Wunused-parameter"
810
namespace opserver {
911

1012
namespace jsi = facebook::jsi;
@@ -39,3 +41,5 @@ void install(jsi::Runtime &rt,
3941
}
4042

4143
} // namespace opserver
44+
45+
#pragma clang diagnostic pop

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@op-engineering/op-server",
3-
"private": false,
4-
"version": "0.1.4",
3+
"version": "0.1.5",
54
"description": "Fast HTTP Server for React Native",
65
"main": "./lib/module/index.js",
76
"types": "./lib/typescript/src/index.d.ts",
@@ -55,6 +54,7 @@
5554
},
5655
"homepage": "https://github.com/OP-Engineering/op-server#readme",
5756
"publishConfig": {
57+
"access": "public",
5858
"registry": "https://registry.npmjs.org/"
5959
},
6060
"devDependencies": {

turbo.json

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)