Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for unity builds #407

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libshvbroker/src/openldap_dynamic.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include <ldap.h>
namespace shv::ldap::OpenLDAP {
// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
Expand Down
10 changes: 5 additions & 5 deletions libshvchainpack/c/cchainpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ static void unpack_uint(ccpcp_unpack_context* unpack_context, int *pbitlen)
*pbitlen = bitlen;
}

static void unpack_int(ccpcp_unpack_context* unpack_context, int64_t *pval)
static void ccpcp_unpack_int(ccpcp_unpack_context* unpack_context, int64_t *pval)
{
int64_t snum = 0;
int bitlen;
Expand Down Expand Up @@ -584,7 +584,7 @@ void cchainpack_unpack_next (ccpcp_unpack_context* unpack_context)
}
case CP_Int: {
int64_t n;
unpack_int(unpack_context, &n);
ccpcp_unpack_int(unpack_context, &n);
unpack_context->item.type = CCPCP_ITEM_INT;
unpack_context->item.as.Int = n;
break;
Expand Down Expand Up @@ -617,17 +617,17 @@ void cchainpack_unpack_next (ccpcp_unpack_context* unpack_context)
}
case CP_Decimal: {
int64_t mant;
unpack_int(unpack_context, &mant);
ccpcp_unpack_int(unpack_context, &mant);
int64_t exp;
unpack_int(unpack_context, &exp);
ccpcp_unpack_int(unpack_context, &exp);
unpack_context->item.type = CCPCP_ITEM_DECIMAL;
unpack_context->item.as.Decimal.mantisa = mant;
unpack_context->item.as.Decimal.exponent = (int)exp;
break;
}
case CP_DateTime: {
int64_t d;
unpack_int(unpack_context, &d);
ccpcp_unpack_int(unpack_context, &d);
int8_t offset = 0;
bool has_tz_offset = d & 1;
bool has_not_msec = d & 2;
Expand Down
6 changes: 3 additions & 3 deletions libshvchainpack/c/ccpcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ double ccpcp_decimal_to_double(const int64_t mantisa, const int exponent)
return ccpcp_exponentional_to_double(mantisa, exponent, 10);
}

