Commit b513e036 authored by Ronan's avatar Ronan

feat(object-tester): add comments to describe signal declaration

parent 114c8513
......@@ -66,7 +66,7 @@ namespace Private {
template<int... Index, typename... SignalArgs, typename Func>
struct FunctionCall<IndexesList<Index...>, List<SignalArgs...>, Func> {
static void call (Func &function, void **args) {
function((*reinterpret_cast<typename std::remove_reference<SignalArgs>::type *>(args[Index])) ...);
function((*reinterpret_cast<typename std::remove_reference<SignalArgs>::type *>(args[Index]))...);
}
};
......
......@@ -68,16 +68,19 @@
const std::lock_guard<Object::Lock> synchronized(const_cast<Object::Lock &>(getLock()));
// Declare one Smart Object with Signals.
#define L_OBJECT(NAME) \
#define L_OBJECT(CLASS) \
private: \
typedef NAME lType; \
static constexpr const char *lName = #NAME; \
typedef CLASS lType; \
static constexpr const char *lName = #CLASS; \
friend constexpr std::tuple<> lMetaSignals (LinphonePrivate::Private::MetaObjectCounter<0>, lType **) { return {}; } \
public: \
static constexpr const char *getName () { \
virtual const char *getName () { \
return lName; \
}
// Declare Smart Object implementation.
#define L_OBJECT_IMPL(CLASS)
// Declare one signal method.
#define L_SIGNAL(NAME, TYPES, ...) \
void NAME (L_APPLY_LIST(L_INTERNAL_SIGNAL_CONCAT_TYPE_ARG, TYPES, __VA_ARGS__)) { \
......@@ -132,7 +135,10 @@ namespace Private {
};
template<typename Signal, int NameLength>
constexpr MetaObjectSignalInfo<Signal, NameLength> makeMetaObjectSignalInfo (Signal signal, RawStringLiteral<NameLength> &name) {
constexpr MetaObjectSignalInfo<Signal, NameLength> makeMetaObjectSignalInfo (
Signal signal,
RawStringLiteral<NameLength> &name
) {
return { signal, { name } };
}
};
......
......@@ -47,12 +47,15 @@ class TestObjectPrivate : public ObjectPrivate {
public:
};
// 1. First step: It's necessary to inherit from `Object` to create a smart object.
class TestObject : public Object {
// 2. `L_OBJECT` => Declare TestObject as a smart object.
L_OBJECT(TestObject);
public:
TestObject () : Object(*new TestObjectPrivate) {}
// 3. `L_SIGNAL` => Declare a signal with `signal1` name and two parameters: `int toto` and `float tata`.
L_SIGNAL(signal1, (int, float), toto, tata); CHECK_SIGNAL_INDEX(0, signal1);
L_SIGNAL(signal2, (bool, float, int), a, b, c); CHECK_SIGNAL_INDEX(1, signal2);
......@@ -65,16 +68,32 @@ private:
L_DECLARE_PRIVATE(TestObject);
};
#undef GET_SIGNAL_INFO
#undef CHECK_SIGNAL_INDEX
#undef CHECK_SIGNAL_META_INFO
// 4. `L_OBJECT_IMPL` => Declare smart object implementation. MUST BE USED IN A CPP FILE!!!
L_OBJECT_IMPL(TestObject);
// -----------------------------------------------------------------------------
static void check_object_creation () {
TestObject *object = new TestObject();
delete object;
}
static void simple_slot () {
}
static void check_object_connection_to_function () {
TestObject object;
Connection connection = Object::connect(&object, &TestObject::signal1, simple_slot);
}
test_t object_tests[] = {
TEST_NO_TAG("Check object creation", check_object_creation)
TEST_NO_TAG("Check object creation", check_object_creation),
TEST_NO_TAG("Check object connection to function", check_object_connection_to_function)
};
test_suite_t object_test_suite = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment