iterator: make private stuff public, cleanup private.h further

There is no good reason to keep them private
This commit is contained in:
George Kiagiadakis
2020-11-15 20:23:48 +02:00
parent 91472c51e9
commit 37134df7c8
13 changed files with 53 additions and 29 deletions

View File

@@ -16,7 +16,7 @@
#include "configuration.h"
#include "debug.h"
#include "private.h"
#include "private/registry.h"
struct _WpConfiguration
{

View File

@@ -28,7 +28,7 @@
#include "core.h"
#include "wp.h"
#include "private.h"
#include "private/registry.h"
#include <pipewire/pipewire.h>

View File

@@ -13,6 +13,7 @@
#include "debug.h"
#include "spa-pod.h"
#include "proxy.h"
#include "private.h"
#include <pipewire/pipewire.h>
#include <spa/support/log.h>

View File

@@ -8,8 +8,8 @@
#define G_LOG_DOMAIN "wp-iterator"
#include "private.h"
#include "iterator.h"
#include <spa/utils/defs.h>
struct _WpIterator
{
@@ -58,6 +58,19 @@ wp_iterator_default_foreach (WpIterator *self, WpIteratorForeachFunc func,
return wp_iterator_fold (self, foreach_fold_func, NULL, &d);
}
/**
* wp_iterator_new:
* @methods: method implementations for the new iterator
* @user_size: size of the user_data structure to be allocated
*
* Constructs an iterator that uses the provided @methods to implement its API.
* The WpIterator structure is internally allocated with @user_size additional
* space at the end. A pointer to this space can be retrieved with
* wp_iterator_get_user_data() and is available for implementation-specific
* storage.
*
* Returns: (transfer full): a new custom iterator
*/
WpIterator *
wp_iterator_new (const WpIteratorMethods *methods, size_t user_size)
{
@@ -73,6 +86,14 @@ wp_iterator_new (const WpIteratorMethods *methods, size_t user_size)
return self;
}
/**
* wp_iterator_get_user_data:
* @self: an iterator object
*
* Note: this only for use by implementations of WpIterator
*
* Returns: a pointer to the implementation-specific storage area
*/
gpointer
wp_iterator_get_user_data (WpIterator *self)
{

View File

@@ -46,6 +46,18 @@ WP_API
GType wp_iterator_get_type (void);
typedef struct _WpIterator WpIterator;
typedef struct _WpIteratorMethods WpIteratorMethods;
struct _WpIteratorMethods
{
void (*reset) (WpIterator *self);
gboolean (*next) (WpIterator *self, GValue *item);
gboolean (*fold) (WpIterator *self, WpIteratorFoldFunc func,
GValue *ret, gpointer data);
gboolean (*foreach) (WpIterator *self, WpIteratorForeachFunc func,
gpointer data);
void (*finalize) (WpIterator *self);
};
/* ref count */
@@ -76,6 +88,15 @@ gboolean wp_iterator_foreach (WpIterator *self, WpIteratorForeachFunc func,
WP_API
WpIterator * wp_iterator_new_ptr_array (GPtrArray * items, GType item_type);
WP_API
WpIterator * wp_iterator_new (const WpIteratorMethods * methods,
size_t user_size);
/* private */
WP_API
gpointer wp_iterator_get_user_data (WpIterator * self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WpIterator, wp_iterator_unref)
G_END_DECLS

View File

@@ -18,7 +18,6 @@
#include "debug.h"
#include "error.h"
#include "wpenums.h"
#include "private.h"
#include <pipewire/pipewire.h>
#include <pipewire/extensions/metadata.h>

View File

@@ -44,7 +44,7 @@
#include "module.h"
#include "debug.h"
#include "error.h"
#include "private.h"
#include "private/registry.h"
#include <gmodule.h>
#define WP_MODULE_INIT_SYMBOL "wireplumber__module_init"

View File

@@ -18,7 +18,8 @@
#include "proxy-interfaces.h"
#include "debug.h"
#include "error.h"
#include "private.h"
#include <pipewire/pipewire.h>
struct constraint
{

View File

@@ -41,7 +41,8 @@
#include "object-manager.h"
#include "debug.h"
#include "private.h"
#include "private/registry.h"
#include <pipewire/pipewire.h>
/* WpObjectManager */

View File

@@ -14,7 +14,7 @@
#define G_LOG_DOMAIN "wp-plugin"
#include "plugin.h"
#include "private.h"
#include "private/registry.h"
enum {
PROP_0,

View File

@@ -14,9 +14,7 @@
#include "props.h"
#include "proxy.h"
#include "session-item.h"
#include "iterator.h"
#include "spa-type.h"
#include "private/registry.h"
#include <stdint.h>
#include <pipewire/pipewire.h>
@@ -31,23 +29,6 @@ struct spa_pod_builder;
void wp_props_handle_proxy_param_event (WpProps * self, guint32 id,
WpSpaPod * pod);
/* iterator */
struct _WpIteratorMethods {
void (*reset) (WpIterator *self);
gboolean (*next) (WpIterator *self, GValue *item);
gboolean (*fold) (WpIterator *self, WpIteratorFoldFunc func,
GValue *ret, gpointer data);
gboolean (*foreach) (WpIterator *self, WpIteratorForeachFunc func,
gpointer data);
void (*finalize) (WpIterator *self);
};
typedef struct _WpIteratorMethods WpIteratorMethods;
WpIterator * wp_iterator_new (const WpIteratorMethods *methods,
size_t user_size);
gpointer wp_iterator_get_user_data (WpIterator *self);
/* spa pod */
typedef struct _WpSpaPod WpSpaPod;

View File

@@ -40,7 +40,6 @@
#define G_LOG_DOMAIN "wp-properties"
#include "properties.h"
#include "private.h"
#include <errno.h>
#include <pipewire/properties.h>

View File

@@ -14,7 +14,7 @@
#define G_LOG_DOMAIN "wp-si-factory"
#include "si-factory.h"
#include "private.h"
#include "private/registry.h"
enum {
PROP_0,