static size_t int_to_str(char *buff, size_t buff_len, int64_t val)
static size_t ccpcp_int_to_str(char *buff, size_t buff_len, int64_t val)
{
size_t n = 0;
bool neg = false;
Expand Down Expand Up @@ -356,7 +356,7 @@ size_t ccpcp_decimal_to_string(char *buff, size_t buff_len, int64_t mantisa, int
str++;
buff_len--;
}
size_t mantisa_str_len = int_to_str(str, buff_len, mantisa);
size_t mantisa_str_len = ccpcp_int_to_str(str, buff_len, mantisa);
if(mantisa_str_len == 0) {
return mantisa_str_len;
}
Expand Down Expand Up @@ -389,7 +389,7 @@ size_t ccpcp_decimal_to_string(char *buff, size_t buff_len, int64_t mantisa, int
}
else {
str[mantisa_str_len++] = 'e';
size_t n2 = int_to_str(str+mantisa_str_len, buff_len - mantisa_str_len, exponent);
size_t n2 = ccpcp_int_to_str(str+mantisa_str_len, buff_len - mantisa_str_len, exponent);
if(n2 == 0) {
return n2;
}
Expand Down
24 changes: 12 additions & 12 deletions libshvchainpack/c/ccpon.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ const char* ccpon_unpack_skip_insignificant(ccpcp_unpack_context* unpack_context
}
}

static int unpack_int(ccpcp_unpack_context* unpack_context, int64_t *p_val)
static int ccpon_unpack_int(ccpcp_unpack_context* unpack_context, int64_t *p_val)
{
int64_t val = 0;
int neg = 0;
Expand Down Expand Up @@ -899,7 +899,7 @@ void ccpon_unpack_date_time(ccpcp_unpack_context *unpack_context, struct tm *tm,
const char *p;

int64_t val;
int n = unpack_int(unpack_context, &val);
int n = ccpon_unpack_int(unpack_context, &val);
if(n < 0) {
unpack_context->err_no = CCPCP_RC_MALFORMED_INPUT;
unpack_context->err_msg = "Malformed year in DateTime";
Expand All @@ -914,7 +914,7 @@ void ccpon_unpack_date_time(ccpcp_unpack_context *unpack_context, struct tm *tm,
return;
}

n = unpack_int(unpack_context, &val);
n = ccpon_unpack_int(unpack_context, &val);
if(n <= 0) {
unpack_context->err_no = CCPCP_RC_MALFORMED_INPUT;
unpack_context->err_msg = "Malformed month in DateTime";
Expand All @@ -929,7 +929,7 @@ void ccpon_unpack_date_time(ccpcp_unpack_context *unpack_context, struct tm *tm,
return;
}

n = unpack_int(unpack_context, &val);
n = ccpon_unpack_int(unpack_context, &val);
if(n <= 0) {
unpack_context->err_no = CCPCP_RC_MALFORMED_INPUT;
unpack_context->err_msg = "Malformed day in DateTime";
Expand All @@ -944,7 +944,7 @@ void ccpon_unpack_date_time(ccpcp_unpack_context *unpack_context, struct tm *tm,
return;
}

n = unpack_int(unpack_context, &val);
n = ccpon_unpack_int(unpack_context, &val);
if(n <= 0) {
unpack_context->err_no = CCPCP_RC_MALFORMED_INPUT;
unpack_context->err_msg = "Malformed hour in DateTime";
Expand All @@ -954,7 +954,7 @@ void ccpon_unpack_date_time(ccpcp_unpack_context *unpack_context, struct tm *tm,

UNPACK_TAKE_BYTE(p);

n = unpack_int(unpack_context, &val);
n = ccpon_unpack_int(unpack_context, &val);
if(n <= 0) {
unpack_context->err_no = CCPCP_RC_MALFORMED_INPUT;
unpack_context->err_msg = "Malformed minutes in DateTime";
Expand All @@ -964,7 +964,7 @@ void ccpon_unpack_date_time(ccpcp_unpack_context *unpack_context, struct tm *tm,

UNPACK_TAKE_BYTE(p);

n = unpack_int(unpack_context, &val);
n = ccpon_unpack_int(unpack_context, &val);
if(n <= 0) {
unpack_context->err_no = CCPCP_RC_MALFORMED_INPUT;
unpack_context->err_msg = "Malformed seconds in DateTime";
Expand All @@ -975,7 +975,7 @@ void ccpon_unpack_date_time(ccpcp_unpack_context *unpack_context, struct tm *tm,
p = ccpcp_unpack_take_byte(unpack_context);
if(p) {
if(*p == '.') {
n = unpack_int(unpack_context, &val);
n = ccpon_unpack_int(unpack_context, &val);
if(n < 0)
return;
*msec = (int)val;
Expand All @@ -988,7 +988,7 @@ void ccpon_unpack_date_time(ccpcp_unpack_context *unpack_context, struct tm *tm,
}
else if(b == '+' || b == '-') {
// UTC time
n = unpack_int(unpack_context, &val);
n = ccpon_unpack_int(unpack_context, &val);
if(!(n == 2 || n == 4))
UNPACK_ERROR(CCPCP_RC_MALFORMED_INPUT, "Malformed TS offset in DateTime.");
if(n == 2)
Expand Down Expand Up @@ -1336,7 +1336,7 @@ void ccpon_unpack_next (ccpcp_unpack_context* unpack_context)
flags.is_neg = *p == '-';
if(!flags.is_neg)
unpack_context->current--;
int n = unpack_int(unpack_context, &mantisa);
int n = ccpon_unpack_int(unpack_context, &mantisa);
if(n < 0)
UNPACK_ERROR(CCPCP_RC_MALFORMED_INPUT, "Malformed number.")
p = ccpcp_unpack_take_byte(unpack_context);
Expand All @@ -1347,7 +1347,7 @@ void ccpon_unpack_next (ccpcp_unpack_context* unpack_context)
}
if(*p == '.') {
flags.is_decimal = 1;
n = unpack_int(unpack_context, &decimals);
n = ccpon_unpack_int(unpack_context, &decimals);
if(n < 0)
UNPACK_ERROR(CCPCP_RC_MALFORMED_INPUT, "Malformed number decimal part.")
dec_cnt = n;
Expand All @@ -1357,7 +1357,7 @@ void ccpon_unpack_next (ccpcp_unpack_context* unpack_context)
}
if(*p == 'e' || *p == 'E') {
flags.is_decimal = 1;
n = unpack_int(unpack_context, &exponent);
n = ccpon_unpack_int(unpack_context, &exponent);
if(n < 0)
UNPACK_ERROR(CCPCP_RC_MALFORMED_INPUT, "Malformed number exponetional part.")
break;
Expand Down
18 changes: 9 additions & 9 deletions libshvchainpack/src/chainpack/chainpackreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

namespace shv::chainpack {

#define PARSE_EXCEPTION(msg) {\
#define CHAINPACK_PARSE_EXCEPTION(msg) {\
std::array<char, 40> buff; \
auto err_pos = m_in.tellg(); \
auto l = m_in.readsome(buff.data(), buff.size() - 1); \
buff[l] = 0; \
auto buff_data_hex = shv::chainpack::utils::hexDump(buff.data(), l); \
if(exception_aborts) { \
if(chainpack_exception_aborts) { \
std::clog << __FILE__ << ':' << __LINE__; \
std::clog << ' ' << (msg) << " at pos: " << err_pos << " near to:\n" << buff_data_hex << std::endl; \
abort(); \
Expand All @@ -25,7 +25,7 @@ namespace shv::chainpack {
}

namespace {
enum {exception_aborts = 0};
enum {chainpack_exception_aborts = 0};
}

ChainPackReader::ChainPackReader(std::istream &in)
Expand All @@ -49,7 +49,7 @@ ChainPackReader::ItemType ChainPackReader::unpackNext()
{
cchainpack_unpack_next(&m_inCtx);
if(m_inCtx.err_no != CCPCP_RC_OK)
PARSE_EXCEPTION("Parse error: " + std::string(m_inCtx.err_msg) + " error code: " + std::to_string(m_inCtx.err_no));
CHAINPACK_PARSE_EXCEPTION("Parse error: " + std::string(m_inCtx.err_msg) + " error code: " + std::to_string(m_inCtx.err_no));
return m_inCtx.item.type;
}

Expand All @@ -62,7 +62,7 @@ ChainPackReader::ItemType ChainPackReader::peekNext()
{
const char *p = ccpcp_unpack_peek_byte(&m_inCtx);
if(!p)
PARSE_EXCEPTION("Parse error: " + std::string(m_inCtx.err_msg) + " error code: " + std::to_string(m_inCtx.err_no));
CHAINPACK_PARSE_EXCEPTION("Parse error: " + std::string(m_inCtx.err_msg) + " error code: " + std::to_string(m_inCtx.err_no));
auto sch = static_cast<cchainpack_pack_packing_schema>(static_cast<uint8_t>(*p));
switch(sch) {
case CP_Null: return CCPCP_ITEM_NULL;
Expand Down Expand Up @@ -137,7 +137,7 @@ void ChainPackReader::read(RpcValue &val)
break;
unpackNext();
if(m_inCtx.item.type != CCPCP_ITEM_STRING)
PARSE_EXCEPTION("Unfinished string");
CHAINPACK_PARSE_EXCEPTION("Unfinished string");
}
val = str;
break;
Expand All @@ -151,7 +151,7 @@ void ChainPackReader::read(RpcValue &val)
break;
unpackNext();
if(m_inCtx.item.type != CCPCP_ITEM_BLOB)
PARSE_EXCEPTION("Unfinished blob");
CHAINPACK_PARSE_EXCEPTION("Unfinished blob");
}
val = blob;
break;
Expand Down Expand Up @@ -183,11 +183,11 @@ void ChainPackReader::read(RpcValue &val)
break;
}
default:
PARSE_EXCEPTION("Invalid type.");
CHAINPACK_PARSE_EXCEPTION("Invalid type.");
}
if(!md.isEmpty()) {
if(!val.isValid())
PARSE_EXCEPTION("Attempt to set metadata to invalid RPC value.");
CHAINPACK_PARSE_EXCEPTION("Attempt to set metadata to invalid RPC value.");
val.setMetaData(std::move(md));
}
}
Expand Down
16 changes: 8 additions & 8 deletions libshvchainpack/src/chainpack/cponreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

namespace shv::chainpack {

#define PARSE_EXCEPTION(msg) {\
#define CPON_PARSE_EXCEPTION(msg) {\
std::array<char, 40> buff; \
auto err_pos = m_in.tellg(); \
auto l = m_in.readsome(buff.data(), buff.size() - 1); \
buff[l] = 0; \
if(exception_aborts) { \
if(cpon_exception_aborts) { \
std::clog << __FILE__ << ':' << __LINE__; \
std::clog << ' ' << (msg) << " at pos: " << err_pos << " near to: " << buff.data() << std::endl; \
abort(); \
Expand All @@ -29,7 +29,7 @@ namespace shv::chainpack {
}

namespace {
enum {exception_aborts = 0};
enum {cpon_exception_aborts = 0};
}

CponReader::CponReader(std::istream &in)
Expand All @@ -53,7 +53,7 @@ void CponReader::unpackNext()
{
ccpon_unpack_next(&m_inCtx);
if(m_inCtx.err_no != CCPCP_RC_OK)
PARSE_EXCEPTION("Parse error: " + std::to_string(m_inCtx.err_no) + " " + ccpcp_error_string(m_inCtx.err_no) + " - " + std::string(m_inCtx.err_msg));
CPON_PARSE_EXCEPTION("Parse error: " + std::to_string(m_inCtx.err_no) + " " + ccpcp_error_string(m_inCtx.err_no) + " - " + std::string(m_inCtx.err_msg));
}

void CponReader::read(RpcValue &val)
Expand Down Expand Up @@ -96,7 +96,7 @@ void CponReader::read(RpcValue &val)
break;
unpackNext();
if(m_inCtx.item.type != CCPCP_ITEM_BLOB)
PARSE_EXCEPTION("Unfinished blob key");
CPON_PARSE_EXCEPTION("Unfinished blob key");
}
val = RpcValue(blob);
break;
Expand All @@ -110,7 +110,7 @@ void CponReader::read(RpcValue &val)
break;
unpackNext();
if(m_inCtx.item.type != CCPCP_ITEM_STRING)
PARSE_EXCEPTION("Unfinished string key");
CPON_PARSE_EXCEPTION("Unfinished string key");
}
val = str;
break;
Expand Down Expand Up @@ -142,11 +142,11 @@ void CponReader::read(RpcValue &val)
break;
}
default:
PARSE_EXCEPTION("Invalid type.");
CPON_PARSE_EXCEPTION("Invalid type.");
}
if(!md.isEmpty()) {
if(!val.isValid())
PARSE_EXCEPTION(std::string("Attempt to set metadata to invalid RPC value. error - ") + m_inCtx.err_msg);
CPON_PARSE_EXCEPTION(std::string("Attempt to set metadata to invalid RPC value. error - ") + m_inCtx.err_msg);
val.setMetaData(std::move(md));
}
}
Expand Down
Loading