wlmaker
Loading...
Searching...
No Matches
Classes | Functions | Variables
util.c File Reference
#include "util.h"
#include <libbase/libbase.h>
#include <stddef.h>
#include <wayland-util.h>
Include dependency graph for util.c:

Classes

struct  test_wl_list_it_t
 

Functions

static void _wlmtk_util_test_listener_handler (struct wl_listener *listener_ptr, void *data_ptr)
 
bool wlmtk_util_wl_list_for_each (struct wl_list *list_ptr, bool(*func)(struct wl_list *link_ptr, void *ud_ptr), void *ud_ptr)
 
void wlmtk_util_connect_listener_signal (struct wl_signal *signal_ptr, struct wl_listener *listener_ptr, void(*notifier_func)(struct wl_listener *, void *))
 
void wlmtk_util_disconnect_listener (struct wl_listener *listener_ptr)
 
void wlmtk_util_connect_test_listener (struct wl_signal *signal_ptr, wlmtk_util_test_listener_t *test_listener_ptr)
 
void wlmtk_util_disconnect_test_listener (wlmtk_util_test_listener_t *test_listener_ptr)
 
void wlmtk_util_clear_test_listener (wlmtk_util_test_listener_t *test_listener_ptr)
 
static void test_wl_list_for_each (bs_test_t *test_ptr)
 
static void test_listener (bs_test_t *test_ptr)
 
static bool _test_wl_list_callback (struct wl_list *link_ptr, void *ud_ptr)
 

Variables

const bs_test_case_t wlmtk_util_test_cases []
 

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ _test_wl_list_callback()

static bool _test_wl_list_callback ( struct wl_list *  link_ptr,
void *  ud_ptr 
)
static

Callback for testing wlmtk_util_wl_list_for_each.

◆ _wlmtk_util_test_listener_handler()

void _wlmtk_util_test_listener_handler ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handler to record a signal call into the wlmtk_util_test_listener_t.

Parameters
listener_ptr
data_ptr

◆ test_listener()

static void test_listener ( bs_test_t *  test_ptr)
static

A test to verify listener handlers are called in order of subscription.

◆ test_wl_list_for_each()

static void test_wl_list_for_each ( bs_test_t *  test_ptr)
static

◆ wlmtk_util_clear_test_listener()

void wlmtk_util_clear_test_listener ( wlmtk_util_test_listener_t test_listener_ptr)

◆ wlmtk_util_connect_listener_signal()

void wlmtk_util_connect_listener_signal ( struct wl_signal *  signal_ptr,
struct wl_listener *  listener_ptr,
void(*)(struct wl_listener *, void *)  notifier_func 
)

Sets |notifier_func| as the notifier for |listener_ptr|, and registers it with |signal_ptr|.

This is merely a convenience helper for the usual two-liner of boilerplate. To disconnect from the listener signal, call wl_list_remove on a reference to the link element of *listener_ptr.

Parameters
signal_ptr
listener_ptr
notifier_func

◆ wlmtk_util_connect_test_listener()

void wlmtk_util_connect_test_listener ( struct wl_signal *  signal_ptr,
wlmtk_util_test_listener_t test_listener_ptr 
)

Connects test listener to signal.

See also
wlmtk_util_connect_listener_signal.
Parameters
signal_ptr
test_listener_ptr

◆ wlmtk_util_disconnect_listener()

void wlmtk_util_disconnect_listener ( struct wl_listener *  listener_ptr)

Disconnects a listener from the signal.

Does that in a safe way: Will only disconnect, if the link is set.

Parameters
listener_ptr

◆ wlmtk_util_disconnect_test_listener()

void wlmtk_util_disconnect_test_listener ( wlmtk_util_test_listener_t test_listener_ptr)

Disconnects a test listener.

Parameters
test_listener_ptr

◆ wlmtk_util_wl_list_for_each()

bool wlmtk_util_wl_list_for_each ( struct wl_list *  list_ptr,
bool(*)(struct wl_list *link_ptr, void *ud_ptr)  func,
void *  ud_ptr 
)

Iterates over list_ptr and calls func() for each element.

Permits removal of link_ptr in func(). Similar to wl_list_for_each_safe, but not as a macro, and returning true if all invocations succeeded.

Returns
true if none of the func() invocations returned false.

Variable Documentation

◆ wlmtk_util_test_cases

const bs_test_case_t wlmtk_util_test_cases[]
Initial value:
= {
{ 1, "wl_list_for_each", test_wl_list_for_each },
{ 1, "listener", test_listener },
{ 0, NULL, NULL }
}
static void test_listener(bs_test_t *test_ptr)
Definition util.c:203
static void test_wl_list_for_each(bs_test_t *test_ptr)
Definition util.c:150

Unit test cases.