libnm: move optimized NM_IS_{SIMPLE,}CONNECTION() to internal header

We already redefine those checks to optimize for NMSimpleConnection.
Which, in particular when libnm-core is used by the daemon, is the only
implementation of the NMConnection interface.

Move those to the private header file. No need to keep it private to
"nm-connection.c".
This commit is contained in:
Thomas Haller 2022-09-27 13:04:47 +02:00
parent 28cb407056
commit d75bfd3a3d
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 26 additions and 27 deletions

View file

@ -54,33 +54,6 @@ static gboolean _nm_connection_clear_settings(NMConnection *connection, NMConnec
/*****************************************************************************/
#undef NM_IS_SIMPLE_CONNECTION
#define NM_IS_SIMPLE_CONNECTION(self) \
({ \
gconstpointer _self1 = (self); \
gboolean _result; \
\
_result = \
(_self1 \
&& (((GTypeInstance *) _self1)->g_class == _nm_simple_connection_class_instance)); \
\
nm_assert(_result == G_TYPE_CHECK_INSTANCE_TYPE(_self1, NM_TYPE_SIMPLE_CONNECTION)); \
\
_result; \
})
#undef NM_IS_CONNECTION
#define NM_IS_CONNECTION(self) \
({ \
gconstpointer _self0 = (self); \
\
(_self0 \
&& (NM_IS_SIMPLE_CONNECTION(_self0) \
|| G_TYPE_CHECK_INSTANCE_TYPE(_self0, NM_TYPE_CONNECTION))); \
})
/*****************************************************************************/
void
_nm_connection_private_clear(NMConnectionPrivate *priv)
{

View file

@ -13,6 +13,7 @@
#include "nm-setting.h"
#include "nm-setting-bridge.h"
#include "nm-connection.h"
#include "nm-simple-connection.h"
#include "nm-core-enum-types.h"
#include "libnm-core-intern/nm-core-internal.h"
@ -31,6 +32,31 @@ typedef struct {
extern GTypeClass *_nm_simple_connection_class_instance;
extern int _nm_simple_connection_private_offset;
#undef NM_IS_SIMPLE_CONNECTION
#define NM_IS_SIMPLE_CONNECTION(self) \
({ \
gconstpointer _self1 = (self); \
gboolean _result; \
\
_result = \
(_self1 \
&& (((GTypeInstance *) _self1)->g_class == _nm_simple_connection_class_instance)); \
\
nm_assert(_result == G_TYPE_CHECK_INSTANCE_TYPE(_self1, NM_TYPE_SIMPLE_CONNECTION)); \
\
_result; \
})
#undef NM_IS_CONNECTION
#define NM_IS_CONNECTION(self) \
({ \
gconstpointer _self0 = (self); \
\
(_self0 \
&& (NM_IS_SIMPLE_CONNECTION(_self0) \
|| G_TYPE_CHECK_INSTANCE_TYPE(_self0, NM_TYPE_CONNECTION))); \
})
#define _NM_SIMPLE_CONNECTION_GET_CONNECTION_PRIVATE(connection) \
({ \
gpointer _connection_1 = (connection); \