Skip to content

Commit

Permalink
Fix clang reported warnings
Browse files Browse the repository at this point in the history
matusnovak committed Apr 21, 2020
1 parent bc7c2c7 commit c0b71dc
Showing 9 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ install/
.vs/
*.kdev4
*~
CMakeSettings.json

# doxygen
docs/doxygen/*.md
1 change: 0 additions & 1 deletion include/wrenbind17/foreign.hpp
Original file line number Diff line number Diff line change
@@ -210,7 +210,6 @@ namespace wrenbind17 {
~ForeignMethodImpl() = default;

void generate(std::ostream& os) const override {
constexpr auto n = sizeof...(Args);
os << " foreign " << (isStatic ? "static " : "") << signature << "\n";
}

4 changes: 4 additions & 0 deletions include/wrenbind17/push.hpp
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ namespace wrenbind17 {

auto memory = wrenSetSlotNewForeign(vm, idx, idx, sizeof(ForeignObject<T>));
auto* foreign = new (memory) ForeignObject<T>(std::make_shared<T>(value));
(void)foreign;
} catch (std::out_of_range& e) {
(void)e;
throw BadCast("Class type not registered in Wren VM");
@@ -49,6 +50,7 @@ namespace wrenbind17 {

auto memory = wrenSetSlotNewForeign(vm, idx, idx, sizeof(ForeignObject<T>));
auto* foreign = new (memory) ForeignObject<T>(std::make_shared<T>(std::move(value)));
(void)foreign;
} catch (std::out_of_range& e) {
(void)e;
throw BadCast("Class type not registered in Wren VM");
@@ -69,6 +71,7 @@ namespace wrenbind17 {

auto memory = wrenSetSlotNewForeign(vm, idx, idx, sizeof(ForeignObject<T>));
auto* foreign = new (memory) ForeignObject<T>(std::shared_ptr<T>(value, [](T* t) {}));
(void)foreign;
} catch (std::out_of_range& e) {
(void)e;
throw BadCast("Class type not registered in Wren VM");
@@ -216,6 +219,7 @@ namespace wrenbind17 {

auto memory = wrenSetSlotNewForeign(vm, idx, idx, sizeof(ForeignObject<T>));
auto* foreign = new (memory) ForeignObject<T>(value);
(void)foreign;
} catch (std::out_of_range& e) {
(void)e;
throw BadCast("Class type not registered in Wren VM");
2 changes: 2 additions & 0 deletions tests/any.cpp
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ TEST_CASE("Returning bad any must throw correct exception") {
wren::VM vm;
auto& m = vm.module("test");
auto& c = m.klass<HelloClass>("HelloClass");
(void)c;

vm.runFromSource("main", code);
auto main = vm.find("main", "Main").func("main()");

2 changes: 1 addition & 1 deletion tests/example.cpp
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ namespace wren = wrenbind17;

class MyFoo {
public:
MyFoo(const int year, const std::string& message) : year(year), message(message), type("MyFoo") {
MyFoo(const int year, const std::string& message) : message(message), year(year), type("MyFoo") {
}

std::string message;
2 changes: 2 additions & 0 deletions tests/inheritance.cpp
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ TEST_CASE("Inheritance") {
wren::VM vm;
auto& m = vm.module("test");
auto& cls = m.klass<BaseClass>("BaseClass");
(void)cls;

auto& cls2 = m.klass<DerivedClass, BaseClass>("DerivedClass");
cls2.ctor<>();
@@ -75,6 +76,7 @@ TEST_CASE("Inheritance with shared_ptr") {
wren::VM vm;
auto& m = vm.module("test");
auto& cls = m.klass<BaseClass>("BaseClass");
(void)cls;

auto& cls2 = m.klass<DerivedClass, BaseClass>("DerivedClass");
cls2.ctor<>();
4 changes: 2 additions & 2 deletions tests/noncopyable.cpp
Original file line number Diff line number Diff line change
@@ -7,11 +7,11 @@ static int counter = 0;

class NonCopyable {
public:
NonCopyable(const std::string& name) : name(name), parent(nullptr) {
NonCopyable(const std::string& name) : parent(nullptr), name(name) {
counter++;
id = size_t(this);
}
NonCopyable(const std::string& name, NonCopyable& parent) : name(name), parent(&parent) {
NonCopyable(const std::string& name, NonCopyable& parent) : parent(&parent), name(name) {
counter++;
id = size_t(this);
}
2 changes: 1 addition & 1 deletion tests/shared.cpp
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ class SomeClass {
counter++;
id = size_t(this);
}
SomeClass(const std::string& name, std::shared_ptr<SomeClass> parent) : name(name), parent(std::move(parent)) {
SomeClass(const std::string& name, std::shared_ptr<SomeClass> parent) : parent(std::move(parent)), name(name) {
counter++;
id = size_t(this);
}
1 change: 0 additions & 1 deletion tests/slots_classes.cpp
Original file line number Diff line number Diff line change
@@ -124,7 +124,6 @@ TEST_CASE("String slots") {

SECTION("String by const ref") {
auto s = std::string("Hello World");
const auto& ref = s;
constRef(s);
REQUIRE(Foo::str == "Hello World");
Foo::str.clear();

0 comments on commit c0b71dc

Please sign in to comment.