Skip to content

Commit

Permalink
Merge pull request #112 from bmcpt/sg_mul_val_c_api
Browse files Browse the repository at this point in the history
SG_MUL_VAL_ c api and sigstksz.h workaround
  • Loading branch information
xR3b0rn authored Sep 2, 2022
2 parents 067abf5 + 0ad2997 commit 1d6ab9f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
10 changes: 10 additions & 0 deletions include/dbcppp/CApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ extern "C"
typedef struct {} dbcppp_Attribute;
typedef struct {} dbcppp_SignalType;
typedef struct {} dbcppp_Signal;
typedef struct {} dbcppp_SignalMultiplexerValue;
typedef struct {
uint64_t from;
uint64_t to;
} dbcppp_ValueRange;
typedef struct {} dbcppp_ValueEncodingDescription;

DBCPPP_API const dbcppp_Attribute* dbcppp_AttributeCreate(
Expand Down Expand Up @@ -235,6 +240,11 @@ extern "C"
DBCPPP_API const char* dbcppp_SignalName(const dbcppp_Signal* sig);
DBCPPP_API dbcppp_ESignalMultiplexer dbcppp_SignalMultiplexerIndicator(const dbcppp_Signal* sig);
DBCPPP_API uint64_t dbcppp_SignalMultiplexerSwitchValue(const dbcppp_Signal* sig);
DBCPPP_API uint64_t dbcppp_SignalMultiplexerValues_Size(const dbcppp_Signal* sig);
DBCPPP_API const dbcppp_SignalMultiplexerValue* dbcppp_SignalMultiplexerValues_Get(const dbcppp_Signal* sig, uint64_t i);
DBCPPP_API const char* dbcppp_SignalMultiplexerValue_SwitchName(const dbcppp_SignalMultiplexerValue* mux_val);
DBCPPP_API uint64_t dbcppp_SignalMultiplexerValue_ValueRanges_Size(const dbcppp_SignalMultiplexerValue* mux_val);
DBCPPP_API const dbcppp_ValueRange* dbcppp_SignalMultiplexerValue_ValueRanges_Get(const dbcppp_SignalMultiplexerValue* mux_val, uint64_t i);
DBCPPP_API uint64_t dbcppp_SignalStartBit(const dbcppp_Signal* sig);
DBCPPP_API uint64_t dbcppp_SignalBitSize(const dbcppp_Signal* sig);
DBCPPP_API dbcppp_ESignalByteOrder dbcppp_SignalByteOrder(const dbcppp_Signal* sig);
Expand Down
2 changes: 1 addition & 1 deletion include/dbcppp/SignalMultiplexerValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace dbcppp
virtual std::unique_ptr<ISignalMultiplexerValue> Clone() const = 0;

virtual ~ISignalMultiplexerValue() = default;
virtual std::string SwitchName() const = 0;
virtual const std::string& SwitchName() const = 0;
virtual const Range& ValueRanges_Get(std::size_t i) const = 0;
virtual uint64_t ValueRanges_Size() const = 0;

Expand Down
29 changes: 27 additions & 2 deletions src/libdbcppp/CApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extern "C"
case IAttributeDefinition::EObjectType::Node: return dbcppp_EObjectType::dbcppp_ObjectType_Node;
case IAttributeDefinition::EObjectType::Message: return dbcppp_EObjectType::dbcppp_ObjectType_Message;
case IAttributeDefinition::EObjectType::Signal: return dbcppp_EObjectType::dbcppp_ObjectType_Signal;
default: return dbcppp_EObjectType::dbcppp_ObjectType_EnvironmentVariable;
default: return dbcppp_EObjectType::dbcppp_ObjectType_EnvironmentVariable;
}
}
DBCPPP_API dbcppp_EAttributeValueType dbcppp_AttributeValueType(const dbcppp_Attribute* attribute)
Expand Down Expand Up @@ -88,7 +88,7 @@ extern "C"
auto ai = reinterpret_cast<const AttributeImpl*>(attribute);
return std::get<std::string>(ai->Value()).c_str();
}

DBCPPP_API dbcppp_AttributeDefinition* dbcppp_AttributeDefinitionCreate(
const char* name
, dbcppp_EObjectType object_type
Expand Down Expand Up @@ -879,6 +879,31 @@ extern "C"
auto sigi = reinterpret_cast<const SignalImpl*>(sig);
return sigi->MultiplexerSwitchValue();
}
DBCPPP_API uint64_t dbcppp_SignalMultiplexerValues_Size(const dbcppp_Signal* sig)
{
auto sigi = reinterpret_cast<const SignalImpl*>(sig);
return sigi->SignalMultiplexerValues_Size();
}
DBCPPP_API const dbcppp_SignalMultiplexerValue* dbcppp_SignalMultiplexerValues_Get(const dbcppp_Signal* sig, uint64_t i)
{
auto sigi = reinterpret_cast<const SignalImpl*>(sig);
return reinterpret_cast<const dbcppp_SignalMultiplexerValue*>(&sigi->SignalMultiplexerValues_Get(i));
}
DBCPPP_API const char* dbcppp_SignalMultiplexerValue_SwitchName(const dbcppp_SignalMultiplexerValue* mux_val)
{
auto sigi = reinterpret_cast<const ISignalMultiplexerValue*>(mux_val);
return sigi->SwitchName().c_str();
}
DBCPPP_API uint64_t dbcppp_SignalMultiplexerValue_ValueRanges_Size(const dbcppp_SignalMultiplexerValue* mux_val)
{
auto sigi = reinterpret_cast<const ISignalMultiplexerValue*>(mux_val);
return sigi->ValueRanges_Size();
}
DBCPPP_API const dbcppp_ValueRange* dbcppp_SignalMultiplexerValue_ValueRanges_Get(const dbcppp_SignalMultiplexerValue* mux_val, uint64_t i)
{
auto sigi = reinterpret_cast<const ISignalMultiplexerValue*>(mux_val);
return reinterpret_cast<const dbcppp_ValueRange*>(&sigi->ValueRanges_Get(i));
}
DBCPPP_API uint64_t dbcppp_SignalStartBit(const dbcppp_Signal* sig)
{
auto sigi = reinterpret_cast<const SignalImpl*>(sig);
Expand Down
2 changes: 1 addition & 1 deletion src/libdbcppp/SignalMultiplexerValueImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ std::unique_ptr<ISignalMultiplexerValue> SignalMultiplexerValueImpl::Clone() con
return std::make_unique<SignalMultiplexerValueImpl>(*this);
}

std::string SignalMultiplexerValueImpl::SwitchName() const
const std::string& SignalMultiplexerValueImpl::SwitchName() const
{
return _switch_name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libdbcppp/SignalMultiplexerValueImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace dbcppp

virtual std::unique_ptr<ISignalMultiplexerValue> Clone() const override;

virtual std::string SwitchName() const override;
virtual const std::string& SwitchName() const override;
virtual const Range& ValueRanges_Get(std::size_t i) const override;
virtual uint64_t ValueRanges_Size() const override;

Expand Down
4 changes: 4 additions & 0 deletions tests/Catch2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3742,6 +3742,10 @@ PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr;

#elif defined( CATCH_CONFIG_POSIX_SIGNALS )

// https://stackoverflow.com/questions/71454588/minsigstksz-error-after-update-in-my-manjaro-linux
#undef MINSIGSTKSZ
#define MINSIGSTKSZ 65536

namespace Catch {

struct SignalDefs {
Expand Down

0 comments on commit 1d6ab9f

Please sign in to comment.