Implement poor-man's RTTI for use over KiWAY.
Fixes: lp:1777883 * https://bugs.launchpad.net/kicad/+bug/1777883
This commit is contained in:
parent
872e1e6532
commit
02a3f83040
|
@ -30,6 +30,8 @@
|
||||||
class CACHE_WRAPPER : public S3D_CACHE, public PROJECT::_ELEM
|
class CACHE_WRAPPER : public S3D_CACHE, public PROJECT::_ELEM
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
KICAD_T Type() override { return CACHE_WRAPPER_T; }
|
||||||
|
|
||||||
CACHE_WRAPPER();
|
CACHE_WRAPPER();
|
||||||
virtual ~CACHE_WRAPPER();
|
virtual ~CACHE_WRAPPER();
|
||||||
};
|
};
|
||||||
|
|
|
@ -401,7 +401,7 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs( KIWAY& aKiway )
|
||||||
FP_LIB_TABLE* tbl = (FP_LIB_TABLE*) GetElem( ELEM_FPTBL );
|
FP_LIB_TABLE* tbl = (FP_LIB_TABLE*) GetElem( ELEM_FPTBL );
|
||||||
|
|
||||||
// its gotta be NULL or a FP_LIB_TABLE, or a bug.
|
// its gotta be NULL or a FP_LIB_TABLE, or a bug.
|
||||||
wxASSERT( !tbl || dynamic_cast<FP_LIB_TABLE*>( tbl ) );
|
wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
|
||||||
|
|
||||||
if( !tbl )
|
if( !tbl )
|
||||||
{
|
{
|
||||||
|
|
|
@ -189,6 +189,7 @@ typedef boost::ptr_vector< PART_LIB > PART_LIBS_BASE;
|
||||||
class PART_LIBS : public PART_LIBS_BASE, public PROJECT::_ELEM
|
class PART_LIBS : public PART_LIBS_BASE, public PROJECT::_ELEM
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
KICAD_T Type() override { return PART_LIBS_T; }
|
||||||
|
|
||||||
static int s_modify_generation; ///< helper for GetModifyHash()
|
static int s_modify_generation; ///< helper for GetModifyHash()
|
||||||
|
|
||||||
|
|
|
@ -641,7 +641,7 @@ SYMBOL_LIB_TABLE* PROJECT::SchSymbolLibTable()
|
||||||
SYMBOL_LIB_TABLE* tbl = (SYMBOL_LIB_TABLE*) GetElem( ELEM_SYMBOL_LIB_TABLE );
|
SYMBOL_LIB_TABLE* tbl = (SYMBOL_LIB_TABLE*) GetElem( ELEM_SYMBOL_LIB_TABLE );
|
||||||
|
|
||||||
// its gotta be NULL or a SYMBOL_LIB_TABLE, or a bug.
|
// its gotta be NULL or a SYMBOL_LIB_TABLE, or a bug.
|
||||||
wxASSERT( !tbl || dynamic_cast<SYMBOL_LIB_TABLE*>( tbl ) );
|
wxASSERT( !tbl || tbl->Type() == SYMBOL_LIB_TABLE_T );
|
||||||
|
|
||||||
if( !tbl )
|
if( !tbl )
|
||||||
{
|
{
|
||||||
|
|
|
@ -156,7 +156,7 @@ PART_LIBS* PROJECT::SchLibs()
|
||||||
{
|
{
|
||||||
PART_LIBS* libs = (PART_LIBS*) GetElem( PROJECT::ELEM_SCH_PART_LIBS );
|
PART_LIBS* libs = (PART_LIBS*) GetElem( PROJECT::ELEM_SCH_PART_LIBS );
|
||||||
|
|
||||||
wxASSERT( !libs || dynamic_cast<PART_LIBS*>( libs ) );
|
wxASSERT( !libs || libs->Type() == PART_LIBS_T );
|
||||||
|
|
||||||
if( !libs )
|
if( !libs )
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,6 +107,8 @@ class SYMBOL_LIB_TABLE : public LIB_TABLE
|
||||||
static int m_modifyHash; ///< helper for GetModifyHash()
|
static int m_modifyHash; ///< helper for GetModifyHash()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
KICAD_T Type() override { return SYMBOL_LIB_TABLE_T; }
|
||||||
|
|
||||||
static const char* PropPowerSymsOnly;
|
static const char* PropPowerSymsOnly;
|
||||||
static const char* PropNonPowerSymsOnly;
|
static const char* PropNonPowerSymsOnly;
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,15 @@ enum KICAD_T
|
||||||
*/
|
*/
|
||||||
TYPE_PL_EDITOR_LAYOUT,
|
TYPE_PL_EDITOR_LAYOUT,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FOR PROJECT::_ELEMs
|
||||||
|
*/
|
||||||
|
SYMBOL_LIB_TABLE_T,
|
||||||
|
FP_LIB_TABLE_T,
|
||||||
|
PART_LIBS_T,
|
||||||
|
SEARCH_STACK_T,
|
||||||
|
CACHE_WRAPPER_T,
|
||||||
|
|
||||||
// End value
|
// End value
|
||||||
MAX_STRUCT_TYPE_ID
|
MAX_STRUCT_TYPE_ID
|
||||||
};
|
};
|
||||||
|
|
|
@ -105,6 +105,7 @@ class FP_LIB_TABLE : public LIB_TABLE
|
||||||
friend class FP_LIB_TABLE_GRID;
|
friend class FP_LIB_TABLE_GRID;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
KICAD_T Type() override { return FP_LIB_TABLE_T; }
|
||||||
|
|
||||||
virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
|
virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
|
#include <core/typeinfo.h>
|
||||||
|
|
||||||
/// A variable name whose value holds the current project directory.
|
/// A variable name whose value holds the current project directory.
|
||||||
/// Currently an environment variable, eventually a project variable.
|
/// Currently an environment variable, eventually a project variable.
|
||||||
|
@ -67,6 +68,8 @@ public:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~_ELEM() {}
|
virtual ~_ELEM() {}
|
||||||
|
|
||||||
|
virtual KICAD_T Type() = 0; // Sanity-checking for returned values.
|
||||||
};
|
};
|
||||||
|
|
||||||
PROJECT();
|
PROJECT();
|
||||||
|
|
|
@ -42,6 +42,8 @@ class SEARCH_STACK : public wxPathList, public PROJECT::_ELEM
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
KICAD_T Type() override { return SEARCH_STACK_T; }
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
void Show( const wxString& aPrefix ) const;
|
void Show( const wxString& aPrefix ) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -172,7 +172,7 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs()
|
||||||
FP_LIB_TABLE* tbl = (FP_LIB_TABLE*) GetElem( ELEM_FPTBL );
|
FP_LIB_TABLE* tbl = (FP_LIB_TABLE*) GetElem( ELEM_FPTBL );
|
||||||
|
|
||||||
// its gotta be NULL or a FP_LIB_TABLE, or a bug.
|
// its gotta be NULL or a FP_LIB_TABLE, or a bug.
|
||||||
wxASSERT( !tbl || dynamic_cast<FP_LIB_TABLE*>( tbl ) );
|
wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
|
||||||
|
|
||||||
if( !tbl )
|
if( !tbl )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue