mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 00:21:31 +00:00
API: Move trace macro to utils
This commit is contained in:
parent
3129e072c4
commit
523fcc039f
@ -201,6 +201,7 @@ if( KICAD_IPC_API )
|
||||
api/api_plugin.cpp
|
||||
api/api_plugin_manager.cpp
|
||||
api/api_server.cpp
|
||||
api/api_utils.cpp
|
||||
|
||||
../scripting/python_manager.cpp
|
||||
)
|
||||
@ -666,7 +667,6 @@ set( COMMON_SRCS
|
||||
http_lib/http_lib_settings.cpp
|
||||
|
||||
api/api_enums.cpp
|
||||
api/api_utils.cpp
|
||||
)
|
||||
|
||||
if( KICAD_IPC_API )
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <api/api_plugin.h>
|
||||
#include <api/api_plugin_manager.h>
|
||||
#include <api/api_utils.h>
|
||||
#include <json_conversions.h>
|
||||
|
||||
|
||||
|
@ -25,14 +25,13 @@
|
||||
|
||||
#include <api/api_plugin_manager.h>
|
||||
#include <api/api_server.h>
|
||||
#include <api/api_utils.h>
|
||||
#include <paths.h>
|
||||
#include <pgm_base.h>
|
||||
#include <python_manager.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <settings/common_settings.h>
|
||||
|
||||
const wxChar* const traceApi = wxT( "KICAD_API" );
|
||||
|
||||
|
||||
wxDEFINE_EVENT( EDA_EVT_PLUGIN_MANAGER_JOB_FINISHED, wxCommandEvent );
|
||||
wxDEFINE_EVENT( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED, wxCommandEvent );
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <advanced_config.h>
|
||||
#include <api/api_handler.h>
|
||||
#include <api/api_plugin_manager.h> // traceApi
|
||||
#include <api/api_utils.h> // traceApi
|
||||
#include <api/api_server.h>
|
||||
#include <kiid.h>
|
||||
#include <kinng.h>
|
||||
|
@ -21,11 +21,15 @@
|
||||
#include <magic_enum.hpp>
|
||||
#include <api/api_utils.h>
|
||||
#include <geometry/shape_poly_set.h>
|
||||
#include <wx/log.h>
|
||||
|
||||
const wxChar* const traceApi = wxT( "KICAD_API" );
|
||||
|
||||
|
||||
namespace kiapi::common
|
||||
{
|
||||
|
||||
std::optional<KICAD_T> TypeNameFromAny( const google::protobuf::Any& aMessage )
|
||||
KICOMMON_API std::optional<KICAD_T> TypeNameFromAny( const google::protobuf::Any& aMessage )
|
||||
{
|
||||
static const std::map<std::string, KICAD_T> s_types = {
|
||||
{ "type.googleapis.com/kiapi.board.types.Track", PCB_TRACE_T },
|
||||
@ -48,17 +52,20 @@ std::optional<KICAD_T> TypeNameFromAny( const google::protobuf::Any& aMessage )
|
||||
if( it != s_types.end() )
|
||||
return it->second;
|
||||
|
||||
wxLogTrace( traceApi, wxString::Format( wxS( "Any message type %s is not known" ),
|
||||
aMessage.type_url() ) );
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
LIB_ID LibIdFromProto( const types::LibraryIdentifier& aId )
|
||||
KICOMMON_API LIB_ID LibIdFromProto( const types::LibraryIdentifier& aId )
|
||||
{
|
||||
return LIB_ID( aId.library_nickname(), aId.entry_name() );
|
||||
}
|
||||
|
||||
|
||||
types::LibraryIdentifier LibIdToProto( const LIB_ID& aId )
|
||||
KICOMMON_API types::LibraryIdentifier LibIdToProto( const LIB_ID& aId )
|
||||
{
|
||||
types::LibraryIdentifier msg;
|
||||
msg.set_library_nickname( aId.GetLibNickname() );
|
||||
@ -67,20 +74,20 @@ types::LibraryIdentifier LibIdToProto( const LIB_ID& aId )
|
||||
}
|
||||
|
||||
|
||||
void PackVector2( types::Vector2& aOutput, const VECTOR2I& aInput )
|
||||
KICOMMON_API void PackVector2( types::Vector2& aOutput, const VECTOR2I& aInput )
|
||||
{
|
||||
aOutput.set_x_nm( aInput.x );
|
||||
aOutput.set_y_nm( aInput.y );
|
||||
}
|
||||
|
||||
|
||||
VECTOR2I UnpackVector2( const types::Vector2& aInput )
|
||||
KICOMMON_API VECTOR2I UnpackVector2( const types::Vector2& aInput )
|
||||
{
|
||||
return VECTOR2I( aInput.x_nm(), aInput.y_nm() );
|
||||
}
|
||||
|
||||
|
||||
void PackVector3D( types::Vector3D& aOutput, const VECTOR3D& aInput )
|
||||
KICOMMON_API void PackVector3D( types::Vector3D& aOutput, const VECTOR3D& aInput )
|
||||
{
|
||||
aOutput.set_x_nm( aInput.x );
|
||||
aOutput.set_y_nm( aInput.y );
|
||||
@ -88,33 +95,33 @@ void PackVector3D( types::Vector3D& aOutput, const VECTOR3D& aInput )
|
||||
}
|
||||
|
||||
|
||||
VECTOR3D UnpackVector3D( const types::Vector3D& aInput )
|
||||
KICOMMON_API VECTOR3D UnpackVector3D( const types::Vector3D& aInput )
|
||||
{
|
||||
return VECTOR3D( aInput.x_nm(), aInput.y_nm(), aInput.z_nm() );
|
||||
}
|
||||
|
||||
|
||||
void PackBox2( types::Box2& aOutput, const BOX2I& aInput )
|
||||
KICOMMON_API void PackBox2( types::Box2& aOutput, const BOX2I& aInput )
|
||||
{
|
||||
PackVector2( *aOutput.mutable_position(), aInput.GetOrigin() );
|
||||
PackVector2( *aOutput.mutable_size(), aInput.GetSize() );
|
||||
}
|
||||
|
||||
|
||||
BOX2I UnpackBox2( const types::Box2& aInput )
|
||||
KICOMMON_API BOX2I UnpackBox2( const types::Box2& aInput )
|
||||
{
|
||||
return BOX2I( UnpackVector2( aInput.position() ), UnpackVector2( aInput.size() ) );
|
||||
}
|
||||
|
||||
|
||||
void PackPolyLine( kiapi::common::types::PolyLine& aOutput, const SHAPE_LINE_CHAIN& aSlc )
|
||||
KICOMMON_API void PackPolyLine( types::PolyLine& aOutput, const SHAPE_LINE_CHAIN& aSlc )
|
||||
{
|
||||
for( int vertex = 0; vertex < aSlc.PointCount(); vertex = aSlc.NextShape( vertex ) )
|
||||
{
|
||||
if( vertex < 0 )
|
||||
break;
|
||||
|
||||
kiapi::common::types::PolyLineNode* node = aOutput.mutable_nodes()->Add();
|
||||
types::PolyLineNode* node = aOutput.mutable_nodes()->Add();
|
||||
|
||||
if( aSlc.IsPtOnArc( vertex ) )
|
||||
{
|
||||
@ -137,11 +144,11 @@ void PackPolyLine( kiapi::common::types::PolyLine& aOutput, const SHAPE_LINE_CHA
|
||||
}
|
||||
|
||||
|
||||
SHAPE_LINE_CHAIN UnpackPolyLine( const kiapi::common::types::PolyLine& aInput )
|
||||
KICOMMON_API SHAPE_LINE_CHAIN UnpackPolyLine( const types::PolyLine& aInput )
|
||||
{
|
||||
SHAPE_LINE_CHAIN slc;
|
||||
|
||||
for( const kiapi::common::types::PolyLineNode& node : aInput.nodes() )
|
||||
for( const types::PolyLineNode& node : aInput.nodes() )
|
||||
{
|
||||
if( node.has_point() )
|
||||
{
|
||||
@ -162,7 +169,7 @@ SHAPE_LINE_CHAIN UnpackPolyLine( const kiapi::common::types::PolyLine& aInput )
|
||||
}
|
||||
|
||||
|
||||
void PackPolySet( types::PolySet& aOutput, const SHAPE_POLY_SET& aInput )
|
||||
KICOMMON_API void PackPolySet( types::PolySet& aOutput, const SHAPE_POLY_SET& aInput )
|
||||
{
|
||||
for( int idx = 0; idx < aInput.OutlineCount(); ++idx )
|
||||
{
|
||||
@ -186,7 +193,7 @@ void PackPolySet( types::PolySet& aOutput, const SHAPE_POLY_SET& aInput )
|
||||
}
|
||||
|
||||
|
||||
SHAPE_POLY_SET UnpackPolySet( const types::PolySet& aInput )
|
||||
KICOMMON_API SHAPE_POLY_SET UnpackPolySet( const types::PolySet& aInput )
|
||||
{
|
||||
SHAPE_POLY_SET sps;
|
||||
|
||||
|
@ -106,6 +106,7 @@
|
||||
|
||||
#ifdef KICAD_IPC_API
|
||||
#include <api/api_plugin_manager.h>
|
||||
#include <api/api_utils.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -27,15 +27,6 @@
|
||||
#include <api/api_plugin.h>
|
||||
#include <kicommon.h>
|
||||
|
||||
/**
|
||||
* Flag to enable debug output related to the API plugin system
|
||||
*
|
||||
* Use "KICAD_API" to enable.
|
||||
*
|
||||
* @ingroup trace_env_vars
|
||||
*/
|
||||
extern const KICOMMON_API wxChar* const traceApi;
|
||||
|
||||
/// Internal event used for handling async tasks
|
||||
wxDECLARE_EVENT( EDA_EVT_PLUGIN_MANAGER_JOB_FINISHED, wxCommandEvent );
|
||||
|
||||
|
@ -34,34 +34,43 @@
|
||||
|
||||
class SHAPE_LINE_CHAIN;
|
||||
|
||||
/**
|
||||
* Flag to enable debug output related to the IPC API and its plugin system
|
||||
*
|
||||
* Use "KICAD_API" to enable.
|
||||
*
|
||||
* @ingroup trace_env_vars
|
||||
*/
|
||||
extern const KICOMMON_API wxChar* const traceApi;
|
||||
|
||||
namespace kiapi::common
|
||||
{
|
||||
|
||||
std::optional<KICAD_T> TypeNameFromAny( const google::protobuf::Any& aMessage );
|
||||
KICOMMON_API std::optional<KICAD_T> TypeNameFromAny( const google::protobuf::Any& aMessage );
|
||||
|
||||
LIB_ID LibIdFromProto( const types::LibraryIdentifier& aId );
|
||||
KICOMMON_API LIB_ID LibIdFromProto( const types::LibraryIdentifier& aId );
|
||||
|
||||
types::LibraryIdentifier LibIdToProto( const LIB_ID& aId );
|
||||
KICOMMON_API types::LibraryIdentifier LibIdToProto( const LIB_ID& aId );
|
||||
|
||||
void PackVector2( types::Vector2& aOutput, const VECTOR2I& aInput );
|
||||
KICOMMON_API void PackVector2( types::Vector2& aOutput, const VECTOR2I& aInput );
|
||||
|
||||
VECTOR2I UnpackVector2( const types::Vector2& aInput );
|
||||
KICOMMON_API VECTOR2I UnpackVector2( const types::Vector2& aInput );
|
||||
|
||||
void PackVector3D( types::Vector3D& aOutput, const VECTOR3D& aInput );
|
||||
KICOMMON_API void PackVector3D( types::Vector3D& aOutput, const VECTOR3D& aInput );
|
||||
|
||||
VECTOR3D UnpackVector3D( const types::Vector3D& aInput );
|
||||
KICOMMON_API VECTOR3D UnpackVector3D( const types::Vector3D& aInput );
|
||||
|
||||
void PackBox2( types::Box2& aOutput, const BOX2I& aInput );
|
||||
KICOMMON_API void PackBox2( types::Box2& aOutput, const BOX2I& aInput );
|
||||
|
||||
BOX2I UnpackBox2( const types::Box2& aInput );
|
||||
KICOMMON_API BOX2I UnpackBox2( const types::Box2& aInput );
|
||||
|
||||
void PackPolyLine( kiapi::common::types::PolyLine& aOutput, const SHAPE_LINE_CHAIN& aSlc );
|
||||
KICOMMON_API void PackPolyLine( types::PolyLine& aOutput, const SHAPE_LINE_CHAIN& aSlc );
|
||||
|
||||
SHAPE_LINE_CHAIN UnpackPolyLine( const kiapi::common::types::PolyLine& aInput );
|
||||
KICOMMON_API SHAPE_LINE_CHAIN UnpackPolyLine( const types::PolyLine& aInput );
|
||||
|
||||
void PackPolySet( kiapi::common::types::PolySet& aOutput, const SHAPE_POLY_SET& aInput );
|
||||
KICOMMON_API void PackPolySet( types::PolySet& aOutput, const SHAPE_POLY_SET& aInput );
|
||||
|
||||
SHAPE_POLY_SET UnpackPolySet( const kiapi::common::types::PolySet& aInput );
|
||||
KICOMMON_API SHAPE_POLY_SET UnpackPolySet( const types::PolySet& aInput );
|
||||
|
||||
} // namespace kiapi::common
|
||||
|
||||
|
@ -63,6 +63,7 @@
|
||||
#include <api/api_enums.h>
|
||||
#include <api/api_utils.h>
|
||||
#include <api/api_pcb_utils.h>
|
||||
#include <wx/log.h>
|
||||
|
||||
|
||||
FOOTPRINT::FOOTPRINT( BOARD* parent ) :
|
||||
@ -533,6 +534,9 @@ bool FOOTPRINT::Deserialize( const google::protobuf::Any &aContainer )
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogTrace( traceApi, wxString::Format( wxS( "Attempting to unpack unknown type %s "
|
||||
"from footprint message, skipping" ),
|
||||
itemMsg.type_url() ) );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -121,6 +121,7 @@
|
||||
#include <api/api_server.h>
|
||||
#include <api/api_handler_pcb.h>
|
||||
#include <api/api_handler_common.h>
|
||||
#include <api/api_utils.h>
|
||||
#endif
|
||||
|
||||
#include <action_plugin.h>
|
||||
|
Loading…
Reference in New Issue
Block a user