Commit 3b08856d authored by Ronan's avatar Ronan

feat(c-wrapper): remove CPP_TYPE parameter of L_GET_CPP_PTR_FROM_C_STRUCT

parent c33a8f2d
......@@ -80,7 +80,7 @@ static LinphoneChatRoom *_linphone_core_create_chat_room_from_url(LinphoneCore *
}
static bool_t linphone_chat_room_matches(LinphoneChatRoom *cr, const LinphoneAddress *from) {
LinphoneAddress *addr = linphone_address_new(L_GET_CPP_PTR_FROM_C_STRUCT(cr, ChatRoom)->getPeerAddress().asString().c_str());
LinphoneAddress *addr = linphone_address_new(L_GET_CPP_PTR_FROM_C_STRUCT(cr)->getPeerAddress().asString().c_str());
bool_t result = linphone_address_weak_equal(addr, from);
linphone_address_unref(addr);
return result;
......@@ -235,8 +235,8 @@ int linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage
void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call) {
if (linphone_core_realtime_text_enabled(lc)) {
std::shared_ptr<LinphonePrivate::RealTimeTextChatRoom> rttcr =
std::static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(L_GET_CPP_PTR_FROM_C_STRUCT(cr, ChatRoom));
std::static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(L_GET_CPP_PTR_FROM_C_STRUCT(cr));
L_GET_PRIVATE(rttcr)->realtimeTextReceived(character, call);
//L_GET_PRIVATE(std::static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(L_GET_CPP_PTR_FROM_C_STRUCT(cr, ChatRoom, ChatRoom)))->realtimeTextReceived(character, call);
//L_GET_PRIVATE(std::static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(L_GET_CPP_PTR_FROM_C_STRUCT(cr)))->realtimeTextReceived(character, call);
}
}
......@@ -29,5 +29,5 @@
#include "chat/chat-room.h"
LinphoneChatMessage *linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr, const LinphoneContent *initial_content) {
return L_GET_CPP_PTR_FROM_C_STRUCT(cr, ChatRoom)->createFileTransferMessage(initial_content);
return L_GET_CPP_PTR_FROM_C_STRUCT(cr)->createFileTransferMessage(initial_content);
}
......@@ -6653,7 +6653,7 @@ void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m) {
}
void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *params) {
L_GET_CPP_PTR_FROM_C_STRUCT(params, MediaSessionParams)->initDefault(lc);
L_GET_CPP_PTR_FROM_C_STRUCT(params)->initDefault(lc);
}
void linphone_core_set_device_identifier(LinphoneCore *lc,const char* device_id) {
......
......@@ -22,7 +22,7 @@
// =============================================================================
#define GET_MEDIA_CPP_PTR(obj) L_GET_CPP_PTR_FROM_C_STRUCT(obj, MediaSessionParams)
#define GET_MEDIA_CPP_PTR(obj) L_GET_CPP_PTR_FROM_C_STRUCT(obj)
#define GET_MEDIA_CPP_PRIVATE_PTR(obj) L_GET_PRIVATE_FROM_C_STRUCT(obj, MediaSessionParams)
L_DECLARE_C_CLONABLE_STRUCT_IMPL(CallParams)
......
......@@ -28,7 +28,7 @@
// =============================================================================
#define GET_CPP_PTR(obj) L_GET_CPP_PTR_FROM_C_STRUCT(obj, Call)
#define GET_CPP_PTR(obj) L_GET_CPP_PTR_FROM_C_STRUCT(obj)
#define GET_CPP_PRIVATE_PTR(obj) L_GET_PRIVATE_FROM_C_STRUCT(obj, Call)
using namespace std;
......@@ -936,7 +936,7 @@ LinphoneStatus linphone_call_accept (LinphoneCall *call) {
}
LinphoneStatus linphone_call_accept_with_params (LinphoneCall *call, const LinphoneCallParams *params) {
return GET_CPP_PTR(call)->accept(params ? L_GET_CPP_PTR_FROM_C_STRUCT(params, MediaSessionParams) : nullptr);
return GET_CPP_PTR(call)->accept(params ? L_GET_CPP_PTR_FROM_C_STRUCT(params) : nullptr);
}
LinphoneStatus linphone_call_accept_early_media (LinphoneCall* call) {
......@@ -944,11 +944,11 @@ LinphoneStatus linphone_call_accept_early_media (LinphoneCall* call) {
}
LinphoneStatus linphone_call_accept_early_media_with_params (LinphoneCall *call, const LinphoneCallParams *params) {
return GET_CPP_PTR(call)->acceptEarlyMedia(params ? L_GET_CPP_PTR_FROM_C_STRUCT(params, MediaSessionParams) : nullptr);
return GET_CPP_PTR(call)->acceptEarlyMedia(params ? L_GET_CPP_PTR_FROM_C_STRUCT(params) : nullptr);
}
LinphoneStatus linphone_call_update (LinphoneCall *call, const LinphoneCallParams *params) {
return GET_CPP_PTR(call)->update(params ? L_GET_CPP_PTR_FROM_C_STRUCT(params, MediaSessionParams) : nullptr);
return GET_CPP_PTR(call)->update(params ? L_GET_CPP_PTR_FROM_C_STRUCT(params) : nullptr);
}
LinphoneStatus linphone_call_defer_update (LinphoneCall *call) {
......@@ -971,7 +971,7 @@ LinphoneStatus linphone_call_defer_update (LinphoneCall *call) {
}
LinphoneStatus linphone_call_accept_update (LinphoneCall *call, const LinphoneCallParams *params) {
return GET_CPP_PTR(call)->acceptUpdate(params ? L_GET_CPP_PTR_FROM_C_STRUCT(params, MediaSessionParams) : nullptr);
return GET_CPP_PTR(call)->acceptUpdate(params ? L_GET_CPP_PTR_FROM_C_STRUCT(params) : nullptr);
}
LinphoneStatus linphone_call_transfer (LinphoneCall *call, const char *refer_to) {
......@@ -1188,8 +1188,8 @@ void linphone_call_set_user_data (LinphoneCall *call, void *ud) {
LinphoneCall *linphone_call_new_outgoing (LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg) {
LinphoneCall *call = L_INIT(Call);
L_SET_CPP_PTR_FROM_C_STRUCT(call, std::make_shared<LinphonePrivate::Call>(call, lc, LinphoneCallOutgoing,
*L_GET_CPP_PTR_FROM_C_STRUCT(from, Address), *L_GET_CPP_PTR_FROM_C_STRUCT(to, Address),
cfg, nullptr, L_GET_CPP_PTR_FROM_C_STRUCT(params, MediaSessionParams)));
*L_GET_CPP_PTR_FROM_C_STRUCT(from), *L_GET_CPP_PTR_FROM_C_STRUCT(to),
cfg, nullptr, L_GET_CPP_PTR_FROM_C_STRUCT(params)));
call->currentParamsCache = linphone_call_params_new_for_wrapper();
call->paramsCache = linphone_call_params_new_for_wrapper();
call->remoteParamsCache = linphone_call_params_new_for_wrapper();
......@@ -1200,7 +1200,7 @@ LinphoneCall *linphone_call_new_outgoing (LinphoneCore *lc, const LinphoneAddres
LinphoneCall *linphone_call_new_incoming (LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, SalOp *op) {
LinphoneCall *call = L_INIT(Call);
L_SET_CPP_PTR_FROM_C_STRUCT(call, std::make_shared<LinphonePrivate::Call>(call, lc, LinphoneCallIncoming,
*L_GET_CPP_PTR_FROM_C_STRUCT(from, Address), *L_GET_CPP_PTR_FROM_C_STRUCT(to, Address),
*L_GET_CPP_PTR_FROM_C_STRUCT(from), *L_GET_CPP_PTR_FROM_C_STRUCT(to),
nullptr, op, nullptr));
call->currentParamsCache = linphone_call_params_new_for_wrapper();
call->paramsCache = linphone_call_params_new_for_wrapper();
......
......@@ -30,7 +30,7 @@
// =============================================================================
#define GET_CPP_PTR(obj) L_GET_CPP_PTR_FROM_C_STRUCT(obj, ChatMessage, ChatMessage)
#define GET_CPP_PTR(obj) L_GET_CPP_PTR_FROM_C_STRUCT(obj)
#define GET_CPP_PRIVATE_PTR(obj) L_GET_PRIVATE_FROM_C_STRUCT(obj, ChatMessage, ChatMessage)
using namespace std;
......@@ -324,7 +324,7 @@ void _linphone_chat_message_resend(LinphoneChatMessage *msg, bool_t ref_msg) {
cr = linphone_chat_message_get_chat_room(msg);
if (ref_msg) linphone_chat_message_ref(msg);
L_GET_CPP_PTR_FROM_C_STRUCT(cr, ChatRoom)->sendMessage(msg);
L_GET_CPP_PTR_FROM_C_STRUCT(cr)->sendMessage(msg);
}
void linphone_chat_message_resend(LinphoneChatMessage *msg) {
......@@ -465,7 +465,7 @@ void linphone_chat_message_send_display_notification(LinphoneChatMessage *cm) {
LinphoneChatRoom *cr = linphone_chat_message_get_chat_room(msg);
if (linphone_core_realtime_text_enabled(linphone_chat_room_get_core(cr))) {
std::shared_ptr<LinphonePrivate::RealTimeTextChatRoom> rttcr =
std::static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(L_GET_CPP_PTR_FROM_C_STRUCT(cr, ChatRoom));
std::static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(L_GET_CPP_PTR_FROM_C_STRUCT(cr));
LinphoneCall *call = rttcr->getCall();
LinphoneCore *lc = rttcr->getCore();
const uint32_t new_line = 0x2028;
......@@ -936,7 +936,7 @@ static void linphone_chat_message_process_response_from_post_file(void *data, co
linphone_chat_message_ref(msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone);
_release_http_request(msg);
L_GET_CPP_PTR_FROM_C_STRUCT(msg->chat_room, ChatRoom)->sendMessage(msg);
L_GET_CPP_PTR_FROM_C_STRUCT(msg->chat_room)->sendMessage(msg);
file_upload_end_background_task(msg);
linphone_chat_message_unref(msg);
} else {
......
......@@ -29,7 +29,7 @@
// =============================================================================
#define GET_CPP_PTR(obj) L_GET_CPP_PTR_FROM_C_STRUCT(obj, ChatRoom)
#define GET_CPP_PTR(obj) L_GET_CPP_PTR_FROM_C_STRUCT(obj)
#define GET_CPP_PRIVATE_PTR(obj) L_GET_PRIVATE_FROM_C_STRUCT(obj, ChatRoom)
using namespace std;
......@@ -211,7 +211,7 @@ LinphoneChatRoomState linphone_chat_room_get_state (const LinphoneChatRoom *cr)
LinphoneParticipant *linphone_chat_room_add_participant (LinphoneChatRoom *cr, const LinphoneAddress *addr) {
return L_GET_C_BACK_PTR(GET_CPP_PTR(cr)->addParticipant(
*L_GET_CPP_PTR_FROM_C_STRUCT(addr, Address), nullptr, false),
*L_GET_CPP_PTR_FROM_C_STRUCT(addr), nullptr, false),
Participant);
}
......@@ -237,7 +237,7 @@ bctbx_list_t *linphone_chat_room_get_participants (const LinphoneChatRoom *cr) {
}
void linphone_chat_room_remove_participant (LinphoneChatRoom *cr, LinphoneParticipant *participant) {
GET_CPP_PTR(cr)->removeParticipant(L_GET_CPP_PTR_FROM_C_STRUCT(participant, Participant));
GET_CPP_PTR(cr)->removeParticipant(L_GET_CPP_PTR_FROM_C_STRUCT(participant));
}
void linphone_chat_room_remove_participants (LinphoneChatRoom *cr, const bctbx_list_t *participants) {
......@@ -272,9 +272,9 @@ void linphone_chat_room_set_user_data (LinphoneChatRoom *cr, void *ud) {
LinphoneChatRoom *linphone_chat_room_new (LinphoneCore *core, const LinphoneAddress *addr) {
LinphoneChatRoom *cr = _linphone_ChatRoom_init();
if (linphone_core_realtime_text_enabled(core))
L_SET_CPP_PTR_FROM_C_STRUCT(cr, std::make_shared<LinphonePrivate::RealTimeTextChatRoom>(core, *L_GET_CPP_PTR_FROM_C_STRUCT(addr, Address)));
L_SET_CPP_PTR_FROM_C_STRUCT(cr, std::make_shared<LinphonePrivate::RealTimeTextChatRoom>(core, *L_GET_CPP_PTR_FROM_C_STRUCT(addr)));
else
L_SET_CPP_PTR_FROM_C_STRUCT(cr, std::make_shared<LinphonePrivate::BasicChatRoom>(core, *L_GET_CPP_PTR_FROM_C_STRUCT(addr, Address)));
L_SET_CPP_PTR_FROM_C_STRUCT(cr, std::make_shared<LinphonePrivate::BasicChatRoom>(core, *L_GET_CPP_PTR_FROM_C_STRUCT(addr)));
linphone_core_notify_chat_room_instantiated(core, cr);
L_GET_PRIVATE_FROM_C_STRUCT(cr, ChatRoom)->setState(LinphonePrivate::ChatRoom::State::Instantiated);
L_GET_PRIVATE_FROM_C_STRUCT(cr, ChatRoom)->setState(LinphonePrivate::ChatRoom::State::Created);
......@@ -290,7 +290,7 @@ LinphoneChatRoom *linphone_client_group_chat_room_new (LinphoneCore *core, const
linphone_address_unref(factoryAddr);
std::string from;
if (proxy)
from = L_GET_CPP_PTR_FROM_C_STRUCT(linphone_proxy_config_get_identity_address(proxy), Address)->asString();
from = L_GET_CPP_PTR_FROM_C_STRUCT(linphone_proxy_config_get_identity_address(proxy))->asString();
if (from.empty())
from = linphone_core_get_primary_contact(core);
LinphonePrivate::Address me(from);
......
......@@ -53,7 +53,7 @@ LinphoneEventLog *linphone_event_log_ref (LinphoneEventLog *event_log) {
LinphoneEventLogType linphone_event_log_get_type (const LinphoneEventLog *event_log) {
return static_cast<LinphoneEventLogType>(
L_GET_CPP_PTR_FROM_C_STRUCT(event_log, EventLog)->getType()
L_GET_CPP_PTR_FROM_C_STRUCT(event_log)->getType()
);
}
......@@ -67,7 +67,7 @@ LinphoneCallEvent *linphone_call_event_new (LinphoneEventLogType type, LinphoneC
call_event,
new LINPHONE_NAMESPACE::CallEvent(
static_cast<LINPHONE_NAMESPACE::EventLog::Type>(type),
L_GET_CPP_PTR_FROM_C_STRUCT(call, Call)
L_GET_CPP_PTR_FROM_C_STRUCT(call)
)
);
return call_event;
......@@ -75,10 +75,7 @@ LinphoneCallEvent *linphone_call_event_new (LinphoneEventLogType type, LinphoneC
LinphoneCall *linphone_call_event_get_call (const LinphoneCallEvent *call_event) {
return L_GET_C_BACK_PTR(
L_GET_CPP_PTR_FROM_C_STRUCT(
call_event, CallEvent
)->getCall(),
Call
L_GET_CPP_PTR_FROM_C_STRUCT(call_event)->getCall(), Call
);
}
......@@ -128,7 +125,7 @@ LinphoneChatMessageEvent *linphone_chat_message_event_new (LinphoneChatMessage *
L_SET_CPP_PTR_FROM_C_STRUCT(
chat_message_event,
new LINPHONE_NAMESPACE::ChatMessageEvent(
L_GET_CPP_PTR_FROM_C_STRUCT(chat_message, ChatMessage)
L_GET_CPP_PTR_FROM_C_STRUCT(chat_message)
)
);
return chat_message_event;
......@@ -136,9 +133,7 @@ LinphoneChatMessageEvent *linphone_chat_message_event_new (LinphoneChatMessage *
LinphoneChatMessage *linphone_chat_message_event_get_chat_message (const LinphoneChatMessageEvent *chat_message_event) {
return L_GET_C_BACK_PTR(
L_GET_CPP_PTR_FROM_C_STRUCT(
chat_message_event, ChatMessageEvent
)->getChatMessage(),
L_GET_CPP_PTR_FROM_C_STRUCT(chat_message_event)->getChatMessage(),
ChatMessage
);
}
......@@ -47,7 +47,7 @@ void linphone_participant_set_user_data(LinphoneParticipant *participant, void *
}
const LinphoneAddress *linphone_participant_get_address (const LinphoneParticipant *participant) {
LinphonePrivate::Address addr = L_GET_CPP_PTR_FROM_C_STRUCT(participant, Participant)->getAddress();
LinphonePrivate::Address addr = L_GET_CPP_PTR_FROM_C_STRUCT(participant)->getAddress();
if (participant->addressCache)
linphone_address_unref(participant->addressCache);
participant->addressCache = linphone_address_new(addr.asString().c_str());
......@@ -55,9 +55,9 @@ const LinphoneAddress *linphone_participant_get_address (const LinphoneParticipa
}
bool_t linphone_participant_is_admin (const LinphoneParticipant *participant) {
return L_GET_CPP_PTR_FROM_C_STRUCT(participant, Participant)->isAdmin();
return L_GET_CPP_PTR_FROM_C_STRUCT(participant)->isAdmin();
}
void linphone_participant_set_admin (LinphoneParticipant *participant, bool_t value) {
L_GET_CPP_PTR_FROM_C_STRUCT(participant, Participant)->setAdmin(value);
L_GET_CPP_PTR_FROM_C_STRUCT(participant)->setAdmin(value);
}
......@@ -323,6 +323,9 @@ LINPHONE_END_NAMESPACE
#define L_CPP_TYPE_OF_C_TYPE(C_TYPE) \
LINPHONE_NAMESPACE::CTypeToCppType<Linphone ## C_TYPE>::type
#define L_CPP_TYPE_OF_C_OBJECT(C_OBJECT) \
LINPHONE_NAMESPACE::CTypeToCppType<std::remove_const<std::remove_pointer<decltype(C_OBJECT)>::type>::type>::type
// -----------------------------------------------------------------------------
// C object declaration.
// -----------------------------------------------------------------------------
......@@ -392,9 +395,9 @@ LINPHONE_END_NAMESPACE
#define L_INIT(C_TYPE) _linphone_ ## C_TYPE ## _init ()
// Get the cpp-ptr of a wrapped C object.
#define L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT, CPP_TYPE) \
#define L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT) \
LINPHONE_NAMESPACE::Wrapper::getCppPtrFromC< \
LINPHONE_NAMESPACE::CPP_TYPE, \
L_CPP_TYPE_OF_C_OBJECT(OBJECT), \
std::remove_pointer<decltype(OBJECT)>::type \
>(OBJECT)
......@@ -409,7 +412,7 @@ LINPHONE_END_NAMESPACE
// Get the private data of a shared or simple cpp-ptr of a wrapped C object.
#define L_GET_PRIVATE_FROM_C_STRUCT(OBJECT, CPP_TYPE) \
L_GET_PRIVATE(LINPHONE_NAMESPACE::Wrapper::getCppPtr( \
L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT, CPP_TYPE) \
L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT) \
))
// Get the wrapped C object of a C++ object.
......@@ -421,11 +424,11 @@ LINPHONE_END_NAMESPACE
// Get/set user data on a wrapped C object.
#define L_GET_USER_DATA_FROM_C_STRUCT(OBJECT, CPP_TYPE) \
LINPHONE_NAMESPACE::Wrapper::getUserData( \
L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT, CPP_TYPE) \
L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT) \
)
#define L_SET_USER_DATA_FROM_C_STRUCT(OBJECT, VALUE, CPP_TYPE) \
LINPHONE_NAMESPACE::Wrapper::setUserData( \
L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT, CPP_TYPE), \
L_GET_CPP_PTR_FROM_C_STRUCT(OBJECT), \
VALUE \
)
......
......@@ -828,7 +828,7 @@ void ChatRoom::sendMessage (LinphoneChatMessage *msg) {
if (identity.empty()) {
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(d->core, peer);
if (proxy) {
identity = L_GET_CPP_PTR_FROM_C_STRUCT(linphone_proxy_config_get_identity_address(proxy), Address)->asString();
identity = L_GET_CPP_PTR_FROM_C_STRUCT(linphone_proxy_config_get_identity_address(proxy))->asString();
} else {
identity = linphone_core_get_primary_contact(d->core);
}
......
......@@ -963,8 +963,7 @@ LinphoneReason CallSession::getReason () const {
const Address& CallSession::getRemoteAddress () const {
L_D(const CallSession);
return *L_GET_CPP_PTR_FROM_C_STRUCT((d->direction == LinphoneCallIncoming)
? linphone_call_log_get_from(d->log) : linphone_call_log_get_to(d->log),
Address);
? linphone_call_log_get_from(d->log) : linphone_call_log_get_to(d->log));
}
string CallSession::getRemoteAddressAsString () const {
......
......@@ -1221,7 +1221,7 @@ void MediaSessionPrivate::makeLocalMediaDescription () {
/* Re-check local ip address each time we make a new offer, because it may change in case of network reconnection */
{
LinphoneAddress *address = (direction == LinphoneCallOutgoing ? log->to : log->from);
getLocalIp(*L_GET_CPP_PTR_FROM_C_STRUCT(address, Address));
getLocalIp(*L_GET_CPP_PTR_FROM_C_STRUCT(address));
}
strncpy(md->addr, mediaLocalIp.c_str(), sizeof(md->addr));
......
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