Move PGM_BASE to kicommon

This commit is contained in:
Marek Roszko 2024-03-19 21:53:21 -04:00
parent e32b26ebeb
commit 83ef5fd7d6
66 changed files with 311 additions and 444 deletions

View File

@ -69,8 +69,6 @@ static struct IFACE : public KIFACE_BASE
using namespace BMP2CMP;
static PGM_BASE* process;
KIFACE_BASE& Kiface()
{
@ -82,27 +80,10 @@ KIFACE_BASE& Kiface()
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
return &kiface;
}
#if defined(BUILD_KIWAY_DLLS)
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return process;
}
#endif
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
{
return start_common( aCtlBits );

View File

@ -97,44 +97,84 @@ set( KICOMMON_SRCS
kicad_curl/kicad_curl.cpp
kicad_curl/kicad_curl_easy.cpp
settings/app_settings.cpp
settings/aui_settings.cpp
settings/bom_settings.cpp
settings/color_settings.cpp
settings/common_settings.cpp
settings/grid_settings.cpp
settings/json_settings.cpp
settings/kicad_settings.cpp
settings/nested_settings.cpp
settings/parameters.cpp
settings/settings_manager.cpp
project/board_project_settings.cpp
project/net_settings.cpp
project/project_archiver.cpp
project/project_file.cpp
project/project_local_settings.cpp
dialogs/dialog_migrate_settings.cpp
dialogs/dialog_migrate_settings_base.cpp
widgets/bitmap_button.cpp
widgets/kistatusbar.cpp
widgets/progress_reporter_base.cpp
widgets/std_bitmap_button.cpp
widgets/ui_common.cpp
database/database_lib_settings.cpp
advanced_config.cpp
asset_archive.cpp
array_axis.cpp
array_options.cpp
background_jobs_monitor.cpp
bitmap.cpp
bitmap_info.cpp
bitmap_store.cpp
build_version.cpp
common.cpp
config_params.cpp
confirm.cpp
dialog_shim.cpp
dsnlexer.cpp
eda_pattern_match.cpp
eda_units.cpp
env_vars.cpp
exceptions.cpp
gestfich.cpp
kiid.cpp
kiway.cpp
kiway_express.cpp
kiway_holder.cpp
launch_ext.cpp
lib_table_base.cpp
layer_id.cpp
lib_id.cpp
locale_io.cpp
lset.cpp
markup_parser.cpp
netclass.cpp
notifications_manager.cpp
page_info.cpp
paths.cpp
project.cpp
richio.cpp
search_stack.cpp
searchhelpfilefullpath.cpp
string_utils.cpp
systemdirsappend.cpp
ui_events.cpp
trace_helpers.cpp
wildcards_and_files_ext.cpp
wx_filename.cpp
pgm_base.cpp
../scripting/python_scripting.cpp
io/kicad/kicad_io_utils.cpp # needed by richio
)
@ -161,8 +201,19 @@ target_link_libraries( kicommon
${FREETYPE_LIBRARIES}
${HarfBuzz_LIBRARIES}
${Fontconfig_LIBRARIES}
# needed because of python_scripting.cpp
${PYTHON_LIBRARIES}
)
if( KICAD_USE_SENTRY )
target_link_libraries( kicommon
sentry )
set_property(SOURCE pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}")
endif()
include( ${KICAD_CMAKE_MODULE_PATH}/KiCadVersion.cmake )
include( ${KICAD_CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake )
create_git_version_header(${CMAKE_SOURCE_DIR})
@ -250,8 +301,6 @@ set( COMMON_DLG_SRCS
dialogs/dialog_import_choose_project_base.cpp
dialogs/dialog_locked_items_query.cpp
dialogs/dialog_locked_items_query_base.cpp
dialogs/dialog_migrate_settings.cpp
dialogs/dialog_migrate_settings_base.cpp
dialogs/dialog_page_settings_base.cpp
dialogs/dialog_paste_special.cpp
dialogs/dialog_paste_special_base.cpp
@ -301,7 +350,6 @@ endif()
set( COMMON_WIDGET_SRCS
widgets/app_progress_dialog.cpp
widgets/bitmap_button.cpp
widgets/bitmap_toggle.cpp
widgets/button_row_panel.cpp
widgets/color_swatch.cpp
@ -322,7 +370,6 @@ set( COMMON_WIDGET_SRCS
widgets/html_window.cpp
widgets/indicator_icon.cpp
widgets/wx_infobar.cpp
widgets/kistatusbar.cpp
widgets/layer_box_selector.cpp
widgets/lib_tree.cpp
widgets/mathplot.cpp
@ -336,7 +383,6 @@ set( COMMON_WIDGET_SRCS
widgets/split_button.cpp
widgets/stepped_slider.cpp
widgets/text_ctrl_eval.cpp
widgets/ui_common.cpp
widgets/unit_binder.cpp
widgets/widget_save_restore.cpp
widgets/widget_hotkey_list.cpp
@ -455,17 +501,12 @@ set( COMMON_SRCS
${COMMON_IMPORT_GFX_SRCS}
${COMMON_GIT_SRCS}
jobs/job_dispatcher.cpp
background_jobs_monitor.cpp
base_screen.cpp
bin_mod.cpp
bitmap.cpp
bitmap_base.cpp
bitmap_store.cpp
board_printout.cpp
cli_progress_reporter.cpp
commit.cpp
common.cpp
dialog_shim.cpp
dpi_scaling_common.cpp
draw_panel_gal.cpp
gal_display_options_common.cpp
@ -479,7 +520,6 @@ set( COMMON_SRCS
eda_text.cpp
eda_tools.cpp
env_paths.cpp
env_vars.cpp
executable_names.cpp
filename_resolver.cpp
file_history.cpp
@ -487,38 +527,27 @@ set( COMMON_SRCS
footprint_filter.cpp
footprint_info.cpp
gbr_metadata.cpp
gestfich.cpp
gr_basic.cpp
grid_tricks.cpp
hotkey_store.cpp
hotkeys_basic.cpp
kiface_base.cpp
kiway.cpp
kiway_express.cpp
kiway_holder.cpp
kiway_player.cpp
launch_ext.cpp
lib_table_base.cpp
lib_table_grid_tricks.cpp
lib_tree_model.cpp
lib_tree_model_adapter.cpp
marker_base.cpp
notifications_manager.cpp
origin_transforms.cpp
printout.cpp
project.cpp
ptree.cpp
rc_item.cpp
refdes_utils.cpp
render_settings.cpp
reporter.cpp
scintilla_tricks.cpp
search_stack.cpp
searchhelpfilefullpath.cpp
status_popup.cpp
string_utf8_map.cpp
stroke_params.cpp
systemdirsappend.cpp
template_fieldnames.cpp
textentry_tricks.cpp
title_block.cpp
@ -529,16 +558,6 @@ set( COMMON_SRCS
view/wx_view_controls.cpp
)
if( TRUE OR NOT USE_KIWAY_DLLS )
#if( NOT USE_KIWAY_DLLS )
# We DO NOT want pgm_base.cpp linked into the KIFACE, only into the KIWAY.
# Check the map files to verify eda_pgm.o not being linked in.
list( APPEND COMMON_SRCS pgm_base.cpp )
if( KICAD_USE_SENTRY )
set_property(SOURCE pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}")
endif()
endif()
set( COMMON_SRCS
${COMMON_SRCS}
@ -572,18 +591,7 @@ set( COMMON_SRCS
tool/zoom_menu.cpp
tool/zoom_tool.cpp
settings/app_settings.cpp
settings/color_settings.cpp
settings/cvpcb_settings.cpp
settings/common_settings.cpp
settings/settings_manager.cpp
settings/kicad_settings.cpp
project/board_project_settings.cpp
project/net_settings.cpp
project/project_archiver.cpp
project/project_file.cpp
project/project_local_settings.cpp
properties/color4d_variant.cpp
properties/eda_angle_variant.cpp
@ -594,7 +602,6 @@ set( COMMON_SRCS
properties/std_optional_variants.cpp
database/database_connection.cpp
database/database_lib_settings.cpp
http_lib/http_lib_connection.cpp
http_lib/http_lib_settings.cpp

View File

@ -2,7 +2,7 @@
<wxFormBuilder_Project>
<FileVersion major="1" minor="17"/>
<object class="Project" expanded="true">
<property name="class_decoration">; </property>
<property name="class_decoration">KICOMMON_API; kicommon.h</property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>

View File

@ -30,13 +30,15 @@ class STD_BITMAP_BUTTON;
#include <wx/checkbox.h>
#include <wx/dialog.h>
#include "kicommon.h"
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_MIGRATE_SETTINGS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_MIGRATE_SETTINGS_BASE : public DIALOG_SHIM
class KICOMMON_API DIALOG_MIGRATE_SETTINGS_BASE : public DIALOG_SHIM
{
private:

View File

@ -54,8 +54,8 @@ int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];
KIWAY::KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop ):
m_program( aProgram ), m_ctl( aCtlBits ), m_top( nullptr ), m_blockingDialog( wxID_NONE )
KIWAY::KIWAY( int aCtlBits, wxFrame* aTop ):
m_ctl( aCtlBits ), m_top( nullptr ), m_blockingDialog( wxID_NONE )
{
SetTop( aTop ); // hook player_destroy_handler() into aTop.
@ -296,7 +296,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
{
KIFACE_GETTER_FUNC* ki_getter = (KIFACE_GETTER_FUNC*) addr;
KIFACE* kiface = ki_getter( &m_kiface_version[aFaceId], KIFACE_VERSION, m_program );
KIFACE* kiface = ki_getter( &m_kiface_version[aFaceId], KIFACE_VERSION, &Pgm() );
// KIFACE_GETTER_FUNC function comment (API) says the non-NULL is unconditional.
wxASSERT_MSG( kiface,
@ -311,7 +311,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
try
{
startSuccess = kiface->OnKifaceStart( m_program, m_ctl, this );
startSuccess = kiface->OnKifaceStart( &Pgm(), m_ctl, this );
}
catch (...)
{

View File

@ -1025,3 +1025,22 @@ void PGM_BASE::WritePdfBrowserInfos()
GetCommonSettings()->m_System.pdf_viewer_name = GetPdfBrowserName();
GetCommonSettings()->m_System.use_system_pdf_viewer = m_use_system_pdf_browser;
}
static PGM_BASE* process;
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return process;
}
void SetPgm(PGM_BASE* pgm)
{
process = pgm;
}

View File

@ -60,7 +60,7 @@
// Only a single KIWAY is supported in this single_top top level component,
// which is dedicated to loading only a single DSO.
KIWAY Kiway( &Pgm(), KFCTL_STANDALONE );
KIWAY Kiway( KFCTL_STANDALONE );
// implement a PGM_BASE and a wxApp side by side:
@ -115,12 +115,6 @@ static struct PGM_SINGLE_TOP : public PGM_BASE
} program;
PGM_BASE& Pgm()
{
return program;
}
// A module to allow Html module initialization/cleanup
// When a wxHtmlWindow is used *only* in a dll/so module, the Html text is displayed
// as plain text.
@ -158,6 +152,7 @@ struct APP_SINGLE_TOP : public wxApp
{
APP_SINGLE_TOP() : wxApp()
{
SetPgm( &program );
// Init the environment each platform wants
KIPLATFORM::ENV::Init();
}

View File

@ -133,9 +133,6 @@ static struct IFACE : public KIFACE_BASE
using namespace CV;
static PGM_BASE* process;
KIFACE_BASE& Kiface() { return kiface; }
@ -143,26 +140,10 @@ KIFACE_BASE& Kiface() { return kiface; }
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
return &kiface;
}
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face
// is run from a python script, mot from a Kicad application
PGM_BASE* PgmOrNull()
{
return process;
}
/// The global footprint library table. This is not dynamically allocated because
/// in a multiple project environment we must keep its address constant (since it is
/// the fallback table for multiple projects).

View File

@ -535,14 +535,9 @@ endif()
add_executable( eeschema WIN32 MACOSX_BUNDLE
${CMAKE_SOURCE_DIR}/common/single_top.cpp
${CMAKE_SOURCE_DIR}/common/pgm_base.cpp
${EESCHEMA_RESOURCES}
)
if( KICAD_USE_SENTRY )
set_property(SOURCE ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}")
endif()
set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_SCH;PGM_DATA_FILE_EXT=\"kicad_sch\";BUILD_KIWAY_DLL"
)
@ -553,6 +548,7 @@ target_link_libraries( eeschema
common
pcbcommon
argparse::argparse
kicommon
${wxWidgets_LIBRARIES}
)

View File

@ -347,8 +347,6 @@ private:
using namespace SCH;
static PGM_BASE* process;
KIFACE_BASE& Kiface() { return kiface; }
@ -357,26 +355,10 @@ KIFACE_BASE& Kiface() { return kiface; }
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
{
process = aProgram;
return &kiface;
}
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from
// a python script or something else.
PGM_BASE* PgmOrNull()
{
return process;
}
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
{
// This is process-level-initialization, not project-level-initialization of the DSO.

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <nlohmann/json.hpp>
#include <json_common.h>
#include <settings/common_settings.h>
#include <settings/parameters.h>

View File

@ -103,14 +103,9 @@ endif()
add_executable( gerbview WIN32 MACOSX_BUNDLE
${CMAKE_SOURCE_DIR}/common/single_top.cpp
${CMAKE_SOURCE_DIR}/common/pgm_base.cpp
${GERBVIEW_RESOURCES}
)
if( KICAD_USE_SENTRY )
set_property(SOURCE ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}")
endif()
set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_GERBER;BUILD_KIWAY_DLL"
)
@ -120,6 +115,7 @@ target_link_libraries( gerbview
gal
common
core
kicommon
nlohmann_json
${wxWidgets_LIBRARIES}
)

View File

@ -130,9 +130,6 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
using namespace GERBV;
static PGM_BASE* process;
KIFACE_BASE& Kiface() { return kiface; }
@ -140,25 +137,10 @@ KIFACE_BASE& Kiface() { return kiface; }
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
{
process = aProgram;
return &kiface;
}
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return process;
}
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
{
InitSettings( new GERBVIEW_SETTINGS );

View File

@ -25,6 +25,7 @@
#ifndef BACKGROUND_JOBS_MONITOR_H
#define BACKGROUND_JOBS_MONITOR_H
#include <kicommon.h>
#include <widgets/progress_reporter_base.h>
#include <functional>
#include <memory>
@ -41,7 +42,7 @@ class BACKGROUND_JOBS_MONITOR;
class wxWindow;
class wxCloseEvent;
class BACKGROUND_JOB_REPORTER : public PROGRESS_REPORTER_BASE
class KICOMMON_API BACKGROUND_JOB_REPORTER : public PROGRESS_REPORTER_BASE
{
public:
BACKGROUND_JOB_REPORTER( BACKGROUND_JOBS_MONITOR* aMonitor,
@ -69,7 +70,7 @@ private:
};
struct BACKGROUND_JOB
struct KICOMMON_API BACKGROUND_JOB
{
public:
wxString m_name;
@ -81,7 +82,7 @@ public:
};
class BACKGROUND_JOBS_MONITOR
class KICOMMON_API BACKGROUND_JOBS_MONITOR
{
friend class BACKGROUND_JOB_REPORTER;
friend class BACKGROUND_JOB_LIST;

View File

@ -26,6 +26,7 @@
#include <wx/bmpbndl.h>
#include <bitmaps/bitmap_info.h>
#include <kicommon.h>
class ASSET_ARCHIVE;
class wxImage;
@ -33,7 +34,7 @@ class wxImage;
namespace std
{
template<> struct hash<std::pair<BITMAPS, int>>
template<> struct KICOMMON_API hash<std::pair<BITMAPS, int>>
{
size_t operator()( const std::pair<BITMAPS, int>& aPair ) const;
};
@ -42,7 +43,7 @@ namespace std
/**
* Helper to retrieve bitmaps while handling icon themes and scaling
*/
class BITMAP_STORE
class KICOMMON_API BITMAP_STORE
{
public:
BITMAP_STORE();

View File

@ -26,6 +26,8 @@
#ifndef BITMAP_TYPES_H_
#define BITMAP_TYPES_H_
#include <kicommon.h>
//FIXME: cannot include only this file in wxWidgets 2.9.3
// test if it works under stable release
// #include <wx/bitmap.h> // only to define wxBitmap
@ -44,7 +46,7 @@ enum class BITMAP_TYPE
BMP
};
BITMAP_STORE* GetBitmapStore();
KICOMMON_API BITMAP_STORE* GetBitmapStore();
/**
* Construct a wxBitmap from an image identifier
@ -52,17 +54,17 @@ BITMAP_STORE* GetBitmapStore();
* @param aBitmap is from the BITMAPS enum in bitmaps_list.h
* @param aHeightTag is the requested height tag for multi-res bitmaps (-1 for any)
*/
wxBitmap KiBitmap( BITMAPS aBitmap, int aHeightTag = -1 );
KICOMMON_API wxBitmap KiBitmap( BITMAPS aBitmap, int aHeightTag = -1 );
wxBitmapBundle KiBitmapBundle( BITMAPS aBitmap );
KICOMMON_API wxBitmapBundle KiBitmapBundle( BITMAPS aBitmap );
wxBitmapBundle KiDisabledBitmapBundle( BITMAPS aBitmap );
KICOMMON_API wxBitmapBundle KiDisabledBitmapBundle( BITMAPS aBitmap );
/**
* Wipes out the scaled bitmap cache so that the icon theme can be changed.
* TODO: move scaling system into BITMAP_STORE so this global doesn't need to exist
*/
void ClearScaledBitmapCache();
KICOMMON_API void ClearScaledBitmapCache();
/**
* Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
@ -75,8 +77,8 @@ void ClearScaledBitmapCache();
* @param aHeight is the requested image height for the source bitmap, or -1 for any height
* @param aQuantized if true scaling will be rounded to integers (2X, 3X, etc.).
*/
wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1,
bool aQuantized = false );
KICOMMON_API wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1,
bool aQuantized = false );
/**
* Overload of the above function that takes another wxBitmap as a parameter.
@ -84,13 +86,13 @@ wxBitmap KiScaledBitmap( BITMAPS aBitmap, wxWindow* aWindow, int aHeight = -1,
* @param aBitmap is the source bitmap to scale
* @param aWindow target window for scaling context
*/
wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, wxWindow* aWindow );
KICOMMON_API wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, wxWindow* aWindow );
/**
* Return the automatic scale factor that would be used for a given window by
* KiScaledBitmap and KiScaledSeparator.
*/
int KiIconScale( wxWindow* aWindow );
KICOMMON_API int KiIconScale( wxWindow* aWindow );
/**
* Allocate a wxBitmap on heap from a memory record, held in a BITMAPS.
@ -98,6 +100,6 @@ int KiIconScale( wxWindow* aWindow );
* @param aBitmap is from the BITMAPS enum in bitmaps_list.h
* @return wxBitmap* - caller owns it.
*/
wxBitmap* KiBitmapNew( BITMAPS aBitmap );
KICOMMON_API wxBitmap* KiBitmapNew( BITMAPS aBitmap );
#endif // BITMAP_TYPES_H_

View File

@ -32,6 +32,7 @@
#ifndef INCLUDE__COMMON_H_
#define INCLUDE__COMMON_H_
#include <kicommon.h>
#include <functional>
#include <memory>
@ -55,7 +56,7 @@ class REPORTER;
* @param aBaseName is the name of the help file to search for (without extension).
* @return the full path and filename if \a aBaseName is found, else wxEmptyString.
*/
wxString SearchHelpFileFullPath( const wxString& aBaseName );
KICOMMON_API wxString SearchHelpFileFullPath( const wxString& aBaseName );
/**
* Make \a aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
@ -66,14 +67,14 @@ wxString SearchHelpFileFullPath( const wxString& aBaseName );
* @param aReporter a point to a REPORTER object use to show messages (can be NULL)
* @return true if \a aOutputDir already exists or was successfully created.
*/
bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName,
const wxString& aBaseFilename,
REPORTER* aReporter = nullptr );
KICOMMON_API bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName,
const wxString& aBaseFilename,
REPORTER* aReporter = nullptr );
/**
* It's annoying to throw up nag dialogs when the extension isn't right. Just fix it.
*/
wxString EnsureFileExtension( const wxString& aFilename, const wxString& aExtension );
KICOMMON_API wxString EnsureFileExtension( const wxString& aFilename, const wxString& aExtension );
/**
* Replace any environment variable & text variable references with their values.
@ -81,34 +82,35 @@ wxString EnsureFileExtension( const wxString& aFilename, const wxString& aExtens
* @param aString a string containing (perhaps) references to env var
* @return the expanded environment variable.
*/
const wxString ExpandEnvVarSubstitutions( const wxString& aString, const PROJECT* aProject );
KICOMMON_API const wxString ExpandEnvVarSubstitutions( const wxString& aString,
const PROJECT* aProject );
/**
* Expand '${var-name}' templates in text.
*/
wxString ExpandTextVars( const wxString& aSource,
const std::function<bool( wxString* )>* aResolver );
KICOMMON_API wxString ExpandTextVars( const wxString& aSource,
const std::function<bool( wxString* )>* aResolver );
wxString ExpandTextVars( const wxString& aSource, const PROJECT* aProject );
KICOMMON_API wxString ExpandTextVars( const wxString& aSource, const PROJECT* aProject );
/**
* Returns any variables unexpanded, e.g. ${VAR} -> VAR
*/
wxString GetTextVars( const wxString& aSource );
KICOMMON_API wxString GetTextVars( const wxString& aSource );
/**
* Returns true if the string is a text var, e.g starts with ${
*/
bool IsTextVar( const wxString& aSource );
KICOMMON_API bool IsTextVar( const wxString& aSource );
/**
* Replace any environment and/or text variables in file-path uris (leaving network-path URIs
* alone).
*/
const wxString ResolveUriByEnvVars( const wxString& aUri, PROJECT* aProject );
KICOMMON_API const wxString ResolveUriByEnvVars( const wxString& aUri, PROJECT* aProject );
long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec );
KICOMMON_API long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec );
/**
@ -116,7 +118,7 @@ long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec );
*
* @return true if the operating system is unsupported
*/
bool WarnUserIfOperatingSystemUnsupported();
KICOMMON_API bool WarnUserIfOperatingSystemUnsupported();
#endif // INCLUDE__COMMON_H_

View File

@ -32,7 +32,7 @@ enum class DATABASE_SOURCE_TYPE
};
struct DATABASE_SOURCE
struct KICOMMON_API DATABASE_SOURCE
{
DATABASE_SOURCE_TYPE type;
std::string dsn;
@ -43,15 +43,15 @@ struct DATABASE_SOURCE
};
struct DATABASE_FIELD_MAPPING
struct KICOMMON_API DATABASE_FIELD_MAPPING
{
const std::string column; ///< Database column name
const std::string name; ///< KiCad field name
const wxString name_wx; ///< KiCad field name (converted)
const bool visible_on_add; ///< Whether to show the field when placing the symbol
const bool visible_in_chooser; ///< Whether the column is shown by default in the chooser
const bool show_name; ///< Whether or not to show the field name as well as its value
const bool inherit_properties; ///< Whether or not to inherit properties from symbol field
std::string column; ///< Database column name
std::string name; ///< KiCad field name
wxString name_wx; ///< KiCad field name (converted)
bool visible_on_add; ///< Whether to show the field when placing the symbol
bool visible_in_chooser; ///< Whether the column is shown by default in the chooser
bool show_name; ///< Whether or not to show the field name as well as its value
bool inherit_properties; ///< Whether or not to inherit properties from symbol field
explicit DATABASE_FIELD_MAPPING( std::string aColumn, std::string aName, bool aVisibleOnAdd,
bool aVisibleInChooser, bool aShowName,
@ -59,7 +59,7 @@ struct DATABASE_FIELD_MAPPING
};
struct MAPPABLE_SYMBOL_PROPERTIES
struct KICOMMON_API MAPPABLE_SYMBOL_PROPERTIES
{
std::string description;
std::string footprint_filters;
@ -83,7 +83,7 @@ struct MAPPABLE_SYMBOL_PROPERTIES
* table called "Capacitors", with `key_col` set to "Part Number", the LIB_ID for a capacitor placed
* from this table will look something like `PartsDB-Capacitors:CAP-001`
*/
struct DATABASE_LIB_TABLE
struct KICOMMON_API DATABASE_LIB_TABLE
{
std::string name; ///< KiCad library nickname (will form part of the LIB_ID)
std::string table; ///< Database table to pull content from
@ -96,14 +96,14 @@ struct DATABASE_LIB_TABLE
};
struct DATABASE_CACHE_SETTINGS
struct KICOMMON_API DATABASE_CACHE_SETTINGS
{
int max_size; ///< Maximum number of single-row results to cache
int max_age; ///< Max age of cached rows before they expire, in seconds
};
class DATABASE_LIB_SETTINGS : public JSON_SETTINGS
class KICOMMON_API DATABASE_LIB_SETTINGS : public JSON_SETTINGS
{
public:
DATABASE_LIB_SETTINGS( const std::string& aFilename );

View File

@ -25,6 +25,7 @@
#ifndef DIALOG_SHIM_
#define DIALOG_SHIM_
#include <kicommon.h>
#include <wx/dialog.h>
#include <kiway_player.h>
class wxGridEvent;
@ -79,7 +80,7 @@ class WX_EVENT_LOOP;
* <br>
* in the dialog window's properties.
*/
class DIALOG_SHIM : public wxDialog, public KIWAY_HOLDER
class KICOMMON_API DIALOG_SHIM : public wxDialog, public KIWAY_HOLDER
{
public:
DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title,

View File

@ -27,7 +27,7 @@
class SETTINGS_MANAGER;
class DIALOG_MIGRATE_SETTINGS : public DIALOG_MIGRATE_SETTINGS_BASE
class KICOMMON_API DIALOG_MIGRATE_SETTINGS : public DIALOG_MIGRATE_SETTINGS_BASE
{
public:
DIALOG_MIGRATE_SETTINGS( SETTINGS_MANAGER* aManager );

View File

@ -25,6 +25,7 @@
#ifndef ENV_VARS_H
#define ENV_VARS_H
#include <kicommon.h>
#include <wx/string.h>
#include <map>
#include <vector>
@ -43,19 +44,19 @@ namespace ENV_VAR
* @param aEnvVar the variable to check
* @return true if predefined
*/
bool IsEnvVarImmutable( const wxString& aEnvVar );
KICOMMON_API bool IsEnvVarImmutable( const wxString& aEnvVar );
/**
* Get the list of pre-defined environment variables.
*/
const ENV_VAR_LIST& GetPredefinedEnvVars();
KICOMMON_API const ENV_VAR_LIST& GetPredefinedEnvVars();
/**
* Constructs a versioned environment variable based on this KiCad major version
* @param aBaseName is the suffix, like TEMPLATE_DIR
* @return an environment variable name, like KICAD8_TEMPLATE_DIR
*/
wxString GetVersionedEnvVarName( const wxString& aBaseName );
KICOMMON_API wxString GetVersionedEnvVarName( const wxString& aBaseName );
/**
* Attempts to retrieve the value of a versioned environment variable, such as
@ -65,8 +66,8 @@ namespace ENV_VAR
* @param aMap is an ENV_VAR_MAP (@see environment.h)
* @param aBaseName is the suffix for the environment variable (@see GetVersionedEnvVarName)
*/
std::optional<wxString> GetVersionedEnvVarValue( const std::map<wxString, ENV_VAR_ITEM>& aMap,
const wxString& aBaseName );
KICOMMON_API std::optional<wxString> GetVersionedEnvVarValue( const std::map<wxString, ENV_VAR_ITEM>& aMap,
const wxString& aBaseName );
/**
* Look up long-form help text for a given environment variable.
@ -78,7 +79,7 @@ namespace ENV_VAR
* @return A string with help for that variable. Empty if
* no help available for this variable.
*/
wxString LookUpEnvVarHelp( const wxString& aEnvVar );
KICOMMON_API wxString LookUpEnvVarHelp( const wxString& aEnvVar );
/**
* Get an environment variable as a specific type, if set correctly
@ -87,7 +88,7 @@ namespace ENV_VAR
* @return an std::optional containing the value, if set and parseable, otherwise empty.
*/
template <typename VAL_TYPE>
std::optional<VAL_TYPE> GetEnvVar( const wxString& aEnvVarName );
KICOMMON_API std::optional<VAL_TYPE> GetEnvVar( const wxString& aEnvVarName );
/**
* Get a string environment variable, if it is set.
@ -96,7 +97,7 @@ namespace ENV_VAR
* @return an std::optional containing the value, if set, otherwise empty.
*/
template<>
std::optional<wxString> GetEnvVar( const wxString& aEnvVarName );
KICOMMON_API std::optional<wxString> GetEnvVar( const wxString& aEnvVarName );
/**
* Get a double from an environment variable, if set
@ -106,7 +107,7 @@ namespace ENV_VAR
* otherwise empty.
*/
template <>
std::optional<double> GetEnvVar( const wxString& aEnvVarName );
KICOMMON_API std::optional<double> GetEnvVar( const wxString& aEnvVarName );
};
#endif /* ENV_VARS_H */

View File

@ -25,6 +25,7 @@
#ifndef GESTFICH_H
#define GESTFICH_H
#include <kicommon.h>
#include <wx/filename.h>
#include <wx/process.h>
@ -45,15 +46,16 @@ class EDA_LIST_DIALOG;
* @param file the PDF file to open.
* @return true is success or false if no PDF viewer found.
*/
bool OpenPDF( const wxString& file );
void OpenFile( const wxString& file );
KICOMMON_API bool OpenPDF( const wxString& file );
KICOMMON_API void OpenFile( const wxString& file );
/**
* @param aSrcPath is the full filename of the source.
* @param aDestPath is the full filename of the target
* @param aErrors a wxString to *append* any errors to
*/
void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, wxString& aErrors );
KICOMMON_API void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath,
wxString& aErrors );
/**
* Call the executable file \a aEditorName with the parameter \a aFileName.
@ -64,7 +66,7 @@ void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, wxString&
* In this case aFileName is a shortname and FindKicadFile() is called to return the path.
* In the other case, aFileName is a full file name (passed prefixed with the path).
*/
int ExecuteFile( const wxString& aEditorName, const wxString& aFileName = wxEmptyString,
KICOMMON_API int ExecuteFile( const wxString& aEditorName, const wxString& aFileName = wxEmptyString,
wxProcess* aCallback = nullptr, bool aFileForKicad = true );
/**
@ -72,7 +74,7 @@ int ExecuteFile( const wxString& aEditorName, const wxString& aFileName = wxEmpt
*
* @param string string to modify.
*/
void QuoteString( wxString& string );
KICOMMON_API void QuoteString( wxString& string );
/**
* Search the executable file shortname in KiCad binary path and return full file
@ -84,7 +86,7 @@ void QuoteString( wxString& string );
* - c:\\kicad or /usr/local/kicad (the default).
* - default binary path.
*/
wxString FindKicadFile( const wxString& shortname );
KICOMMON_API wxString FindKicadFile( const wxString& shortname );
/**
* Quote return value of wxFileName::GetFullPath().
@ -96,13 +98,13 @@ wxString FindKicadFile( const wxString& shortname );
* @param format if provided, can be used to transform the nature of the wrapped filename
* to another platform.
*/
extern wxString QuoteFullPath( wxFileName& fn, wxPathFormat format = wxPATH_NATIVE );
KICOMMON_API extern wxString QuoteFullPath( wxFileName& fn, wxPathFormat format = wxPATH_NATIVE );
/**
* Removes the directory \a aDirName and all its contents including
* subdirectories and their files
*/
bool RmDirRecursive( const wxString& aDirName, wxString* aErrors = nullptr );
KICOMMON_API bool RmDirRecursive( const wxString& aDirName, wxString* aErrors = nullptr );
#endif /* GESTFICH_H */

View File

@ -275,7 +275,7 @@ struct KIFACE
* and a #NETLIST, (anything relating to production of a single #BOARD and added to class
* #PROJECT.)
*/
class KIWAY : public wxEvtHandler
class KICOMMON_API KIWAY : public wxEvtHandler
{
friend struct PGM_SINGLE_TOP; // can use set_kiface()
@ -403,7 +403,7 @@ public:
*/
virtual void ProjectChanged();
KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop = nullptr );
KIWAY( int aCtlBits, wxFrame* aTop = nullptr );
/**
* Overwrites previously set ctl bits, only for use in kicad.cpp to flip between
@ -459,7 +459,6 @@ private:
static KIFACE* m_kiface[KIWAY_FACE_COUNT];
static int m_kiface_version[KIWAY_FACE_COUNT];
PGM_BASE* m_program;
int m_ctl;
wxFrame* m_top; // Usually m_top is the Project manager

View File

@ -28,6 +28,7 @@
// @see http://wiki.wxwidgets.org/Custom_Events_Tutorial
#include <frame_type.h>
#include <mail_type.h>
#include <kicommon.h>
#include <wx/string.h>
#include <wx/event.h>
@ -35,7 +36,7 @@
/**
* Carry a payload from one #KIWAY_PLAYER to another within a #PROJECT.
*/
class KIWAY_EXPRESS : public wxEvent
class KICOMMON_API KIWAY_EXPRESS : public wxEvent
{
public:
/**

View File

@ -24,6 +24,8 @@
#ifndef KIWAY_HOLDER_H_
#define KIWAY_HOLDER_H_
#include <kicommon.h>
class KIWAY;
class PROJECT;
class wxWindow;
@ -33,7 +35,7 @@ class wxWindow;
*
* It allows calls to Kiway() and SetKiway().
*/
class KIWAY_HOLDER
class KICOMMON_API KIWAY_HOLDER
{
public:
enum HOLDER_TYPE { DIALOG, FRAME, PANEL };

View File

@ -21,12 +21,14 @@
#ifndef LAUNCH_EXT_H
#define LAUNCH_EXT_H
#include <kicommon.h>
class wxString;
/**
* Launches the given file or folder in the host OS
* @param aPath is a path to a file or folder
*/
bool LaunchExternal( const wxString& aPath );
KICOMMON_API bool LaunchExternal( const wxString& aPath );
#endif

View File

@ -34,6 +34,7 @@
#include <project.h>
#include <string_utf8_map.h>
#include <richio.h>
#include <kicommon.h>
class OUTPUTFORMATTER;
class LIB_TABLE_LEXER;
@ -55,14 +56,14 @@ typedef LIB_TABLE_ROWS::const_iterator LIB_TABLE_ROWS_CITER;
* store pointers the data is cloned. Copying and assigning pointers would cause ownership
* issues if the standard C++ containers were used.
*/
LIB_TABLE_ROW* new_clone( const LIB_TABLE_ROW& aRow );
KICOMMON_API LIB_TABLE_ROW* new_clone( const LIB_TABLE_ROW& aRow );
/**
* Hold a record identifying a library accessed by the appropriate plug in object in the
* #LIB_TABLE. This is an abstract base class from which to derive library specific rows.
*/
class LIB_TABLE_ROW
class KICOMMON_API LIB_TABLE_ROW
{
public:
LIB_TABLE_ROW() :
@ -292,7 +293,7 @@ private:
*
* @author Wayne Stambaugh
*/
class LIB_TABLE : public PROJECT::_ELEM
class KICOMMON_API LIB_TABLE : public PROJECT::_ELEM
{
public:
/**

View File

@ -25,6 +25,7 @@
#ifndef NOTIFICATIONS_MANAGER_H
#define NOTIFICATIONS_MANAGER_H
#include <kicommon.h>
#include <functional>
#include <vector>
@ -36,7 +37,7 @@ class wxWindow;
class wxCloseEvent;
struct NOTIFICATION
struct KICOMMON_API NOTIFICATION
{
public:
wxString title; ///< Title of the notification
@ -47,7 +48,7 @@ public:
};
class NOTIFICATIONS_MANAGER
class KICOMMON_API NOTIFICATIONS_MANAGER
{
friend class NOTIFICATION_LIST;

View File

@ -31,6 +31,7 @@
#ifndef PGM_BASE_H_
#define PGM_BASE_H_
#include <kicommon.h>
#include <exception>
#include <map>
#include <vector>
@ -58,7 +59,7 @@ class SCRIPTING;
* maintainer's convenience. To add a support to a new translation add a new item
* to #LanguagesList[].
*/
struct LANGUAGE_DESCR
struct KICOMMON_API LANGUAGE_DESCR
{
/// wxWidgets locale identifier (See wxWidgets doc)
int m_WX_Lang_Identifier;
@ -77,7 +78,7 @@ struct LANGUAGE_DESCR
/**
* An array containing all the languages that KiCad supports.
*/
extern LANGUAGE_DESCR LanguagesList[];
KICOMMON_API extern LANGUAGE_DESCR LanguagesList[];
/**
* Container for data for KiCad programs.
@ -92,7 +93,7 @@ extern LANGUAGE_DESCR LanguagesList[];
* - OnPgmEnd() is virtual, may be overridden, and parallels wxApp::OnExit(), from where it
* should be called.
*/
class PGM_BASE
class KICOMMON_API PGM_BASE
{
public:
PGM_BASE();
@ -430,11 +431,13 @@ protected:
/// The global Program "get" accessor.
/// Implemented in: 1) common/single_top.cpp, 2) kicad/kicad.cpp, and 3) scripting/kiway.i
extern PGM_BASE& Pgm();
KICOMMON_API extern PGM_BASE& Pgm();
/// similar to PGM_BASE& Pgm(), but return a reference that can be nullptr
/// when running a shared lib from a script, not from a kicad appl
extern PGM_BASE* PgmOrNull();
KICOMMON_API extern PGM_BASE* PgmOrNull();
KICOMMON_API extern void SetPgm( PGM_BASE* pgm );
#endif // PGM_BASE_H_

View File

@ -58,7 +58,7 @@ class PROJECT_LOCAL_SETTINGS;
* Because it is in the neutral program top, which is not linked to by subsidiary DSOs,
* any functions in this interface must be virtual.
*/
class PROJECT
class KICOMMON_API PROJECT
{
public:
/**
@ -69,7 +69,7 @@ public:
* include derived class headers in this file, you are doing incompatible with the goal
* of this class. Keep knowledge of derived classes opaque to class PROJECT please.
*/
class _ELEM
class KICOMMON_API _ELEM
{
public:
virtual ~_ELEM() {}

View File

@ -39,7 +39,7 @@
* Selection filtering that applies all the time (not the "filter selection" dialog that modifies
* the current selection)
*/
struct PCB_SELECTION_FILTER_OPTIONS
struct KICOMMON_API PCB_SELECTION_FILTER_OPTIONS
{
bool lockedItems; ///< Allow selecting locked items
bool footprints; ///< Allow selecting entire footprints
@ -125,7 +125,7 @@ enum class RATSNEST_MODE
};
///< BOM Data choices for IPC2581 export
struct IP2581_BOM
struct KICOMMON_API IP2581_BOM
{
wxString mfg; ///< Manufacturer name column
wxString MPN; ///< Manufacturer part number column
@ -137,7 +137,7 @@ struct IP2581_BOM
/**
* A saved set of layers that are visible.
*/
struct LAYER_PRESET
struct KICOMMON_API LAYER_PRESET
{
LAYER_PRESET( const wxString& aName = wxS( "" ) ) :
name( aName ),
@ -184,7 +184,7 @@ struct LAYER_PRESET
};
class PARAM_LAYER_PRESET : public PARAM_LAMBDA<nlohmann::json>
class KICOMMON_API PARAM_LAYER_PRESET : public PARAM_LAMBDA<nlohmann::json>
{
public:
PARAM_LAYER_PRESET( const std::string& aPath, std::vector<LAYER_PRESET>* aPresetList );
@ -198,7 +198,7 @@ private:
};
struct VIEWPORT
struct KICOMMON_API VIEWPORT
{
VIEWPORT( const wxString& aName = wxEmptyString ) :
name( aName )
@ -214,7 +214,7 @@ struct VIEWPORT
};
class PARAM_VIEWPORT : public PARAM_LAMBDA<nlohmann::json>
class KICOMMON_API PARAM_VIEWPORT : public PARAM_LAMBDA<nlohmann::json>
{
public:
PARAM_VIEWPORT( const std::string& aPath, std::vector<VIEWPORT>* aViewportList );
@ -228,7 +228,7 @@ private:
};
struct VIEWPORT3D
struct KICOMMON_API VIEWPORT3D
{
VIEWPORT3D( const wxString& aName = wxEmptyString ) :
name( aName )
@ -244,7 +244,7 @@ struct VIEWPORT3D
};
class PARAM_VIEWPORT3D : public PARAM_LAMBDA<nlohmann::json>
class KICOMMON_API PARAM_VIEWPORT3D : public PARAM_LAMBDA<nlohmann::json>
{
public:
PARAM_VIEWPORT3D( const std::string& aPath, std::vector<VIEWPORT3D>* aViewportList );
@ -260,7 +260,7 @@ private:
/**
* Persisted state for the net inspector panel
*/
struct PANEL_NET_INSPECTOR_SETTINGS
struct KICOMMON_API PANEL_NET_INSPECTOR_SETTINGS
{
wxString filter_text;
bool filter_by_net_name;

View File

@ -30,7 +30,7 @@
* NET_SETTINGS stores various net-related settings in a project context. These settings are
* accessible and editable from both the schematic and PCB editors.
*/
class NET_SETTINGS : public NESTED_SETTINGS
class KICOMMON_API NET_SETTINGS : public NESTED_SETTINGS
{
public:
NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );

View File

@ -21,6 +21,7 @@
#define KICAD_PROJECT_ARCHIVER_H
#include <wx/string.h>
#include <kicommon.h>
class PROJECT;
@ -28,7 +29,7 @@ class REPORTER;
class SETTINGS_MANAGER;
class PROJECT_ARCHIVER
class KICOMMON_API PROJECT_ARCHIVER
{
public:
PROJECT_ARCHIVER();

View File

@ -66,7 +66,7 @@ enum LAST_PATH_TYPE : unsigned int
* There is either zero or one PROJECT_FILE for every PROJECT
* (you can have a dummy PROJECT that has no file)
*/
class PROJECT_FILE : public JSON_SETTINGS
class KICOMMON_API PROJECT_FILE : public JSON_SETTINGS
{
public:
/**

View File

@ -31,7 +31,7 @@
class PROJECT;
struct PROJECT_FILE_STATE
struct KICOMMON_API PROJECT_FILE_STATE
{
wxString fileName;
bool open;
@ -51,7 +51,7 @@ struct PROJECT_FILE_STATE
* This file doesn't need to exist for a project to be loaded. It will be created on-demand if
* any of the things stored here are modified by the user.
*/
class PROJECT_LOCAL_SETTINGS : public JSON_SETTINGS
class KICOMMON_API PROJECT_LOCAL_SETTINGS : public JSON_SETTINGS
{
public:
PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxString& aFilename );

View File

@ -26,6 +26,7 @@
#ifndef SEARCH_STACK_H_
#define SEARCH_STACK_H_
#include <kicommon.h>
#include <wx/filefn.h>
#include <wx/filename.h>
#include <project.h>
@ -38,7 +39,7 @@
* reminder that anything you put in here means searching work at some point in time.
* (An alternative is to simply know where something is.)
*/
class SEARCH_STACK : public wxPathList, public PROJECT::_ELEM
class KICOMMON_API SEARCH_STACK : public wxPathList, public PROJECT::_ELEM
{
public:
KICAD_T Type() override { return SEARCH_STACK_T; }

View File

@ -28,7 +28,7 @@
/**
* Cross-probing behavior
*/
struct CROSS_PROBING_SETTINGS
struct KICOMMON_API CROSS_PROBING_SETTINGS
{
bool on_selection; ///< Synchronize the selection for multiple items too
bool center_on_items; ///< Automatically pan to cross-probed items
@ -39,7 +39,7 @@ struct CROSS_PROBING_SETTINGS
/**
* Common cursor settings, available to every frame
*/
struct CURSOR_SETTINGS
struct KICOMMON_API CURSOR_SETTINGS
{
bool always_show_cursor;
bool fullscreen_cursor;
@ -57,7 +57,7 @@ enum class ARC_EDIT_MODE
/**
* Stores the window positioning/state
*/
struct WINDOW_STATE
struct KICOMMON_API WINDOW_STATE
{
bool maximized;
int size_x;
@ -70,7 +70,7 @@ struct WINDOW_STATE
/**
* Stores the common settings that are saved and loaded for each window / frame
*/
struct WINDOW_SETTINGS
struct KICOMMON_API WINDOW_SETTINGS
{
WINDOW_STATE state;
wxString mru_path;
@ -88,7 +88,7 @@ struct WINDOW_SETTINGS
*
* COMMON_SETTINGS stores settings that are always the same across all applications.
*/
class APP_SETTINGS_BASE : public JSON_SETTINGS
class KICOMMON_API APP_SETTINGS_BASE : public JSON_SETTINGS
{
public:
struct FIND_REPLACE

View File

@ -48,7 +48,7 @@ using KIGFX::COLOR4D;
* Each application (eeschema, gerbview, pcbnew) can have a different active color scheme selected.
* The "child applications" (library editors) inherit from either eeschema or pcbnew.
*/
class COLOR_SETTINGS : public JSON_SETTINGS
class KICOMMON_API COLOR_SETTINGS : public JSON_SETTINGS
{
public:
explicit COLOR_SETTINGS( const wxString& aFilename = wxT( "user" ),

View File

@ -44,7 +44,7 @@ enum class ICON_THEME
};
class COMMON_SETTINGS : public JSON_SETTINGS
class KICOMMON_API COMMON_SETTINGS : public JSON_SETTINGS
{
public:
struct APPEARANCE

View File

@ -25,7 +25,7 @@
#define PCM_DEFAULT_REPOSITORY_URL "https://repository.kicad.org/repository.json"
class KICAD_SETTINGS : public APP_SETTINGS_BASE
class KICOMMON_API KICAD_SETTINGS : public APP_SETTINGS_BASE
{
public:
KICAD_SETTINGS();

View File

@ -300,7 +300,8 @@ public:
m_default( std::move( aDefault ) ),
m_getter( std::move( aGetter ) ),
m_setter( std::move( aSetter ) )
{ }
{
}
void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
{
@ -367,11 +368,17 @@ private:
std::function<void( ValueType )> m_setter;
};
#ifdef _MSC_VER
template class KICOMMON_API PARAM_LAMBDA<bool>;
template class KICOMMON_API PARAM_LAMBDA<int>;
template class KICOMMON_API PARAM_LAMBDA<nlohmann::json>;
template class KICOMMON_API PARAM_LAMBDA<std::string>;
#else
extern template class APIVISIBLE PARAM_LAMBDA<bool>;
extern template class APIVISIBLE PARAM_LAMBDA<int>;
extern template class APIVISIBLE PARAM_LAMBDA<nlohmann::json>;
extern template class APIVISIBLE PARAM_LAMBDA<std::string>;
#endif
/**
* Represents a parameter that has a scaling factor between the value in the file and the
@ -550,15 +557,25 @@ protected:
};
#ifdef _MSC_VER
template class KICOMMON_API PARAM_LIST<bool>;
template class KICOMMON_API PARAM_LIST<int>;
template class KICOMMON_API PARAM_LIST<double>;
template class KICOMMON_API PARAM_LIST<KIGFX::COLOR4D>;
template class KICOMMON_API PARAM_LIST<struct BOM_PRESET>;
template class KICOMMON_API PARAM_LIST<struct BOM_FMT_PRESET>;
template class KICOMMON_API PARAM_LIST<GRID>;
template class KICOMMON_API PARAM_LIST<wxString>;
#else
extern template class APIVISIBLE PARAM_LIST<bool>;
extern template class APIVISIBLE PARAM_LIST<int>;
extern template class APIVISIBLE PARAM_LIST<double>;
extern template class APIVISIBLE PARAM_LIST<KIGFX::COLOR4D>;
//template KICOMMON_EXTERN_DECL class PARAM_LIST<FILE_INFO_PAIR>;
extern template class APIVISIBLE PARAM_LIST<struct BOM_PRESET>;
extern template class APIVISIBLE PARAM_LIST<struct BOM_FMT_PRESET>;
extern template class APIVISIBLE PARAM_LIST<GRID>;
extern template class APIVISIBLE PARAM_LIST<wxString>;
#endif
template<typename Type>
@ -639,7 +656,11 @@ protected:
std::set<Type> m_default;
};
#ifdef _MSC_VER
template class KICOMMON_API PARAM_SET<wxString>;
#else
extern template class APIVISIBLE PARAM_SET<wxString>;
#endif
/**
* Represents a list of strings holding directory paths.
@ -776,9 +797,15 @@ private:
};
#ifdef _MSC_VER
template class KICOMMON_API PARAM_MAP<int>;
template class KICOMMON_API PARAM_MAP<double>;
template class KICOMMON_API PARAM_MAP<bool>;
#else
extern template class APIVISIBLE PARAM_MAP<int>;
extern template class APIVISIBLE PARAM_MAP<double>;
extern template class APIVISIBLE PARAM_MAP<bool>;
#endif
/**

View File

@ -41,7 +41,7 @@ class LOCKFILE;
#define PROJECT_BACKUPS_DIR_SUFFIX wxT( "-backups" )
class SETTINGS_MANAGER
class KICOMMON_API SETTINGS_MANAGER
{
public:
SETTINGS_MANAGER( bool aHeadless = false );

View File

@ -37,12 +37,12 @@ class SEARCH_STACK;
* Append system places to \a aSearchStack in a platform specific way and pertinent
* to KiCad programs.
*/
void SystemDirsAppend( SEARCH_STACK* aSearchStack );
KICOMMON_API void SystemDirsAppend( SEARCH_STACK* aSearchStack );
/**
* Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
* Adds libraries, docs, template paths to the search stack.
*/
void GlobalPathsAppend( SEARCH_STACK* aDst, KIWAY::FACE_T aId );
KICOMMON_API void GlobalPathsAppend( SEARCH_STACK* aDst, KIWAY::FACE_T aId );
#endif // INCLUDE__SYSTEM_DIRS_APPEND_H_

View File

@ -25,6 +25,7 @@
#ifndef BITMAP_BUTTON_H_
#define BITMAP_BUTTON_H_
#include <kicommon.h>
#include <wx/bmpbndl.h>
#include <wx/panel.h>
#include <wx/colour.h>
@ -37,7 +38,7 @@
* * It has a rectangle highlight when the mouse is hovering/pressed
* * It has the ability to be checked/toggled
*/
class BITMAP_BUTTON : public wxPanel
class KICOMMON_API BITMAP_BUTTON : public wxPanel
{
public:
BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos = wxDefaultPosition,

View File

@ -25,6 +25,8 @@
#ifndef KISTATUSBAR_H
#define KISTATUSBAR_H
#include <kicommon.h>
class wxGauge;
class wxButton;
class wxStaticText;
@ -39,7 +41,7 @@ class BITMAP_BUTTON;
* Background notifications button (FIELD_OFFSET_NOTIFICATION_BUTTON offset id)
*/
class KISTATUSBAR : public wxStatusBar
class KICOMMON_API KISTATUSBAR : public wxStatusBar
{
public:
KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id );

View File

@ -26,6 +26,7 @@
#ifndef UI_COMMON_H
#define UI_COMMON_H
#include <kicommon.h>
#include "report_severity.h" // enum SEVERITY
#include <wx/string.h>
#include <wx/font.h>
@ -51,20 +52,20 @@ namespace KIUI
* Get the standard margin around a widget in the KiCad UI
* @return margin in pixels
*/
int GetStdMargin();
KICOMMON_API int GetStdMargin();
/**
* Return the size of @a aSingleLine of text when it is rendered in @a aWindow
* using whatever font is currently set in that window.
*/
wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow );
KICOMMON_API wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow );
wxFont GetMonospacedUIFont();
KICOMMON_API wxFont GetMonospacedUIFont();
wxFont GetControlFont( wxWindow* aWindow );
wxFont GetInfoFont( wxWindow* aWindow );
wxFont GetDockedPaneFont( wxWindow* aWindow );
wxFont GetStatusFont( wxWindow* aWindow );
KICOMMON_API wxFont GetControlFont( wxWindow* aWindow );
KICOMMON_API wxFont GetInfoFont( wxWindow* aWindow );
KICOMMON_API wxFont GetDockedPaneFont( wxWindow* aWindow );
KICOMMON_API wxFont GetStatusFont( wxWindow* aWindow );
/**
* Set the minimum pixel width on a text control in order to make a text
@ -80,33 +81,33 @@ wxFont GetStatusFont( wxWindow* aWindow );
* the text already within the control is used.
* @return true if the \a aCtrl had its size changed, else false.
*/
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = nullptr );
KICOMMON_API bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = nullptr );
/**
* Select the number (or "?") in a reference for ease of editing.
*/
void SelectReferenceNumber( wxTextEntry* aTextEntry );
KICOMMON_API void SelectReferenceNumber( wxTextEntry* aTextEntry );
/**
* Ellipsize text (at the end) to be no more than 1/3 of the window width.
*
* @return shortened text ending with an ellipsis.
*/
wxString EllipsizeStatusText( wxWindow* aWindow, const wxString& aString );
KICOMMON_API wxString EllipsizeStatusText( wxWindow* aWindow, const wxString& aString );
/**
* Ellipsize text (at the end) to be no more than 36 characters.
*
* @return shortened text ending with an ellipsis.
*/
wxString EllipsizeMenuText( const wxString& aString );
KICOMMON_API wxString EllipsizeMenuText( const wxString& aString );
/**
* Check if a input control has focus.
*
* @param aFocus Control that has focus, if null, wxWidgets will be queried
*/
bool IsInputControlFocused( wxWindow* aFocus = nullptr );
KICOMMON_API bool IsInputControlFocused( wxWindow* aFocus = nullptr );
/**
* Check if a input control has focus.
@ -115,17 +116,17 @@ bool IsInputControlFocused( wxWindow* aFocus = nullptr );
* @return True if control is input and editable OR control is not a input. False if control is
* input and not editable.
*/
bool IsInputControlEditable( wxWindow* aControl );
KICOMMON_API bool IsInputControlEditable( wxWindow* aControl );
bool IsModalDialogFocused();
KICOMMON_API bool IsModalDialogFocused();
/**
* Makes a window read-only. Does some extra work over wxWindow::Disable() to make sure you
* can still scroll around in sub-windows.
*/
void Disable( wxWindow* aWindow );
KICOMMON_API void Disable( wxWindow* aWindow );
extern const wxString s_FocusStealableInputName;
KICOMMON_API extern const wxString s_FocusStealableInputName;
/**
@ -138,7 +139,7 @@ extern const wxString s_FocusStealableInputName;
* @param aMenu is the menuitem.
* @param aImage is the icon to add to aMenu.
*/
void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage );
KICOMMON_API void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage );
/**
@ -151,8 +152,8 @@ void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage );
* @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ...
* @return a pointer to the new created wxMenuItem.
*/
wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wxBitmap& aImage,
wxItemKind aType = wxITEM_NORMAL );
KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wxBitmap& aImage,
wxItemKind aType = wxITEM_NORMAL );
/**
@ -166,8 +167,8 @@ wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wx
* @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ...
* @return a pointer to the new created wxMenuItem.
*/
wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wxString& aHelpText,
const wxBitmap& aImage, wxItemKind aType = wxITEM_NORMAL );
KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wxString& aHelpText,
const wxBitmap& aImage, wxItemKind aType = wxITEM_NORMAL );
/**
@ -180,8 +181,8 @@ wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, const wx
* @param aImage is the icon to add to the new menu item.
* @return a pointer to the new created wxMenuItem,
*/
wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxString& aText,
const wxBitmap& aImage );
KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxString& aText,
const wxBitmap& aImage );
/**
@ -196,12 +197,12 @@ wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxStrin
* @param aImage is the icon to add to the new menu item.
* @return a pointer to the new created wxMenuItem.
*/
wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxString& aText,
const wxString& aHelpText, const wxBitmap& aImage );
KICOMMON_API wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, const wxString& aText,
const wxString& aHelpText, const wxBitmap& aImage );
}
SEVERITY SeverityFromString( const wxString& aSeverity );
KICOMMON_API SEVERITY SeverityFromString( const wxString& aSeverity );
wxString SeverityToString( const SEVERITY& aSeverity );
KICOMMON_API wxString SeverityToString( const SEVERITY& aSeverity );
#endif // UI_COMMON_H

View File

@ -73,20 +73,6 @@ KIFACE_BASE& Kiface()
static PGM_KICAD program;
PGM_BASE& Pgm()
{
return program;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return &program;
}
PGM_KICAD& PgmTop()
{
return program;
@ -414,7 +400,7 @@ void PGM_KICAD::Destroy()
}
KIWAY Kiway( &Pgm(), KFCTL_CPP_PROJECT_SUITE );
KIWAY Kiway( KFCTL_CPP_PROJECT_SUITE );
#ifdef NDEBUG
// Define a custom assertion handler
@ -435,6 +421,8 @@ struct APP_KICAD : public wxApp
{
APP_KICAD() : wxApp()
{
SetPgm( &program );
// Init the environment each platform wants
KIPLATFORM::ENV::Init();
}

View File

@ -94,28 +94,6 @@ KIFACE_BASE& Kiface()
}
static PGM_KICAD program;
PGM_BASE& Pgm()
{
return program;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return &program;
}
PGM_KICAD& PgmTop()
{
return program;
}
struct COMMAND_ENTRY
{
CLI::COMMAND* handler;
@ -463,8 +441,9 @@ void PGM_KICAD::Destroy()
}
KIWAY Kiway( &Pgm(), KFCTL_CPP_PROJECT_SUITE | KFCTL_CLI );
KIWAY Kiway( KFCTL_CPP_PROJECT_SUITE | KFCTL_CLI );
static PGM_KICAD program;
/**
* Not publicly visible because most of the action is in #PGM_KICAD these days.
@ -473,6 +452,8 @@ struct APP_KICAD_CLI : public wxAppConsole
{
APP_KICAD_CLI() : wxAppConsole()
{
SetPgm( &program );
// Init the environment each platform wants
KIPLATFORM::ENV::Init();
}

View File

@ -74,14 +74,9 @@ endif()
# a very small program launcher for pl_editor_kiface
add_executable( pl_editor WIN32 MACOSX_BUNDLE
${CMAKE_SOURCE_DIR}/common/single_top.cpp
${CMAKE_SOURCE_DIR}/common/pgm_base.cpp
${PL_EDITOR_RESOURCES}
)
if( KICAD_USE_SENTRY )
set_property(SOURCE ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}")
endif()
set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_PL_EDITOR;PGM_DATA_FILE_EXT=\"kicad_wks\";BUILD_KIWAY_DLL"
)
@ -91,6 +86,7 @@ target_link_libraries( pl_editor
gal
common
core
kicommon
${wxWidgets_LIBRARIES}
)

View File

@ -124,9 +124,6 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
using namespace PGE;
static PGM_BASE* process;
KIFACE_BASE& Kiface() { return kiface; }
@ -134,24 +131,9 @@ KIFACE_BASE& Kiface() { return kiface; }
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
return &kiface;
}
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return process;
}
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
{
InitSettings( new PL_EDITOR_SETTINGS );

View File

@ -88,14 +88,9 @@ endif()
add_executable( pcb_calculator WIN32 MACOSX_BUNDLE
${CMAKE_SOURCE_DIR}/common/single_top.cpp
${CMAKE_SOURCE_DIR}/common/pgm_base.cpp
${PCB_CALCULATOR_RESOURCES}
)
if( KICAD_USE_SENTRY )
set_property(SOURCE ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp APPEND PROPERTY COMPILE_DEFINITIONS KICAD_SENTRY_DSN="${KICAD_SENTRY_DSN}")
endif()
set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_CALC;BUILD_KIWAY_DLL"
)
@ -103,6 +98,7 @@ target_link_libraries( pcb_calculator
#singletop # replaces common, giving us restrictive control and link warnings.
# There's way too much crap coming in from common yet.
common
kicommon
${wxWidgets_LIBRARIES}
)

View File

@ -72,8 +72,6 @@ static struct IFACE : public KIFACE_BASE
using namespace PCBCALC;
static PGM_BASE* process;
KIFACE_BASE& Kiface() { return kiface; }
@ -82,24 +80,10 @@ KIFACE_BASE& Kiface() { return kiface; }
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
return &kiface;
}
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return process;
}
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
{
InitSettings( new PCB_CALCULATOR_SETTINGS );

View File

@ -351,9 +351,6 @@ private:
using namespace PCB;
static PGM_BASE* process;
KIFACE_BASE& Kiface() { return kiface; }
@ -361,27 +358,10 @@ KIFACE_BASE& Kiface() { return kiface; }
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
{
process = aProgram;
return &kiface;
}
#if defined( BUILD_KIWAY_DLL )
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
PGM_BASE* PgmOrNull()
{
return process;
}
#endif
/// The global footprint library table. This is not dynamically allocated because
/// in a multiple project environment we must keep its address constant (since it is
/// the fallback table for multiple projects).

View File

@ -30,22 +30,6 @@
#include <mock_pgm_base.h>
PGM_BASE& Pgm()
{
static MOCK_PGM_BASE program;
return program;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from
// a python script or something else.
// Therefore here return always nullptr
PGM_BASE* PgmOrNull()
{
return nullptr;
}
KIFACE_BASE& Kiface()
{
static MOCK_KIFACE_BASE kiface;

View File

@ -89,7 +89,7 @@ static struct IFACE : public KIFACE_BASE
kiface( "pcb_test_frame", KIWAY::FACE_PCB );
KIWAY Kiway( &Pgm(), KFCTL_STANDALONE );
KIWAY Kiway( KFCTL_STANDALONE );
static struct PGM_TEST_FRAME : public PGM_BASE
@ -129,20 +129,6 @@ static struct PGM_TEST_FRAME : public PGM_BASE
program;
PGM_BASE& Pgm()
{
return program;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face
// is run from a python script, mot from a Kicad application
PGM_BASE* PgmOrNull()
{
return &program;
}
KIFACE_BASE& Kiface()
{
return kiface;
@ -156,7 +142,9 @@ KIFACE_BASE& Kiface()
struct APP_TEST : public wxApp
{
APP_TEST()
{}
{
SetPgm( &program );
}
bool OnInit() override
{

View File

@ -25,6 +25,7 @@
* Main file for the libcommon tests to be compiled
*/
#include <boost/test/unit_test.hpp>
#include <mock_pgm_base.h>
#include <wx/image.h>
#include <wx/init.h>
@ -32,6 +33,7 @@
bool init_unit_test()
{
SetPgm( new MOCK_PGM_BASE() );
boost::unit_test::framework::master_test_suite().p_name.value = "Common library module tests";
bool ok = wxInitialize();

View File

@ -35,6 +35,7 @@
#include <symbol_editor/symbol_editor_settings.h>
#include <wx/app.h>
#include <wx/init.h>
#include <mock_pgm_base.h>
#include <qa_utils/wx_utils/wx_assert.h>
@ -52,6 +53,7 @@ void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc,
bool init_unit_test()
{
SetPgm( new MOCK_PGM_BASE() );
KIPLATFORM::APP::Init();
boost::unit_test::framework::master_test_suite().p_name.value = "Common Eeschema module tests";

View File

@ -51,6 +51,7 @@ target_compile_definitions( qa_gerbview
target_include_directories( qa_gerbview PRIVATE
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/qa/mocks/include
)
# Anytime we link to the kiface_objects, we have to add a dependency on the last object

View File

@ -26,12 +26,14 @@
*/
#include <boost/test/unit_test.hpp>
#include <kiplatform/app.h>
#include <mock_pgm_base.h>
#include <wx/init.h>
bool init_unit_test()
{
SetPgm( new MOCK_PGM_BASE() );
KIPLATFORM::APP::Init();
boost::unit_test::framework::master_test_suite().p_name.value = "Gerbview module tests";
return wxInitialize();

View File

@ -104,6 +104,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/polygon
${CMAKE_SOURCE_DIR}/common/geometry
${CMAKE_SOURCE_DIR}/qa/qa_utils
${CMAKE_SOURCE_DIR}/qa/mocks/include
${INC_AFTER}
)

View File

@ -26,6 +26,7 @@
*/
#include <boost/test/unit_test.hpp>
#include <kiplatform/app.h>
#include <mock_pgm_base.h>
#include <wx/image.h>
#include <wx/init.h>
@ -33,6 +34,7 @@
bool init_unit_test()
{
SetPgm( new MOCK_PGM_BASE() );
KIPLATFORM::APP::Init();
boost::unit_test::framework::master_test_suite().p_name.value = "Pcbnew module tests";

View File

@ -35,6 +35,7 @@
#include <symbol_editor/symbol_editor_settings.h>
#include <wx/app.h>
#include <wx/init.h>
#include <mock_pgm_base.h>
#include <qa_utils/wx_utils/wx_assert.h>
@ -52,6 +53,7 @@ void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc,
bool init_unit_test()
{
SetPgm( new MOCK_PGM_BASE() );
KIPLATFORM::APP::Init();
boost::unit_test::framework::master_test_suite().p_name.value = "Common spice integration tests";

View File

@ -1,6 +1,5 @@
set( KIPYTHON_SRCS
kipython_settings.cpp
python_scripting.cpp
)
add_library( scripting STATIC
@ -12,6 +11,7 @@ target_link_libraries( scripting
${PYTHON_LIBRARIES}
Boost::headers
common
kicommon
)
target_include_directories( scripting PUBLIC

View File

@ -78,8 +78,6 @@ static struct IFACE : public KIFACE_BASE
using namespace KIPYTHON;
static PGM_BASE* process;
KIFACE_BASE& Kiface()
{
return kiface;
@ -90,25 +88,10 @@ KIFACE_BASE& Kiface()
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
return &kiface;
}
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from
// a python script or something else.
PGM_BASE* PgmOrNull()
{
return process;
}
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
{
InitSettings( new KIPYTHON_SETTINGS );

View File

@ -36,10 +36,7 @@
#include <cstring>
#include <string>
#include <eda_base_frame.h>
#include <env_vars.h>
#include <gal/color4d.h>
#include <gestfich.h>
#include <trace_helpers.h>
#include <string_utils.h>
#include <macros.h>

View File

@ -45,7 +45,9 @@
#include <wx/string.h>
#include <wx/arrstr.h>
class SCRIPTING
#include <kicommon.h>
class KICOMMON_API SCRIPTING
{
public:
SCRIPTING();
@ -82,14 +84,15 @@ private:
* @param aVar is the variable to set
* @param aValue is the value to give it
*/
void UpdatePythonEnvVar( const wxString& aVar, const wxString& aValue );
KICOMMON_API void UpdatePythonEnvVar( const wxString& aVar, const wxString& aValue );
void RedirectStdio();
wxWindow* CreatePythonShellWindow( wxWindow* parent, const wxString& aFramenameId );
bool InitPythonScripting( const char* aStockScriptingPath, const char* aUserScriptingPath );
bool IsWxPythonLoaded();
KICOMMON_API void RedirectStdio();
KICOMMON_API wxWindow* CreatePythonShellWindow( wxWindow* parent, const wxString& aFramenameId );
KICOMMON_API bool InitPythonScripting( const char* aStockScriptingPath,
const char* aUserScriptingPath );
KICOMMON_API bool IsWxPythonLoaded();
class PyLOCK
class KICOMMON_API PyLOCK
{
PyGILState_STATE gil_state;
public:
@ -97,8 +100,8 @@ public:
~PyLOCK() { PyGILState_Release( gil_state ); }
};
wxString PyStringToWx( PyObject* str );
wxArrayString PyArrayStringToWx( PyObject* arr );
wxString PyErrStringWithTraceback();
KICOMMON_API wxString PyStringToWx( PyObject* str );
KICOMMON_API wxArrayString PyArrayStringToWx( PyObject* arr );
KICOMMON_API wxString PyErrStringWithTraceback();
#endif // __PYTHON_SCRIPTING_H