Replace "module" with "footprint" in PCB sexpr.

This commit is contained in:
Jeff Young 2020-11-15 12:20:59 +00:00
parent 8b9be2e129
commit 3f1a58bd06
6 changed files with 25 additions and 46 deletions

View File

@ -108,6 +108,7 @@ filled_areas_thickness
fillet fillet
font font
format format
footprint
footprints footprints
fp_arc fp_arc
fp_circle fp_circle

View File

@ -105,13 +105,14 @@ public:
case S_SEGMENT: case S_SEGMENT:
case S_ARC: case S_ARC:
case S_CURVE: case S_CURVE:
case S_LAST: // Make CLang compiler happy
return false; return false;
case S_LAST: // Sentinel case S_LAST: // Sentinel
break; break;
} }
return false; // Make compil happy return false; // Make GCC compiler happy
} }
void SetWidth( int aWidth ) { m_width = aWidth; } void SetWidth( int aWidth ) { m_width = aWidth; }

View File

@ -67,7 +67,7 @@ public:
FP_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName ); FP_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName );
const WX_FILENAME& GetFileName() const { return m_filename; } const WX_FILENAME& GetFileName() const { return m_filename; }
const FOOTPRINT* GetModule() const { return m_footprint.get(); } const FOOTPRINT* GetFootprint() const { return m_footprint.get(); }
}; };
@ -173,7 +173,7 @@ void FP_CACHE::Save( FOOTPRINT* aFootprint )
for( FOOTPRINT_MAP::iterator it = m_footprints.begin(); it != m_footprints.end(); ++it ) for( FOOTPRINT_MAP::iterator it = m_footprints.begin(); it != m_footprints.end(); ++it )
{ {
if( aFootprint && aFootprint != it->second->GetModule() ) if( aFootprint && aFootprint != it->second->GetFootprint() )
continue; continue;
WX_FILENAME fn = it->second->GetFileName(); WX_FILENAME fn = it->second->GetFileName();
@ -193,7 +193,7 @@ void FP_CACHE::Save( FOOTPRINT* aFootprint )
FILE_OUTPUTFORMATTER formatter( tempFileName ); FILE_OUTPUTFORMATTER formatter( tempFileName );
m_owner->SetOutputFormatter( &formatter ); m_owner->SetOutputFormatter( &formatter );
m_owner->Format( (BOARD_ITEM*) it->second->GetModule() ); m_owner->Format( (BOARD_ITEM*) it->second->GetFootprint() );
} }
#ifdef USE_TMP_FILE #ifdef USE_TMP_FILE
@ -972,10 +972,10 @@ void PCB_IO::format( FOOTPRINT* aFootprint, int aNestLevel ) const
} }
if( m_ctl & CTL_OMIT_LIBNAME ) if( m_ctl & CTL_OMIT_LIBNAME )
m_out->Print( aNestLevel, "(module %s", m_out->Print( aNestLevel, "(footprint %s",
m_out->Quotes( aFootprint->GetFPID().GetLibItemNameAndRev() ).c_str() ); m_out->Quotes( aFootprint->GetFPID().GetLibItemNameAndRev() ).c_str() );
else else
m_out->Print( aNestLevel, "(module %s", m_out->Print( aNestLevel, "(footprint %s",
m_out->Quotes( aFootprint->GetFPID().Format() ).c_str() ); m_out->Quotes( aFootprint->GetFPID().Format() ).c_str() );
if( aFootprint->IsLocked() ) if( aFootprint->IsLocked() )
@ -2118,7 +2118,6 @@ void PCB_IO::init( const PROPERTIES* aProperties )
{ {
m_board = NULL; m_board = NULL;
m_reader = NULL; m_reader = NULL;
m_loading_format_version = SEXPR_BOARD_FILE_VERSION;
m_props = aProperties; m_props = aProperties;
} }
@ -2188,7 +2187,7 @@ const FOOTPRINT* PCB_IO::getFootprint( const wxString& aLibraryPath,
if( it == footprints.end() ) if( it == footprints.end() )
return nullptr; return nullptr;
return it->second->GetModule(); return it->second->GetFootprint();
} }

View File

@ -89,7 +89,8 @@ class PCB_TEXT;
//#define SEXPR_BOARD_FILE_VERSION 20200921 // Add orthogonal dimension //#define SEXPR_BOARD_FILE_VERSION 20200921 // Add orthogonal dimension
//#define SEXPR_BOARD_FILE_VERSION 20200922 // Add user name to layer definition. //#define SEXPR_BOARD_FILE_VERSION 20200922 // Add user name to layer definition.
//#define SEXPR_BOARD_FILE_VERSION 20201002 // Add groups in footprints (for footprint editor). //#define SEXPR_BOARD_FILE_VERSION 20201002 // Add groups in footprints (for footprint editor).
#define SEXPR_BOARD_FILE_VERSION 20201114 // Add first-class support for filled shapes. //#define SEXPR_BOARD_FILE_VERSION 20201114 // Add first-class support for filled shapes.
#define SEXPR_BOARD_FILE_VERSION 20201115 // module -> footprint.
#define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag #define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag
@ -175,10 +176,10 @@ public:
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override; long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
void FootprintLibCreate( const wxString& aLibraryPath, void FootprintLibCreate( const wxString& aLibraryPath,
const PROPERTIES* aProperties = NULL) override; const PROPERTIES* aProperties = NULL) override;
bool FootprintLibDelete( const wxString& aLibraryPath, bool FootprintLibDelete( const wxString& aLibraryPath,
const PROPERTIES* aProperties = NULL ) override; const PROPERTIES* aProperties = NULL ) override;
bool IsFootprintLibWritable( const wxString& aLibraryPath ) override; bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
@ -200,6 +201,7 @@ public:
std::string GetStringOutput( bool doClear ) std::string GetStringOutput( bool doClear )
{ {
std::string ret = m_sf.GetString(); std::string ret = m_sf.GetString();
if( doClear ) if( doClear )
m_sf.Clear(); m_sf.Clear();
@ -222,8 +224,6 @@ protected:
LINE_READER* m_reader; ///< no ownership here. LINE_READER* m_reader; ///< no ownership here.
wxString m_filename; ///< for saves only, name is in m_reader for loads wxString m_filename; ///< for saves only, name is in m_reader for loads
int m_loading_format_version; ///< which #SEXPR_BOARD_FILE_VERSION should be Load()ed?
STRING_FORMATTER m_sf; STRING_FORMATTER m_sf;
OUTPUTFORMATTER* m_out; ///< output any Format()s to this, no ownership OUTPUTFORMATTER* m_out; ///< output any Format()s to this, no ownership
int m_ctl; int m_ctl;

View File

@ -181,19 +181,6 @@ bool PCB_PARSER::parseBool()
} }
int PCB_PARSER::parseVersion()
{
if( NextTok() != T_version )
Expecting( GetTokenText( T_version ) );
int pcb_version = parseInt( FromUTF8().mb_str( wxConvUTF8 ) );
NeedRIGHT();
return pcb_version;
}
wxString PCB_PARSER::GetRequiredVersion() wxString PCB_PARSER::GetRequiredVersion()
{ {
int year, month, day; int year, month, day;
@ -509,8 +496,9 @@ BOARD_ITEM* PCB_PARSER::Parse()
item = (BOARD_ITEM*) parseBOARD(); item = (BOARD_ITEM*) parseBOARD();
break; break;
case T_module: case T_module: // legacy token
item = (BOARD_ITEM*) parseFOOTPRINT( initial_comments.release()); case T_footprint:
item = (BOARD_ITEM*) parseFOOTPRINT( initial_comments.release() );
break; break;
default: default:
@ -614,7 +602,8 @@ BOARD* PCB_PARSER::parseBOARD_unchecked()
m_board->Add( parseDIMENSION(), ADD_MODE::APPEND ); m_board->Add( parseDIMENSION(), ADD_MODE::APPEND );
break; break;
case T_module: case T_module: // legacy token
case T_footprint:
m_board->Add( parseFOOTPRINT(), ADD_MODE::APPEND ); m_board->Add( parseFOOTPRINT(), ADD_MODE::APPEND );
break; break;
@ -2812,7 +2801,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT( wxArrayString* aInitialComments )
FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments ) FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments )
{ {
wxCHECK_MSG( CurTok() == T_module, NULL, wxCHECK_MSG( CurTok() == T_module || CurTok() == T_footprint, NULL,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as FOOTPRINT." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as FOOTPRINT." ) );
wxString name; wxString name;

View File

@ -57,7 +57,6 @@ class PCB_GROUP;
class PCB_TARGET; class PCB_TARGET;
class VIA; class VIA;
class ZONE; class ZONE;
class PCB_MARKER;
class FP_3DMODEL; class FP_3DMODEL;
struct LAYER; struct LAYER;
@ -161,29 +160,25 @@ class PCB_PARSER : public PCB_LEXER
PCB_TEXT* parsePCB_TEXT(); PCB_TEXT* parsePCB_TEXT();
DIMENSION_BASE* parseDIMENSION(); DIMENSION_BASE* parseDIMENSION();
/** // Parse a footprint, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically.
* Function parseFOOTPRINT_unchecked
* Parse a footprint, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically.
*/
FOOTPRINT* parseFOOTPRINT_unchecked( wxArrayString* aInitialComments = 0 ); FOOTPRINT* parseFOOTPRINT_unchecked( wxArrayString* aInitialComments = 0 );
FP_TEXT* parseFP_TEXT(); FP_TEXT* parseFP_TEXT();
FP_SHAPE* parseFP_SHAPE(); FP_SHAPE* parseFP_SHAPE();
PAD* parsePAD( FOOTPRINT* aParent = NULL ); PAD* parsePAD( FOOTPRINT* aParent = NULL );
// Parse only the (option ...) inside a pad description // Parse only the (option ...) inside a pad description
bool parsePAD_option( PAD* aPad ); bool parsePAD_option( PAD* aPad );
ARC* parseARC(); ARC* parseARC();
TRACK* parseTRACK(); TRACK* parseTRACK();
VIA* parseVIA(); VIA* parseVIA();
ZONE* parseZONE( BOARD_ITEM_CONTAINER* aParent ); ZONE* parseZONE( BOARD_ITEM_CONTAINER* aParent );
PCB_TARGET* parsePCB_TARGET(); PCB_TARGET* parsePCB_TARGET();
PCB_MARKER* parseMARKER( BOARD_ITEM_CONTAINER* aParent );
BOARD* parseBOARD(); BOARD* parseBOARD();
void parseGROUP( BOARD_ITEM* aParent ); void parseGROUP( BOARD_ITEM* aParent );
/** // Parse a board, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically.
* Function parseBOARD_unchecked
* Parse a board, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically.
*/
BOARD* parseBOARD_unchecked(); BOARD* parseBOARD_unchecked();
/** /**
@ -325,12 +320,6 @@ class PCB_PARSER : public PCB_LEXER
bool parseBool(); bool parseBool();
/**
* Parse a format version tag like (version 20160417) return the version.
* Expects to start on 'version', and eats the closing paren.
*/
int parseVersion();
/* /*
* @return if m_resetKIIDs, returns new KIID(), otehrwise returns CurStr() as KIID. * @return if m_resetKIIDs, returns new KIID(), otehrwise returns CurStr() as KIID.
*/ */