Skip to content

Commit

Permalink
keep fixing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrec committed Oct 29, 2024
1 parent b81f76c commit f0cff49
Show file tree
Hide file tree
Showing 51 changed files with 141 additions and 128 deletions.
18 changes: 8 additions & 10 deletions embedded/CreateEmbeddedSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ int main(int argc, char* argv[]) {
return 1;
}

auto* infile = argv[1];
const auto* infile = argv[1];
auto* outfile = argv[2];
auto* filenum = argv[3];
auto* embeddedname = argv[4];
const auto* filenum = argv[3];
const auto* embeddedname = argv[4];

int ret, flush;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
Expand All @@ -41,7 +39,7 @@ int main(int argc, char* argv[]) {
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
int ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
if (ret != Z_OK) return 1;

FILE* source = fopen(infile, "rb");
Expand All @@ -52,11 +50,11 @@ int main(int argc, char* argv[]) {

std::fstream outstream(outfile, std::fstream::out | std::fstream::trunc);

// This is the compressed length in chars;
unsigned length = 0;

if (outstream.is_open()) {
outstream << "static const uint8_t embedded_file_" << filenum << "[] = {";
int flush = 0;
// This is the compressed length in chars;
unsigned length = 0;
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
Expand All @@ -73,7 +71,7 @@ int main(int argc, char* argv[]) {
strm.next_out = out;
ret = deflate(&strm, flush); /* no bad return value */
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
have = CHUNK - strm.avail_out;
unsigned have = CHUNK - strm.avail_out;

for (unsigned i = 0; i != have; ++i) {
if (length != 0) {
Expand Down
12 changes: 7 additions & 5 deletions python/engine/PythonEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ spec.loader.exec_module(module)
return result;
}

int PythonEngine::numberOfArguments(ScriptObject& classInstanceObject, std::string_view methodName) {
int PythonEngine::numberOfArguments(ScriptObject& methodObject, std::string_view methodName) {

int numberOfArguments = -1;

auto val = std::any_cast<PythonObject>(classInstanceObject.object);
auto val = std::any_cast<PythonObject>(methodObject.object);
if (PyObject_HasAttrString(val.obj_, methodName.data()) == 0) {
// FAILED
return numberOfArguments;
Expand All @@ -386,13 +386,15 @@ int PythonEngine::numberOfArguments(ScriptObject& classInstanceObject, std::stri
if (PyMethod_Check(method)) {
PyObject* func = PyMethod_Function(method); // Borrowed
if (auto* code = PyFunction_GetCode(func)) { // Borrowed
auto* co = (PyCodeObject*)code;
// cppcheck-suppress cstyleCast
const auto* co = (PyCodeObject*)code;
numberOfArguments = co->co_argcount - 1; // This includes `self`
}
} else if (PyFunction_Check(method)) {
// Shouldn't enter this block here
if (auto code = PyFunction_GetCode(method)) {
auto* co = (PyCodeObject*)code;
if (auto * code = PyFunction_GetCode(method)) {
// cppcheck-suppress cstyleCast
const auto* co = (PyCodeObject*)code;
numberOfArguments = co->co_argcount;
}
}
Expand Down
12 changes: 6 additions & 6 deletions python/engine/test/PythonEngine_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#include <gtest/gtest.h>

#include "measure/ModelMeasure.hpp"
#include "measure/OSArgument.hpp"
#include "measure/OSMeasure.hpp"
#include "measure/OSRunner.hpp"
#include "model/Model.hpp"
#include "scriptengine/ScriptEngine.hpp"
#include "../../../src/measure/ModelMeasure.hpp"
#include "../../../src/measure/OSArgument.hpp"
#include "../../../src/measure/OSMeasure.hpp"
#include "../../../src/measure/OSRunner.hpp"
#include "../../../src/model/Model.hpp"
#include "../../../src/scriptengine/ScriptEngine.hpp"

#include <fmt/format.h>

Expand Down
2 changes: 1 addition & 1 deletion ruby/bindings/InitRubyBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
***********************************************************************************************************************/

#include "InitRubyBindings.hpp"
#include "RubyEval.hpp"
#include "../interpreter/RubyEval.hpp"

// #define HAVE_ISFINITE 1
#include <ruby.h>
Expand Down
4 changes: 2 additions & 2 deletions ruby/engine/RubyEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
***********************************************************************************************************************/

#include "RubyEngine.hpp"
#include "InitRubyBindings.hpp"
#include "RubyException.hpp"
#include "../bindings/InitRubyBindings.hpp"
#include "../interpreter/RubyException.hpp"
#include <embedded_files.hxx>
#include <csignal>
#include <stdexcept>
Expand Down
10 changes: 5 additions & 5 deletions ruby/engine/test/RubyEngine_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

#include <gtest/gtest.h>

#include "measure/ModelMeasure.hpp"
#include "measure/OSArgument.hpp"
#include "measure/OSMeasure.hpp"
#include "model/Model.hpp"
#include "scriptengine/ScriptEngine.hpp"
#include "../../../src/measure/ModelMeasure.hpp"
#include "../../../src/measure/OSArgument.hpp"
#include "../../../src/measure/OSMeasure.hpp"
#include "../../../src/model/Model.hpp"
#include "../../../src/scriptengine/ScriptEngine.hpp"

#include <fmt/format.h>

Expand Down
20 changes: 10 additions & 10 deletions ruby/interpreter/RubyEval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#ifndef RUBYEVAL_included
#define RUBYEVAL_included

#include "ruby.h"
#include "./RubyException.hpp"
#include <ruby.h>
#include "RubyException.hpp"

namespace openstudio {

Expand Down Expand Up @@ -49,21 +49,21 @@ inline VALUE evalString(const std::string& t_str) {
// Generally speaking, the backtrace is there, but not for the case where it's a stack too deep error
const ID ID_backtrace = rb_intern_const("backtrace");
if (exception_class != rb_eSysStackError && rb_respond_to(errinfo, ID_backtrace)) {
std::vector<std::string> backtrace_lines;
// std::vector<std::string> backtrace_lines;
std::string btlines;
/*volatile*/ VALUE backtrace;
if (!NIL_P(backtrace = rb_funcall(errinfo, ID_backtrace, 0))) {
VALUE backtracejoin = rb_ary_join(backtrace, rb_str_new2("\n"));
btlines = StringValuePtr(backtracejoin);

// Get the backing C array of the ruby array
VALUE* elements = RARRAY_PTR(backtrace);
for (long c = 0; c < RARRAY_LEN(backtrace); ++c) {
VALUE entry = elements[c];
[[maybe_unused]] char* backtrace_line = RSTRING_PTR(entry);
char* backtrace_line2 = StringValuePtr(entry);
backtrace_lines.emplace_back(backtrace_line2);
}
// VALUE* elements = RARRAY_PTR(backtrace);
// for (long c = 0; c < RARRAY_LEN(backtrace); ++c) {
// VALUE entry = elements[c];
// [[maybe_unused]] char* backtrace_line = RSTRING_PTR(entry);
// char* backtrace_line2 = StringValuePtr(entry);
// backtrace_lines.emplace_back(backtrace_line2);
// }
}

if (!btlines.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion ruby/module/openstudio_rb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* See also https://openstudio.net/license
***********************************************************************************************************************/

#include "InitRubyBindings.hpp"
#include "../bindings/InitRubyBindings.hpp"
#include <RubyAPI.hpp>
#include <iostream>
#include <ruby.h>
Expand Down
4 changes: 2 additions & 2 deletions src/airflow/contam/PrjReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace contam {
// template <class T> QVector<T> readSectionQVector(STRING name=STRING_INIT);
// template <class T> std::vector<T> readSectionStdVector(STRING name=STRING_INIT);
template <class T>
std::vector<std::shared_ptr<T>> readElementVector(std::string name = std::string());
std::vector<std::shared_ptr<T>> readElementVector(const std::string& name = std::string());
template <class T>
T read();
template <class T>
Expand Down Expand Up @@ -162,7 +162,7 @@ namespace contam {
//}

template <class T>
std::vector<std::shared_ptr<T>> Reader::readElementVector(std::string name) {
std::vector<std::shared_ptr<T>> Reader::readElementVector(const std::string& name) {
int n = readInt();
std::vector<std::shared_ptr<T>> vector;
for (int i = 0; i < n; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/gltf/GltfUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace gltf {

// Creates Coordinates / Normal Buffers and Accessors.
// returns : index
int createBuffers(std::vector<float>& values, std::vector<unsigned char>& coordinatesBuffer, std::vector<tinygltf::Accessor>& accessors) {
int createBuffers(const std::vector<float>& values, std::vector<unsigned char>& coordinatesBuffer, std::vector<tinygltf::Accessor>& accessors) {
// Fixes ACCESSOR_TOTAL_OFFSET_ALIGNMENT
// Accessor's total byteOffset XXXX isn't a multiple of componentType length 4.
auto _padding = coordinatesBuffer.size() % 4;
Expand Down
2 changes: 1 addition & 1 deletion src/gltf/GltfUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace gltf {
// std::vector<tinygltf::Accessor>& accessors);
// int addNormals(const std::vector<Vector3d>& normalVectors, std::vector<unsigned char>& coordinatesBuffer,
// std::vector<tinygltf::Accessor>& accessors);
// int createBuffers(std::vector<float>& values, std::vector<unsigned char>& coordinatesBuffer, std::vector<tinygltf::Accessor>& accessors);
// int createBuffers(const std::vector<float>& values, std::vector<unsigned char>& coordinatesBuffer, std::vector<tinygltf::Accessor>& accessors);
};
} // namespace detail

Expand Down
3 changes: 1 addition & 2 deletions src/install_utility/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ inline std::string applicationFilePath() {
return {};
}

int main(int argc, char* argv[]) {
int main(int argc, const char* argv[]) {

#ifdef __APPLE__
if (argc > 1u) {
openstudio::filesystem::path appDir = openstudio::filesystem::path(applicationFilePath()).parent_path();
openstudio::filesystem::path cliPath = appDir / "openstudio";
openstudio::filesystem::path appPath = appDir.parent_path() / "OpenStudioApp.app";

if (std::string(argv[1]) == "Install") {
try {
Expand Down
9 changes: 5 additions & 4 deletions src/isomodel/SimModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "SimModel.hpp"

#include <cmath>
#include <array>

#if _DEBUG || (__GNUC__ && !NDEBUG)
# define DEBUG_ISO_MODEL_SIMULATION
Expand Down Expand Up @@ -577,7 +578,7 @@ v_wall_alpha_sc =In.wall_solar_alpha; %wall solar absorption coefficient
double n_win_ff = 0.25;
Vector v_win_ff = Vector(vsize);

double n_win_SDF_table[] = {0.5, 0.35, 1.0};
constexpr std::array<double, 3> n_win_SDF_table = {0.5, 0.35, 1.0};
Vector v_win_SDF = Vector(vsize);
Vector v_win_SDF_frac = Vector(vsize);

Expand Down Expand Up @@ -734,7 +735,7 @@ end
for (size_t i = 0; i < theta_er.size(); i++) {
theta_er[i] = 11.0;
}
double n_v_env_form_factors[] = {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1};
constexpr std::array<double, 9> n_v_env_form_factors = {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1};

Vector v_wall_phi_r = mult(mult(mult(mult(v_wall_R_sc, v_wall_U), v_wall_A), v_win_hr), theta_er);
Vector v_wall_phi_sol(12);
Expand Down Expand Up @@ -1840,11 +1841,11 @@ v_Qcl_gas_tot = v_Qcl_DC_abs; % total gas cooliing energy
*/
Vector v_frac_tot = div(sum(v_Qneed_ht, v_Qneed_cl), Qneed_ht_yr + Qneed_cl_yr);
double frac_total = sum(v_frac_tot);
double Q_pumps_tot = Q_pumps_ht + Q_pumps_cl;
if (Q_pumps_ht == 0 || Q_pumps_cl == 0) {
v_Q_pump_tot = sum(v_Q_pumps_ht, v_Q_pumps_cl);
} else {
const double Q_pumps_tot = Q_pumps_ht + Q_pumps_cl;
const double frac_total = sum(v_frac_tot);
v_Q_pump_tot = div(mult(v_frac_tot, Q_pumps_tot), frac_total);
}
/*
Expand Down
2 changes: 1 addition & 1 deletion src/isomodel/UserModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,9 @@ namespace isomodel {
}
}
void UserModel::loadBuilding(const openstudio::path& t_buildingFile) {
string line;
ifstream inputFile(openstudio::toSystemFilename(t_buildingFile));
if (inputFile.is_open()) {
std::string line;
while (inputFile.good()) {
getline(inputFile, line);
if (!line.empty() && line[0] == '#') {
Expand Down
10 changes: 5 additions & 5 deletions src/model/AirflowNetworkDetailedOpening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ namespace model {
OS_ASSERT(result);
}

bool AirflowNetworkDetailedOpening_Impl::setOpeningFactors(std::vector<DetailedOpeningFactorData>& factors) {
bool AirflowNetworkDetailedOpening_Impl::setOpeningFactors(const std::vector<DetailedOpeningFactorData>& factors) {
// Number of Sets of Opening Factor Data
if (factors.size() < 2) {
LOG(Error, "Insufficient data in opening factors vector, minimum number of factors is 2");
Expand Down Expand Up @@ -254,7 +254,7 @@ namespace model {
double massFlowExponentWhenOpeningisClosed,
const std::string& typeofRectangularLargeVerticalOpening,
double extraCrackLengthorHeightofPivotingAxis,
std::vector<DetailedOpeningFactorData>& openingFactors)
const std::vector<DetailedOpeningFactorData>& openingFactors)
: AirflowNetworkComponent(AirflowNetworkDetailedOpening::iddObjectType(), model) {
OS_ASSERT(getImpl<detail::AirflowNetworkDetailedOpening_Impl>());

Expand All @@ -271,7 +271,7 @@ namespace model {
}

AirflowNetworkDetailedOpening::AirflowNetworkDetailedOpening(const Model& model, double massFlowCoefficientWhenOpeningisClosed,
std::vector<DetailedOpeningFactorData>& openingFactors)
const std::vector<DetailedOpeningFactorData>& openingFactors)
: AirflowNetworkComponent(AirflowNetworkDetailedOpening::iddObjectType(), model) {
OS_ASSERT(getImpl<detail::AirflowNetworkDetailedOpening_Impl>());

Expand Down Expand Up @@ -351,13 +351,13 @@ namespace model {
getImpl<detail::AirflowNetworkDetailedOpening_Impl>()->resetExtraCrackLengthorHeightofPivotingAxis();
}

bool AirflowNetworkDetailedOpening::setOpeningFactors(std::vector<DetailedOpeningFactorData>& factors) {
bool AirflowNetworkDetailedOpening::setOpeningFactors(const std::vector<DetailedOpeningFactorData>& factors) {
return getImpl<detail::AirflowNetworkDetailedOpening_Impl>()->setOpeningFactors(factors);
}

/// @cond
AirflowNetworkDetailedOpening::AirflowNetworkDetailedOpening(std::shared_ptr<detail::AirflowNetworkDetailedOpening_Impl> impl)
: AirflowNetworkComponent(impl) {}
: AirflowNetworkComponent(std::move(impl)) {}
/// @endcond

} // namespace model
Expand Down
6 changes: 3 additions & 3 deletions src/model/AirflowNetworkDetailedOpening.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ namespace model {
/** Construct a detailed opening object. */
AirflowNetworkDetailedOpening(const Model& model, double massFlowCoefficientWhenOpeningisClosed, double massFlowExponentWhenOpeningisClosed,
const std::string& typeofRectangularLargeVerticalOpening, double extraCrackLengthorHeightofPivotingAxis,
std::vector<DetailedOpeningFactorData>& openingFactors);
const std::vector<DetailedOpeningFactorData>& openingFactors);
/** Construct a detailed opening object with defaulted values. */
AirflowNetworkDetailedOpening(const Model& model, double massFlowCoefficientWhenOpeningisClosed,
std::vector<DetailedOpeningFactorData>& openingFactors);
const std::vector<DetailedOpeningFactorData>& openingFactors);

virtual ~AirflowNetworkDetailedOpening() override = default;
// Default the copy and move operators because the virtual dtor is explicit
Expand Down Expand Up @@ -137,7 +137,7 @@ namespace model {
/** Resets the extra crack length or height of pivoting axis. */
void resetExtraCrackLengthorHeightofPivotingAxis();
/** Sets the opening factor data. */
bool setOpeningFactors(std::vector<DetailedOpeningFactorData>& factors);
bool setOpeningFactors(const std::vector<DetailedOpeningFactorData>& factors);

//@}
protected:
Expand Down
2 changes: 1 addition & 1 deletion src/model/AirflowNetworkDetailedOpening_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace model {

void resetExtraCrackLengthorHeightofPivotingAxis();

bool setOpeningFactors(std::vector<DetailedOpeningFactorData>& factors);
bool setOpeningFactors(const std::vector<DetailedOpeningFactorData>& factors);

//@}
protected:
Expand Down
2 changes: 1 addition & 1 deletion src/model/RadianceParameters_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace model {

RadianceParameters_Impl(const RadianceParameters_Impl& other, Model_Impl* model, bool keepHandle);

virtual ~RadianceParameters_Impl();
virtual ~RadianceParameters_Impl() override;

//@}

Expand Down
2 changes: 2 additions & 0 deletions src/model/TableMultiVariableLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,10 +1266,12 @@ namespace model {
getImpl<detail::TableMultiVariableLookup_Impl>()->resetOutputUnitType();
}

// cppcheck-suppress [duplInheritedMember] this is overriden for documentation purposes
int TableMultiVariableLookup::numVariables() const {
return getImpl<detail::TableMultiVariableLookup_Impl>()->numVariables();
}

// cppcheck-suppress [duplInheritedMember] this is overriden for documentation purposes
double TableMultiVariableLookup::evaluate(const std::vector<double>& x) const {
return getImpl<detail::TableMultiVariableLookup_Impl>()->evaluate(x);
}
Expand Down
1 change: 1 addition & 0 deletions src/nano/nano_observer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Observer
head = new SSNode{{key, obs}, head};
}

// cppcheck-suppress constParameterPointer
void remove(DelegateKey const& key, Observer* obs) {
SSNode* node = head;
SSNode* prev = nullptr;
Expand Down
Loading

0 comments on commit f0cff49

Please sign in to comment.