Fix compil issues and warnings, especially in ibis code.

This commit is contained in:
jean-pierre charras 2022-09-28 09:55:00 +02:00
parent 46471247ff
commit 7d20418d6f
4 changed files with 85 additions and 65 deletions

View File

@ -124,6 +124,7 @@ principle should be easily implemented by adapting the current STL containers.
%include marker_base.h
%include eda_text.h
%include build_version.h
%include layer_ids.h
%include settings/settings_manager.h
// Cast time_t to known type for Python

View File

@ -5,18 +5,18 @@
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
@ -35,13 +35,25 @@
#include <iterator>
#include <locale_io.h> // KiCad header
bool IbisParser::compareIbisWord( const std::string& a, const std::string& b )
// _() is used here to mark translatable strings in IBIS_REPORTER::Report()
// However, currently non ASCII7 chars are nor correctly handled when printing messages
// So we disable translations
#if 0
#include <wx/intl.h> // for _() macro and wxGetTranslation()
#else
#undef _
#define _( x ) x
#endif
bool IbisParser::compareIbisWord( const std::string& stra, const std::string& strb )
{
return std::equal(a.begin(), a.end(),
b.begin(), b.end(),
[](char a, char b) {
return std::tolower(a) == std::tolower(b);
});
return std::equal( stra.begin(), stra.end(),
strb.begin(), strb.end(),
[](char a, char b)
{
return std::tolower(a) == std::tolower(b);
});
}
bool IBIS_MATRIX_BANDED::Check()
@ -231,9 +243,9 @@ bool IbisComponent::Check()
if( !m_package.Check() )
{
Report( _( "Component: Invalid Package." ), RPT_SEVERITY_ERROR );
status = false;
status = false;
}
if( m_pins.size() < 1 )
{
Report( _( "Component: no pin" ), RPT_SEVERITY_ERROR );
@ -322,7 +334,7 @@ double IVtable::InterpolatedI( double aV, IBIS_CORNER aCorner )
return m_entries.at( 0 ).I.value[aCorner];
}
for( int i = 1; i < m_entries.size(); i++ )
for( size_t i = 1; i < m_entries.size(); i++ )
{
if( m_entries.at( i ).V > aV )
{
@ -612,13 +624,13 @@ bool IbisPackageModel::Check()
status = false;
}
if( m_pins.size() != m_numberOfPins )
if( (int)m_pins.size() != m_numberOfPins )
{
Report( "Number of pins does not match [Pin Numbers] size", RPT_SEVERITY_ERROR );
status = false;
}
for( int i = 0; i < m_pins.size(); i++ )
for( size_t i = 0; i < m_pins.size(); i++ )
{
if( m_pins.at( i ).empty() )
{
@ -778,7 +790,7 @@ bool IbisParser::readDvdt( std::string& aString, dvdt& aDest )
int i = 0;
for( i = 1; i < aString.length(); i++ )
for( i = 1; i < (int)aString.length(); i++ )
{
if( aString.at( i ) == '/' )
{
@ -951,7 +963,7 @@ bool IbisParser::readInt( int& aDest )
if( readWord( str ) )
{
double result;
size_t size;
size_t size = 0;
try
{
@ -1036,7 +1048,7 @@ bool IbisParser::readString( std::string& aDest )
bool IbisParser::storeString( std::string& aDest, bool aMultiline )
{
skipWhitespaces();
readString( aDest );
@ -1082,7 +1094,6 @@ bool IbisParser::changeCommentChar()
return false;
}
int i = 0;
while( isspace( c ) && c != 0 && c != '\n' && c != d )
{
c = m_buffer[m_lineOffset + m_lineIndex++];
@ -1444,7 +1455,7 @@ bool IbisParser::readMatrixFull( std::string aKeyword, IBIS_MATRIX_FULL& aDest )
status &= readTableLine( values );
int i;
for( i = 0; i < values.size(); i++ )
for( i = 0; i < (int)values.size(); i++ )
{
int index = i + m_currentMatrixRow * aDest.m_dim + m_currentMatrixRow;
// + final m_currentMatrixRow because we don't fill the lower triangle.
@ -1718,7 +1729,7 @@ bool IbisParser::readNumericSubparam( std::string aSubparam, double& aDest )
std::string paramName;
bool status = true;
if( aSubparam.size() >= m_lineLength )
if( aSubparam.size() >= (size_t)m_lineLength )
{
// Continuing would result in an overflow
return false;
@ -1727,7 +1738,8 @@ bool IbisParser::readNumericSubparam( std::string aSubparam, double& aDest )
int old_index = m_lineIndex;
m_lineIndex = 0;
for( int i = 0; i < aSubparam.size(); i++ )
for( size_t i = 0; i < aSubparam.size(); i++ )
{
paramName += m_buffer[m_lineOffset + m_lineIndex++];
}
@ -1784,9 +1796,9 @@ bool IbisParser::readTypMinMaxValueSubparam( std::string aSubparam, TypMinMaxVal
m_lineIndex = 0; // rewind
if( aSubparam.size() < m_lineLength )
if( aSubparam.size() < (size_t)m_lineLength )
{
for( int i = 0; i < aSubparam.size(); i++ )
for( size_t i = 0; i < aSubparam.size(); i++ )
{
paramName += m_buffer[m_lineOffset + m_lineIndex++];
}
@ -1812,8 +1824,6 @@ bool IbisParser::readModel()
{
bool status = true;
int startOfLine = m_lineIndex;
std::string subparam;
if( readWord( subparam ) )
{
@ -1931,7 +1941,7 @@ bool IbisParser::readModel()
;
else if( readTypMinMaxValueSubparam( std::string( "C_comp" ),
m_currentModel->m_C_comp ) )
;
;
else
{
status = false;
@ -1940,6 +1950,7 @@ bool IbisParser::readModel()
m_continue = IBIS_PARSER_CONTINUE::MODEL;
break;
default:
status = false;
Report( _( "Continued reading a model that did not begin. ( internal error )" ),
@ -2085,7 +2096,7 @@ bool IbisParser::readPackage()
int extraArg = ( m_continue == IBIS_PARSER_CONTINUE::NONE ) ? 1 : 0;
if( fields.size() == ( 4 + extraArg ) )
if( (int)fields.size() == ( 4 + extraArg ) )
{
if( fields.at( 0 ) == "R_pkg" )
{

View File

@ -5,18 +5,18 @@
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
@ -32,8 +32,6 @@
#ifndef IBIS_PARSER_H
#define IBIS_PARSER_H
#define _( x ) x
#define NAN_NA "1"
#define NAN_INVALID "0"
@ -54,10 +52,10 @@ class IBIS_REPORTER
{
public:
/** @brief Print a message
*
*
* In the future, this function could do more than just printing a message.
* All KIBIS messages are concentrated at a single point in the code.
*
* All KIBIS messages are concentrated at a single point in the code.
*
* @param aMsg Message
* @param aSeverity Message sevirity
*/
@ -71,9 +69,9 @@ public:
IBIS_REPORTER* m_reporter;
/** @brief Print a message
*
*
* Call m_reporter->Report if m_reporter exists.
*
*
* @param aMsg Message
* @param aSeverity Message sevirity
*/
@ -86,7 +84,7 @@ public:
};
protected:
/** @brief Convert a double to string using scientific notation
*
*
* @param aNumber Number
* @return Output string
*/
@ -98,8 +96,8 @@ class IBIS_INPUT : public IBIS_ANY
{
public:
IBIS_INPUT( IBIS_REPORTER* aReporter ) : IBIS_ANY( aReporter ){};
/** @brief Check if the data held by the object is valid.
*
/** @brief Check if the data held by the object is valid.
*
* @return true in case of success
*/
bool virtual Check() { return false; };
@ -338,9 +336,9 @@ public:
bool Check() override;
/** @brief Interpolate the IV table
*
*
* Linear interpolation to find the current for voltage aV
*
*
* @param aV voltage
* @param aCorner Power supply corner
* @return current
@ -348,10 +346,10 @@ public:
double InterpolatedI( double aV, IBIS_CORNER aCorner );
/** @brief Interpolate the IV table
*
*
* Generate the spice directive needed to define a model defined by its IV table.
* The order of aPort1 and aPort2 is important. ( Inverting them will reverse the component )
*
*
* @param aN Index of the 'a' device
* @param aPort1 Spice node
* @param aPort2 Spice node
@ -381,10 +379,10 @@ public:
};
/*
Model_type must be one of the following:
Input, Output, I/O, 3-state, Open_drain, I/O_open_drain, Open_sink, I/O_open_sink,
Open_source, I/O_open_source, Input_ECL, Output_ECL, I/O_ECL, 3-state_ECL, Terminator,
Series, and Series_switch.
Model_type must be one of the following:
Input, Output, I/O, 3-state, Open_drain, I/O_open_drain, Open_sink, I/O_open_sink,
Open_source, I/O_open_source, Input_ECL, Output_ECL, I/O_ECL, 3-state_ECL, Terminator,
Series, and Series_switch.
*/
enum class IBIS_MODEL_TYPE
@ -629,9 +627,9 @@ public:
IbisWaveform* m_currentWaveform = nullptr;
/** @brief Parse a file
*
*
* This is the entry point to parse a file
*
*
* @param aFileName input file name
* @return True in case of success
*/
@ -641,9 +639,9 @@ private:
std::string* m_continuingString = nullptr;
/** @brief compare two strings without being case sensitive
*
*
* Ibis: "The content of the files is case sensitive, except for reserved words and keywords."
*
*
* @param a string to compare
* @param b string to compare
* @return true if the string are equal
@ -651,43 +649,43 @@ private:
bool compareIbisWord( const std::string& a, const std::string& b );
/** @brief Parse a single keyword in the header context
*
*
* @param aKeyword Keyword
* @return True in case of success
*/
bool parseHeader( std::string& aKeyword );
/** @brief Parse a single keyword in the component context
*
*
* @param aKeyword Keyword
* @return True in case of success
*/
bool parseComponent( std::string& aKeyword );
/** @brief Parse a single keyword in the component context
*
*
* @param aKeyword Keyword
* @return True in case of success
*/
bool parseModelSelector( std::string& aKeyword );
/** @brief Parse a single keyword in the model selector context
*
*
* @param aKeyword Keyword
* @return True in case of success
*/
bool parseModel( std::string& aKeyword );
/** @brief Parse a single keyword in the model context
*
*
* @param aKeyword Keyword
* @return True in case of success
*/
bool parsePackageModel( std::string& aKeyword );
/** @brief Parse a single keyword in the package model context
*
*
* @param aKeyword Keyword
* @return True in case of success
*/
bool parsePackageModelModelData( std::string& );
/** @brief Parse a double according to the ibis standard
*
*
* @param aDest Where the double should be stored
* @param aStr The string to parse
* @param aAllowModifiers Allows modifiers ( p for pico, f for femto, k for kilo, ... )

View File

@ -5,18 +5,18 @@
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
@ -33,6 +33,16 @@
#include "ibis_parser.h"
#include <sstream>
// _() is used here to mark translatable strings in IBIS_REPORTER::Report()
// However, currently non ASCII7 chars are nor correctly handled when printing messages
// So we disable translations
#if 0
#include <wx/intl.h> // for _() macro and wxGetTranslation()
#else
#undef _
#define _( x ) x
#endif
KIBIS_ANY::KIBIS_ANY( KIBIS* aTopLevel ) : IBIS_ANY( aTopLevel->m_reporter )
{
m_topLevel = aTopLevel;