mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-03 11:49:31 +00:00
Fix build of Python module + fix memory leak of bctbx_list_t objects in the wrapper.
This commit is contained in:
parent
a24787cfa5
commit
85ffd1e592
15 changed files with 78 additions and 60 deletions
|
|
@ -484,7 +484,7 @@ void linphone_core_remove_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *in
|
|||
/**
|
||||
* Returns an unmodifiable list of currently entered LinphoneAuthInfo.
|
||||
* @param[in] lc The LinphoneCore object
|
||||
* @return \mslist{LinphoneAuthInfo}
|
||||
* @return \bctbx_list{LinphoneAuthInfo}
|
||||
**/
|
||||
const bctbx_list_t *linphone_core_get_auth_info_list(const LinphoneCore *lc){
|
||||
return lc->auth_info;
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ LINPHONE_PUBLIC int linphone_conference_remove_participant(LinphoneConference *o
|
|||
* The returned bctbx_list_t contains URIs of all participant. That list must be
|
||||
* freed after use and each URI must be unref with linphone_address_unref()
|
||||
* @param obj A #LinphoneConference
|
||||
* @return \mslist{LinphoneAddress}
|
||||
* @return \bctbx_list{LinphoneAddress}
|
||||
*/
|
||||
LINPHONE_PUBLIC bctbx_list_t *linphone_conference_get_participants(const LinphoneConference *obj);
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ LINPHONE_PUBLIC void linphone_core_remove_friend_list(LinphoneCore *lc, Linphone
|
|||
/**
|
||||
* Retrieves the list of LinphoneFriendList from the core.
|
||||
* @param[in] lc LinphoneCore object
|
||||
* @return \mslist{LinphoneFriendList} a list of LinphoneFriendList
|
||||
* @return \bctbx_list{LinphoneFriendList} a list of LinphoneFriendList
|
||||
*/
|
||||
LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_friends_lists(const LinphoneCore *lc);
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ LINPHONE_PUBLIC LinphoneFriendListStatus linphone_friend_list_remove_friend(Linp
|
|||
/**
|
||||
* Retrieves the list of LinphoneFriend from this LinphoneFriendList.
|
||||
* @param[in] list LinphoneFriendList object
|
||||
* @return \mslist{LinphoneFriend} a list of LinphoneFriend
|
||||
* @return \bctbx_list{LinphoneFriend} a list of LinphoneFriend
|
||||
*/
|
||||
LINPHONE_PUBLIC const bctbx_list_t * linphone_friend_list_get_friends(const LinphoneFriendList *list);
|
||||
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ TAB_SIZE = 8
|
|||
# "Side Effects:". You can put \n's in the value part of an alias to insert
|
||||
# newlines.
|
||||
|
||||
ALIASES = "mslist{1}=A list of \ref \1 objects. \xmlonly <mslist>\1</mslist> \endxmlonly"
|
||||
ALIASES = "bctbx_list{1}=A list of \ref \1 objects. \xmlonly <bctbxlist>\1</bctbxlist> \endxmlonly"
|
||||
|
||||
# This tag can be used to specify a number of word-keyword mappings (TCL only).
|
||||
# A mapping has the form "name=value". For example adding "class=itcl::class"
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ LINPHONE_PUBLIC void linphone_tunnel_remove_server(LinphoneTunnel *tunnel, Linph
|
|||
/**
|
||||
* Get added servers
|
||||
* @param tunnel LinphoneTunnel object
|
||||
* @return \mslist{LinphoneTunnelConfig}
|
||||
* @return \bctbx_list{LinphoneTunnelConfig}
|
||||
*/
|
||||
LINPHONE_PUBLIC const bctbx_list_t *linphone_tunnel_get_servers(const LinphoneTunnel *tunnel);
|
||||
|
||||
|
|
|
|||
|
|
@ -1975,7 +1975,7 @@ LinphoneAddress *linphone_core_get_primary_contact_parsed(LinphoneCore *lc){
|
|||
/**
|
||||
* Sets the list of audio codecs.
|
||||
* @param[in] lc The LinphoneCore object
|
||||
* @param[in] codecs \mslist{PayloadType}
|
||||
* @param[in] codecs \bctbx_list{PayloadType}
|
||||
* @return 0
|
||||
*
|
||||
* @ingroup media_parameters
|
||||
|
|
@ -1993,7 +1993,7 @@ int linphone_core_set_audio_codecs(LinphoneCore *lc, bctbx_list_t *codecs){
|
|||
/**
|
||||
* Sets the list of video codecs.
|
||||
* @param[in] lc The LinphoneCore object
|
||||
* @param[in] codecs \mslist{PayloadType}
|
||||
* @param[in] codecs \bctbx_list{PayloadType}
|
||||
* @return 0
|
||||
*
|
||||
* @ingroup media_parameters
|
||||
|
|
@ -4130,7 +4130,7 @@ int linphone_core_terminate_all_calls(LinphoneCore *lc){
|
|||
/**
|
||||
* Returns the current list of calls.
|
||||
* @param[in] lc The LinphoneCore object
|
||||
* @return \mslist{LinphoneCall}
|
||||
* @return \bctbx_list{LinphoneCall}
|
||||
*
|
||||
* Note that this list is read-only and might be changed by the core after a function call to linphone_core_iterate().
|
||||
* Similarly the LinphoneCall objects inside it might be destroyed without prior notice.
|
||||
|
|
|
|||
|
|
@ -1583,7 +1583,7 @@ LINPHONE_PUBLIC int linphone_chat_room_get_history_size(LinphoneChatRoom *cr);
|
|||
* Gets nb_message most recent messages from cr chat room, sorted from oldest to most recent.
|
||||
* @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which messages should be retrieved
|
||||
* @param[in] nb_message Number of message to retrieve. 0 means everything.
|
||||
* @return \mslist{LinphoneChatMessage}
|
||||
* @return \bctbx_list{LinphoneChatMessage}
|
||||
*/
|
||||
LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message);
|
||||
|
||||
|
|
@ -1592,7 +1592,7 @@ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *c
|
|||
* @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which messages should be retrieved
|
||||
* @param[in] begin The first message of the range to be retrieved. History most recent message has index 0.
|
||||
* @param[in] end The last message of the range to be retrieved. History oldest message has index of history size - 1 (use #linphone_chat_room_get_history_size to retrieve history size)
|
||||
* @return \mslist{LinphoneChatMessage}
|
||||
* @return \bctbx_list{LinphoneChatMessage}
|
||||
*/
|
||||
LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int begin, int end);
|
||||
|
||||
|
|
@ -1643,7 +1643,7 @@ LINPHONE_PUBLIC uint32_t linphone_chat_room_get_char(const LinphoneChatRoom *cr)
|
|||
/**
|
||||
* Returns an list of chat rooms
|
||||
* @param[in] lc #LinphoneCore object
|
||||
* @return \mslist{LinphoneChatRoom}
|
||||
* @return \bctbx_list{LinphoneChatRoom}
|
||||
**/
|
||||
LINPHONE_PUBLIC const bctbx_list_t* linphone_core_get_chat_rooms(LinphoneCore *lc);
|
||||
LINPHONE_PUBLIC unsigned int linphone_chat_message_store(LinphoneChatMessage *msg);
|
||||
|
|
@ -2912,7 +2912,7 @@ LINPHONE_PUBLIC void linphone_core_set_dns_servers(LinphoneCore *lc, const bctbx
|
|||
/**
|
||||
* Returns the list of available audio codecs.
|
||||
* @param[in] lc The LinphoneCore object
|
||||
* @return \mslist{PayloadType}
|
||||
* @return \bctbx_list{PayloadType}
|
||||
*
|
||||
* This list is unmodifiable. The ->data field of the bctbx_list_t points a PayloadType
|
||||
* structure holding the codec information.
|
||||
|
|
@ -2927,7 +2927,7 @@ LINPHONE_PUBLIC int linphone_core_set_audio_codecs(LinphoneCore *lc, bctbx_list_
|
|||
/**
|
||||
* Returns the list of available video codecs.
|
||||
* @param[in] lc The LinphoneCore object
|
||||
* @return \mslist{PayloadType}
|
||||
* @return \bctbx_list{PayloadType}
|
||||
*
|
||||
* This list is unmodifiable. The ->data field of the bctbx_list_t points a PayloadType
|
||||
* structure holding the codec information.
|
||||
|
|
@ -2942,7 +2942,7 @@ LINPHONE_PUBLIC int linphone_core_set_video_codecs(LinphoneCore *lc, bctbx_list_
|
|||
/**
|
||||
* Returns the list of available text codecs.
|
||||
* @param[in] lc The LinphoneCore object
|
||||
* @return \mslist{PayloadType}
|
||||
* @return \bctbx_list{PayloadType}
|
||||
*
|
||||
* This list is unmodifiable. The ->data field of the bctbx_list_t points a PayloadType
|
||||
* structure holding the codec information.
|
||||
|
|
@ -3078,7 +3078,7 @@ LINPHONE_PUBLIC void linphone_core_remove_proxy_config(LinphoneCore *lc, Linphon
|
|||
/**
|
||||
* Returns an unmodifiable list of entered proxy configurations.
|
||||
* @param[in] lc The LinphoneCore object
|
||||
* @return \mslist{LinphoneProxyConfig}
|
||||
* @return \bctbx_list{LinphoneProxyConfig}
|
||||
**/
|
||||
LINPHONE_PUBLIC const bctbx_list_t *linphone_core_get_proxy_config_list(const LinphoneCore *lc);
|
||||
|
||||
|
|
@ -3539,7 +3539,7 @@ LINPHONE_PUBLIC void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *l
|
|||
/**
|
||||
* Get the list of call logs (past calls).
|
||||
* @param[in] lc LinphoneCore object
|
||||
* @return \mslist{LinphoneCallLog}
|
||||
* @return \bctbx_list{LinphoneCallLog}
|
||||
**/
|
||||
LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_call_logs(LinphoneCore *lc);
|
||||
|
||||
|
|
@ -3548,7 +3548,7 @@ LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_call_logs(LinphoneCore *l
|
|||
* At the contrary of linphone_core_get_call_logs, it is your responsability to unref the logs and free this list once you are done using it.
|
||||
* @param[in] lc LinphoneCore object
|
||||
* @param[in] addr LinphoneAddress object
|
||||
* @return \mslist{LinphoneCallLog}
|
||||
* @return \bctbx_list{LinphoneCallLog}
|
||||
**/
|
||||
LINPHONE_PUBLIC bctbx_list_t * linphone_core_get_call_history_for_address(LinphoneCore *lc, const LinphoneAddress *addr);
|
||||
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ LINPHONE_PUBLIC void linphone_friend_add_address(LinphoneFriend *lf, const Linph
|
|||
/**
|
||||
* Returns a list of #LinphoneAddress for this friend
|
||||
* @param lf #LinphoneFriend object
|
||||
* @return \mslist{LinphoneAddress}
|
||||
* @return \bctbx_list{LinphoneAddress}
|
||||
*/
|
||||
LINPHONE_PUBLIC const bctbx_list_t* linphone_friend_get_addresses(const LinphoneFriend *lf);
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ LINPHONE_PUBLIC void linphone_friend_add_phone_number(LinphoneFriend *lf, const
|
|||
/**
|
||||
* Returns a list of phone numbers for this friend
|
||||
* @param lf #LinphoneFriend object
|
||||
* @return \mslist{const char *}
|
||||
* @return \bctbx_list{const char *}
|
||||
*/
|
||||
LINPHONE_PUBLIC bctbx_list_t* linphone_friend_get_phone_numbers(LinphoneFriend *lf);
|
||||
|
||||
|
|
@ -444,7 +444,7 @@ LINPHONE_PUBLIC void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneF
|
|||
/**
|
||||
* Get Buddy list of LinphoneFriend
|
||||
* @param[in] lc #LinphoneCore object
|
||||
* @return \mslist{LinphoneFriend}
|
||||
* @return \bctbx_list{LinphoneFriend}
|
||||
* @deprecated use linphone_core_get_friends_lists() or linphone_friend_list_get_friends() instead.
|
||||
*/
|
||||
LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_friend_list(const LinphoneCore *lc);
|
||||
|
|
|
|||
|
|
@ -111,8 +111,8 @@ LINPHONE_PUBLIC const char *lp_config_get_string(const LpConfig *lpconfig, const
|
|||
* @param[in] lpconfig A LpConfig object
|
||||
* @param[in] section The section from which to retrieve a configuration item
|
||||
* @param[in] key The name of the configuration item to retrieve
|
||||
* @param[in] default_list \mslist{const char *}
|
||||
* @return \mslist{const char *}
|
||||
* @param[in] default_list \bctbx_list{const char *}
|
||||
* @return \bctbx_list{const char *}
|
||||
*/
|
||||
LINPHONE_PUBLIC bctbx_list_t * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, bctbx_list_t *default_list);
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ LINPHONE_PUBLIC void lp_config_set_string(LpConfig *lpconfig,const char *section
|
|||
* @param[in] lpconfig A LpConfig object
|
||||
* @param[in] section The name of the section to put the configuration item into
|
||||
* @param[in] key The name of the configuration item to set
|
||||
* @param[in] value \mslist{const char *} The value to set
|
||||
* @param[in] value \bctbx_list{const char *} The value to set
|
||||
*/
|
||||
LINPHONE_PUBLIC void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const bctbx_list_t *value);
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVcard *vCard);
|
|||
* Uses belcard to parse the content of a file and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none.
|
||||
* @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time)
|
||||
* @param[in] file the path to the file to parse
|
||||
* @return \mslist{LinphoneVcard}
|
||||
* @return \bctbx_list{LinphoneVcard}
|
||||
*/
|
||||
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardContext *context, const char *file);
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(Li
|
|||
* Uses belcard to parse the content of a buffer and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none.
|
||||
* @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time)
|
||||
* @param[in] buffer the buffer to parse
|
||||
* @return \mslist{LinphoneVcard}
|
||||
* @return \bctbx_list{LinphoneVcard}
|
||||
*/
|
||||
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardContext *context, const char *buffer);
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_
|
|||
/**
|
||||
* Returns the list of SIP addresses (as LinphoneAddress) in the vCard (all the IMPP attributes that has an URI value starting by "sip:") or NULL
|
||||
* @param[in] vCard the LinphoneVcard
|
||||
* @return const \mslist{LinphoneAddress *}
|
||||
* @return \bctbx_list{LinphoneAddress}
|
||||
*/
|
||||
LINPHONE_PUBLIC const bctbx_list_t* linphone_vcard_get_sip_addresses(LinphoneVcard *vCard);
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone)
|
|||
/**
|
||||
* Returns the list of phone numbers (as string) in the vCard (all the TEL attributes) or NULL
|
||||
* @param[in] vCard the LinphoneVcard
|
||||
* @return \mslist{const char *}
|
||||
* @return \bctbx_list{const char *}
|
||||
*/
|
||||
LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard);
|
||||
|
||||
|
|
@ -293,4 +293,4 @@ void linphone_vcard_clean_cache(LinphoneVcard *vCard);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ class Project:
|
|||
para.remove(n)
|
||||
for n in para.findall('.//ref'):
|
||||
n.attrib = {}
|
||||
for n in para.findall(".//mslist"):
|
||||
for n in para.findall(".//bctbx_list"):
|
||||
para.remove(n)
|
||||
if descriptionNode.tag == 'parameterdescription':
|
||||
descriptionNode.tag = 'description'
|
||||
|
|
@ -439,7 +439,7 @@ class Project:
|
|||
returndesc = node.find("./detaileddescription/para/simplesect[@kind='return']")
|
||||
if returndesc is not None:
|
||||
if returnarg.ctype == 'MSList' or returnarg.ctype == 'bctbx_list_t':
|
||||
n = returndesc.find('.//mslist')
|
||||
n = returndesc.find('.//bctbxlist')
|
||||
if n is not None:
|
||||
returnarg.containedType = n.text
|
||||
returnarg.description = self.__cleanDescription(returndesc)
|
||||
|
|
@ -510,7 +510,7 @@ class Project:
|
|||
returndesc = node.find("./detaileddescription/para/simplesect[@kind='return']")
|
||||
if returndesc is not None:
|
||||
if returnarg.ctype == 'MSList' or returnarg.ctype == 'bctbx_list_t':
|
||||
n = returndesc.find('.//mslist')
|
||||
n = returndesc.find('.//bctbxlist')
|
||||
if n is not None:
|
||||
returnarg.containedType = n.text
|
||||
returnarg.description = self.__cleanDescription(returndesc)
|
||||
|
|
@ -533,7 +533,7 @@ class Project:
|
|||
for paramdesc in paramdescs:
|
||||
if arg.name == paramdesc.find('./parameternamelist').find('./parametername').text:
|
||||
if arg.ctype == 'MSList' or arg.ctype == 'bctbx_list_t':
|
||||
n = paramdesc.find('.//mslist')
|
||||
n = paramdesc.find('.//bctbxlist')
|
||||
if n is not None:
|
||||
arg.containedType = n.text
|
||||
arg.description = self.__cleanDescription(paramdesc.find('./parameterdescription'))
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ typedef struct {
|
|||
LCSipTransports lcst;
|
||||
} pylinphone_SipTransportsObject;
|
||||
|
||||
PyObject * PyList_FromMSListOfString(const bctbx_list_t *msl);
|
||||
bctbx_list_t * PyList_AsMSListOfString(PyObject *pyl);
|
||||
PyObject * PyList_FromBctbxListOfString(const bctbx_list_t *msl);
|
||||
bctbx_list_t * PyList_AsBctbxListOfString(PyObject *pyl);
|
||||
|
||||
int PyLinphoneVideoSize_Check(PyObject *p);
|
||||
MSVideoSize PyLinphoneVideoSize_AsMSVideoSize(PyObject *obj);
|
||||
|
|
@ -44,4 +44,4 @@ static int pylinphone_Buffer_set_content(PyObject *self, PyObject *value, void *
|
|||
static PyObject * pylinphone_Content_get_buffer(PyObject *self, void *closure);
|
||||
static int pylinphone_Content_set_buffer(PyObject *self, PyObject *value, void *closure);
|
||||
|
||||
static PyObject * pylinphone_LpConfig_get_sections_names(PyObject *self, void *closure);
|
||||
static PyObject * pylinphone_LpConfig_get_sections_names(PyObject *self, void *closure);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
PyObject * PyList_FromMSListOfString(const bctbx_list_t *msl) {
|
||||
PyObject * PyList_FromBctbxListOfString(const bctbx_list_t *msl) {
|
||||
PyObject *pyl = PyList_New(0);
|
||||
while (msl != NULL) {
|
||||
PyObject *item = Py_BuildValue("z", (const char *)msl->data);
|
||||
|
|
@ -8,7 +8,7 @@ PyObject * PyList_FromMSListOfString(const bctbx_list_t *msl) {
|
|||
return pyl;
|
||||
}
|
||||
|
||||
bctbx_list_t * PyList_AsMSListOfString(PyObject *pyl) {
|
||||
bctbx_list_t * PyList_AsBctbxListOfString(PyObject *pyl) {
|
||||
bctbx_list_t *msl = NULL;
|
||||
Py_ssize_t idx;
|
||||
Py_ssize_t size = PyList_Size(pyl);
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ def compute_event_name(s, className):
|
|||
first = False
|
||||
return event_name
|
||||
|
||||
def is_const_from_complete_type(complete_type):
|
||||
splitted_type = complete_type.split(' ')
|
||||
return 'const' in splitted_type
|
||||
|
||||
|
||||
class HandWrittenCode:
|
||||
def __init__(self, _class, name, func_list, doc = ''):
|
||||
|
|
@ -95,6 +99,7 @@ class ArgumentType:
|
|||
self.check_condition = None
|
||||
self.convert_code = None
|
||||
self.convert_from_func = None
|
||||
self.free_convert_result_func = None
|
||||
self.fmt_str = 'O'
|
||||
self.cfmt_str = '%p'
|
||||
self.cnativefmt_str = '%p'
|
||||
|
|
@ -102,7 +107,7 @@ class ArgumentType:
|
|||
self.cast_convert_func_result = True
|
||||
self.__compute()
|
||||
if (self.basic_type == 'MSList' or self.basic_type == 'bctbx_list_t') and self.contained_type is not None and self.contained_type != 'const char *':
|
||||
self.linphone_module.mslist_types.add(self.contained_type)
|
||||
self.linphone_module.bctbxlist_types.add(self.contained_type)
|
||||
|
||||
def __compute(self):
|
||||
splitted_type = self.complete_type.split(' ')
|
||||
|
|
@ -217,12 +222,14 @@ class ArgumentType:
|
|||
elif self.basic_type == 'MSList' or self.basic_type == 'bctbx_list_t':
|
||||
if self.contained_type == 'const char *':
|
||||
self.type_str = 'list of string'
|
||||
self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsMSListOfString({arg_name});\n"
|
||||
self.convert_from_func = 'PyList_FromMSListOfString'
|
||||
self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsBctbxListOfString({arg_name});\n"
|
||||
self.convert_from_func = 'PyList_FromBctbxListOfString'
|
||||
else:
|
||||
self.type_str = 'list of linphone.' + self.contained_type
|
||||
self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsMSListOf" + self.contained_type + "({arg_name});\n"
|
||||
self.convert_from_func = 'PyList_FromMSListOf' + self.contained_type
|
||||
self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsBctbxListOf" + self.contained_type + "({arg_name});\n"
|
||||
self.convert_from_func = 'PyList_FromBctbxListOf' + self.contained_type
|
||||
if not is_const_from_complete_type(self.complete_type):
|
||||
self.free_convert_result_func = "bctbx_list_free"
|
||||
self.check_condition = "!PyList_Check({arg_name})"
|
||||
self.fmt_str = 'O'
|
||||
self.cfmt_str = '%p'
|
||||
|
|
@ -372,6 +379,7 @@ class MethodDefinition:
|
|||
def format_c_function_call(self):
|
||||
arg_names = []
|
||||
c_function_call_code = ''
|
||||
cfree_argument_code = ''
|
||||
for xml_method_arg in self.xml_method_args:
|
||||
arg_name = "_" + xml_method_arg.get('name')
|
||||
arg_type = xml_method_arg.get('type')
|
||||
|
|
@ -382,6 +390,10 @@ class MethodDefinition:
|
|||
arg_names.append(arg_name + "_native_ptr")
|
||||
elif argument_type.fmt_str == 'O' and argument_type.convert_code is not None:
|
||||
arg_names.append(arg_name + "_native_obj")
|
||||
if argument_type.free_convert_result_func is not None and not is_const_from_complete_type(arg_complete_type):
|
||||
cfree_argument_code = \
|
||||
"""{free_func}({arg_name}_native_obj);
|
||||
""".format(free_func=argument_type.free_convert_result_func, arg_name=arg_name)
|
||||
else:
|
||||
arg_names.append(arg_name)
|
||||
if is_callback(self.return_complete_type):
|
||||
|
|
@ -412,6 +424,10 @@ class MethodDefinition:
|
|||
convert_from_code = \
|
||||
"""pyresult = {convert_func}(cresult);
|
||||
""".format(convert_func=return_argument_type.convert_from_func)
|
||||
if return_argument_type.free_convert_result_func is not None:
|
||||
cfree_code = \
|
||||
"""{free_func}(cresult);
|
||||
""".format(free_func=return_argument_type.free_convert_result_func)
|
||||
result_variable = 'pyresult'
|
||||
else:
|
||||
result_variable = 'cresult'
|
||||
|
|
@ -421,12 +437,14 @@ class MethodDefinition:
|
|||
cfree_code = 'ms_free(cresult);';
|
||||
body = \
|
||||
""" {c_function_call_code}
|
||||
{cfree_argument_code}
|
||||
pylinphone_dispatch_messages();
|
||||
{from_native_pointer_code}
|
||||
{convert_from_code}
|
||||
{build_value_code}
|
||||
{cfree_code}
|
||||
""".format(c_function_call_code=c_function_call_code,
|
||||
cfree_argument_code=cfree_argument_code,
|
||||
from_native_pointer_code=from_native_pointer_code,
|
||||
convert_from_code=convert_from_code,
|
||||
build_value_code=build_value_code,
|
||||
|
|
@ -535,12 +553,6 @@ class MethodDefinition:
|
|||
self.self_arg = self.xml_method_args[0]
|
||||
self.xml_method_args = self.xml_method_args[1:]
|
||||
|
||||
def remove_const_from_complete_type(self, complete_type):
|
||||
splitted_type = complete_type.split(' ')
|
||||
while 'const' in splitted_type:
|
||||
splitted_type.remove('const')
|
||||
return ' '.join(splitted_type)
|
||||
|
||||
def find_class_definition(self, basic_type):
|
||||
basic_type = strip_leading_linphone(basic_type)
|
||||
for c in self.linphone_module.classes:
|
||||
|
|
@ -799,15 +811,21 @@ class SetterMethodDefinition(MethodDefinition):
|
|||
""" {method_name}(native_ptr, pylinphone_{class_name}_callback_{callback_name});
|
||||
pylinphone_dispatch_messages();
|
||||
""".format(method_name=self.method_node.get('name'), class_name=self.class_['class_name'], callback_name=compute_event_name(self.first_argument_type.complete_type, self.class_['class_name']))
|
||||
cfree_argument_code = ''
|
||||
suffix = ''
|
||||
if self.first_argument_type.fmt_str == 'O' and self.first_argument_type.use_native_pointer:
|
||||
suffix = '_native_ptr'
|
||||
elif self.first_argument_type.fmt_str == 'O' and self.first_argument_type.convert_code is not None:
|
||||
suffix = '_native_obj'
|
||||
if self.first_argument_type.free_convert_result_func is not None and not is_const_from_complete_type(self.first_argument_type.complete_type):
|
||||
cfree_argument_code = \
|
||||
"""{free_func}({arg_name}_native_obj);
|
||||
""".format(free_func=self.first_argument_type.free_convert_result_func, arg_name="_" + self.first_arg_name)
|
||||
return \
|
||||
""" {method_name}(native_ptr, {arg_name}{suffix});
|
||||
{cfree_argument_code}
|
||||
pylinphone_dispatch_messages();
|
||||
""".format(arg_name="_" + self.first_arg_name, method_name=self.method_node.get('name'), suffix=suffix)
|
||||
""".format(arg_name="_" + self.first_arg_name, method_name=self.method_node.get('name'), suffix=suffix, cfree_argument_code=cfree_argument_code)
|
||||
|
||||
def format_return_trace(self):
|
||||
return "\tpylinphone_trace(-1, \"[PYLINPHONE] <<< %s -> 0\", __FUNCTION__);\n"
|
||||
|
|
@ -989,7 +1007,7 @@ class LinphoneModule(object):
|
|||
def __init__(self, tree, blacklisted_classes, blacklisted_events, blacklisted_functions, hand_written_codes):
|
||||
self.internal_instance_method_names = ['destroy', 'ref', 'unref']
|
||||
self.internal_property_names = ['user_data']
|
||||
self.mslist_types = Set([])
|
||||
self.bctbxlist_types = Set([])
|
||||
self.enums = []
|
||||
self.enum_names = []
|
||||
self.cfunction2methodmap = {}
|
||||
|
|
@ -1225,14 +1243,14 @@ class LinphoneModule(object):
|
|||
except Exception, e:
|
||||
e.args += (c['class_name'], 'dealloc_body')
|
||||
raise
|
||||
# Convert mslist_types to a list of dictionaries for the template
|
||||
# Convert bctbxlist_types to a list of dictionaries for the template
|
||||
d = []
|
||||
for mslist_type in self.mslist_types:
|
||||
for bctbxlist_type in self.bctbxlist_types:
|
||||
t = {}
|
||||
t['c_contained_type'] = mslist_type
|
||||
t['python_contained_type'] = strip_leading_linphone(mslist_type)
|
||||
t['c_contained_type'] = bctbxlist_type
|
||||
t['python_contained_type'] = strip_leading_linphone(bctbxlist_type)
|
||||
d.append(t)
|
||||
self.mslist_types = d
|
||||
self.bctbxlist_types = d
|
||||
|
||||
def __format_doc_node(self, node):
|
||||
desc = ''
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ static PyObject * pylinphone_{{class_name}}_instance_method_{{method_name}}(PyOb
|
|||
{{/class_instance_hand_written_methods}}
|
||||
{{/classes}}
|
||||
|
||||
{{#mslist_types}}
|
||||
PyObject * PyList_FromMSListOf{{c_contained_type}}(const bctbx_list_t *msl) {
|
||||
{{#bctbxlist_types}}
|
||||
PyObject * PyList_FromBctbxListOf{{c_contained_type}}(const bctbx_list_t *msl) {
|
||||
PyObject *pyl = PyList_New(0);
|
||||
while (msl != NULL) {
|
||||
{{c_contained_type}} *native_ptr = ({{c_contained_type}} *)msl->data;
|
||||
|
|
@ -83,7 +83,7 @@ PyObject * PyList_FromMSListOf{{c_contained_type}}(const bctbx_list_t *msl) {
|
|||
return pyl;
|
||||
}
|
||||
|
||||
bctbx_list_t * PyList_AsMSListOf{{c_contained_type}}(PyObject *pyl) {
|
||||
bctbx_list_t * PyList_AsBctbxListOf{{c_contained_type}}(PyObject *pyl) {
|
||||
bctbx_list_t *msl = NULL;
|
||||
Py_ssize_t idx;
|
||||
Py_ssize_t size = PyList_Size(pyl);
|
||||
|
|
@ -95,7 +95,7 @@ bctbx_list_t * PyList_AsMSListOf{{c_contained_type}}(PyObject *pyl) {
|
|||
return msl;
|
||||
}
|
||||
|
||||
{{/mslist_types}}
|
||||
{{/bctbxlist_types}}
|
||||
|
||||
{{#core_events}}
|
||||
{{{event_callback_definition}}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue