mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-23 14:18:07 +00:00
Fix build of Python module + handle wrapper generation of deprecated methods.
This commit is contained in:
parent
33a781807e
commit
c71cfe46ec
5 changed files with 39 additions and 43 deletions
|
|
@ -2269,7 +2269,7 @@ LINPHONE_PUBLIC void linphone_core_v_table_set_user_data(LinphoneCoreVTable *tab
|
|||
* @param table the vtable
|
||||
* @return the data attached to the vtable
|
||||
*/
|
||||
LINPHONE_PUBLIC void* linphone_core_v_table_get_user_data(LinphoneCoreVTable *table);
|
||||
LINPHONE_PUBLIC void* linphone_core_v_table_get_user_data(const LinphoneCoreVTable *table);
|
||||
|
||||
/**
|
||||
* Gets the current VTable.
|
||||
|
|
@ -4630,15 +4630,6 @@ LINPHONE_PUBLIC const char* linphone_transport_to_string(LinphoneTransportType t
|
|||
**/
|
||||
LINPHONE_PUBLIC LinphoneTransportType linphone_transport_parse(const char* transport);
|
||||
|
||||
/**
|
||||
* @ingroup media_parameters
|
||||
* Get default call parameters reflecting current linphone core configuration
|
||||
* @param lc LinphoneCore object
|
||||
* @return LinphoneCallParams
|
||||
* @deprecated use linphone_core_create_call_params()
|
||||
*/
|
||||
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneCallParams *linphone_core_create_default_call_parameters(LinphoneCore *lc);
|
||||
|
||||
typedef struct _LinphoneRingtonePlayer LinphoneRingtonePlayer;
|
||||
|
||||
LINPHONE_PUBLIC LinphoneRingtonePlayer *linphone_core_get_ringtoneplayer(LinphoneCore *lc);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ void linphone_core_v_table_set_user_data(LinphoneCoreVTable *table, void *data)
|
|||
table->user_data = data;
|
||||
}
|
||||
|
||||
void* linphone_core_v_table_get_user_data(LinphoneCoreVTable *table) {
|
||||
void* linphone_core_v_table_get_user_data(const LinphoneCoreVTable *table) {
|
||||
return table->user_data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ class CArgument(CObject):
|
|||
fullySplittedType.append('*')
|
||||
else:
|
||||
fullySplittedType.append(s)
|
||||
if 'MS2_DEPRECATED' in fullySplittedType:
|
||||
fullySplittedType.remove('MS2_DEPRECATED')
|
||||
isStruct = False
|
||||
isEnum = False
|
||||
self.ctype = 'int' # Default to int so that the result is correct eg. for 'unsigned short'
|
||||
|
|
|
|||
|
|
@ -31,22 +31,29 @@ blacklisted_classes = [
|
|||
'LinphoneTunnelConfig'
|
||||
]
|
||||
blacklisted_events = [
|
||||
'LinphoneChatMessageStateChangedCb', # not respecting naming convention
|
||||
'LinphoneCoreInfoReceivedCb', # missing LinphoneInfoMessage
|
||||
'LinphoneCoreNotifyReceivedCb', # missing LinphoneContent
|
||||
'LinphoneCoreFileTransferProgressIndicationCb', # missing LinphoneContent
|
||||
'LinphoneCoreFileTransferRecvCb', # missing LinphoneContent
|
||||
'LinphoneCoreFileTransferSendCb' # missing LinphoneContent
|
||||
'LinphoneCoreFileTransferSendCb', # missing LinphoneContent
|
||||
'LinphoneCoreTextMessageReceivedCb' # not respecting naming convention
|
||||
]
|
||||
blacklisted_functions = [
|
||||
'linphone_call_log_get_local_stats', # missing rtp_stats_t
|
||||
'linphone_call_log_get_remote_stats', # missing rtp_stats_t
|
||||
'linphone_call_params_get_privacy', # missing LinphonePrivacyMask
|
||||
'linphone_call_params_set_privacy', # missing LinphonePrivacyMask
|
||||
'linphone_chat_message_start_file_download', # callback function in parameter
|
||||
'linphone_chat_message_state_to_string', # There is no use to wrap this function
|
||||
'linphone_chat_room_send_message2', # callback function in parameter
|
||||
'linphone_core_add_listener',
|
||||
'linphone_core_can_we_add_call', # private function
|
||||
'linphone_core_enable_log_collection', # need to handle class properties
|
||||
'linphone_core_enable_logs', # unhandled argument type FILE
|
||||
'linphone_core_enable_logs_with_cb', # callback function in parameter
|
||||
'linphone_core_get_audio_port_range', # to be handwritten because of result via arguments
|
||||
'linphone_core_get_default_proxy',
|
||||
'linphone_core_get_network_simulator_params', # missing OrtpNetworkSimulatorParams
|
||||
'linphone_core_get_supported_video_sizes', # missing MSVideoSizeDef
|
||||
'linphone_core_get_video_policy', # missing LinphoneVideoPolicy
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ class ArgumentType:
|
|||
|
||||
|
||||
class MethodDefinition:
|
||||
def __init__(self, linphone_module, class_, method_node = None):
|
||||
def __init__(self, linphone_module, class_, method_name = "", method_node = None):
|
||||
self.body = ''
|
||||
self.arg_names = []
|
||||
self.parse_tuple_format = ''
|
||||
|
|
@ -269,6 +269,7 @@ class MethodDefinition:
|
|||
self.return_type = 'void'
|
||||
self.return_complete_type = 'void'
|
||||
self.return_contained_type = None
|
||||
self.method_name = method_name
|
||||
self.method_node = method_node
|
||||
self.class_ = class_
|
||||
self.linphone_module = linphone_module
|
||||
|
|
@ -303,6 +304,12 @@ class MethodDefinition:
|
|||
self.arg_names.append(arg_name)
|
||||
return body
|
||||
|
||||
def format_deprecation_warning(self):
|
||||
if self.method_node is not None and self.method_node.get('deprecated') == 'true':
|
||||
print(self.class_['class_name'] + "." + self.method_name + " is deprecated")
|
||||
return "\tPyErr_WarnEx(PyExc_DeprecationWarning, \"{msg}\", 1);\n".format(msg="{class_name}.{method_name} is deprecated".format(class_name=self.class_['class_name'], method_name=self.method_name))
|
||||
return ""
|
||||
|
||||
def format_arguments_parsing(self):
|
||||
class_native_ptr_check_code = ''
|
||||
if self.self_arg is not None:
|
||||
|
|
@ -544,6 +551,7 @@ class MethodDefinition:
|
|||
def format(self):
|
||||
self.parse_method_node()
|
||||
body = self.format_local_variables_definition()
|
||||
body += self.format_deprecation_warning()
|
||||
body += self.format_arguments_parsing()
|
||||
body += self.format_enter_trace()
|
||||
body += self.format_c_function_call()
|
||||
|
|
@ -553,7 +561,7 @@ class MethodDefinition:
|
|||
|
||||
class NewMethodDefinition(MethodDefinition):
|
||||
def __init__(self, linphone_module, class_, method_node = None):
|
||||
MethodDefinition.__init__(self, linphone_module, class_, method_node)
|
||||
MethodDefinition.__init__(self, linphone_module, class_, "new", method_node)
|
||||
|
||||
def format_local_variables_definition(self):
|
||||
return "\tpylinphone_{class_name}Object *self = (pylinphone_{class_name}Object *)type->tp_alloc(type, 0);\n".format(class_name=self.class_['class_name'])
|
||||
|
|
@ -575,7 +583,7 @@ class NewMethodDefinition(MethodDefinition):
|
|||
|
||||
class InitMethodDefinition(MethodDefinition):
|
||||
def __init__(self, linphone_module, class_, method_node = None):
|
||||
MethodDefinition.__init__(self, linphone_module, class_, method_node)
|
||||
MethodDefinition.__init__(self, linphone_module, class_, "init", method_node)
|
||||
|
||||
def format_local_variables_definition(self):
|
||||
return "\tpylinphone_{class_name}Object *self_obj = (pylinphone_{class_name}Object *)self;\n".format(class_name=self.class_['class_name'])
|
||||
|
|
@ -604,7 +612,7 @@ class InitMethodDefinition(MethodDefinition):
|
|||
|
||||
class FromNativePointerMethodDefinition(MethodDefinition):
|
||||
def __init__(self, linphone_module, class_):
|
||||
MethodDefinition.__init__(self, linphone_module, class_, None)
|
||||
MethodDefinition.__init__(self, linphone_module, class_, "from_native_pointer", None)
|
||||
|
||||
def format_local_variables_definition(self):
|
||||
return "\tpylinphone_{class_name}Object *self = NULL;\n".format(class_name=self.class_['class_name'])
|
||||
|
|
@ -653,7 +661,7 @@ class FromNativePointerMethodDefinition(MethodDefinition):
|
|||
|
||||
class DeallocMethodDefinition(MethodDefinition):
|
||||
def __init__(self, linphone_module, class_, method_node = None):
|
||||
MethodDefinition.__init__(self, linphone_module, class_, method_node)
|
||||
MethodDefinition.__init__(self, linphone_module, class_, "dealloc", method_node)
|
||||
|
||||
def format_local_variables_definition(self):
|
||||
func = "pylinphone_{class_name}_get_native_ptr".format(class_name=self.class_['class_name'])
|
||||
|
|
@ -714,12 +722,12 @@ class DeallocMethodDefinition(MethodDefinition):
|
|||
}}""".format(class_name=self.class_['class_name'], method_body=MethodDefinition.format(self))
|
||||
|
||||
class GetterMethodDefinition(MethodDefinition):
|
||||
def __init__(self, linphone_module, class_, method_node = None):
|
||||
MethodDefinition.__init__(self, linphone_module, class_, method_node)
|
||||
def __init__(self, linphone_module, class_, method_name = "", method_node = None):
|
||||
MethodDefinition.__init__(self, linphone_module, class_, method_name, method_node)
|
||||
|
||||
class SetterMethodDefinition(MethodDefinition):
|
||||
def __init__(self, linphone_module, class_, method_node = None):
|
||||
MethodDefinition.__init__(self, linphone_module, class_, method_node)
|
||||
def __init__(self, linphone_module, class_, method_name = "", method_node = None):
|
||||
MethodDefinition.__init__(self, linphone_module, class_, method_name, method_node)
|
||||
|
||||
def format_arguments_parsing(self):
|
||||
if self.first_argument_type.check_condition is None:
|
||||
|
|
@ -821,8 +829,8 @@ class SetterMethodDefinition(MethodDefinition):
|
|||
self.first_arg_class = strip_leading_linphone(self.first_arg_type)
|
||||
|
||||
class EventCallbackMethodDefinition(MethodDefinition):
|
||||
def __init__(self, linphone_module, class_, method_node = None):
|
||||
MethodDefinition.__init__(self, linphone_module, class_, method_node)
|
||||
def __init__(self, linphone_module, class_, method_name = "", method_node = None):
|
||||
MethodDefinition.__init__(self, linphone_module, class_, method_name, method_node)
|
||||
|
||||
def format_local_variables_definition(self):
|
||||
class_name = self.class_['event_class']
|
||||
|
|
@ -990,8 +998,6 @@ class LinphoneModule(object):
|
|||
hand_written_functions += hand_written_code.func_list
|
||||
xml_enums = tree.findall("./enums/enum")
|
||||
for xml_enum in xml_enums:
|
||||
if xml_enum.get('deprecated') == 'true':
|
||||
continue
|
||||
e = {}
|
||||
e['enum_name'] = strip_leading_linphone(xml_enum.get('name'))
|
||||
e['enum_doc'] = self.__format_doc_content(xml_enum.find('briefdescription'), xml_enum.find('detaileddescription'))
|
||||
|
|
@ -1008,8 +1014,6 @@ class LinphoneModule(object):
|
|||
e['enum_deprecated_values'] = []
|
||||
xml_enum_values = xml_enum.findall("./values/value")
|
||||
for xml_enum_value in xml_enum_values:
|
||||
if xml_enum_value.get('deprecated') == 'true':
|
||||
continue
|
||||
v = {}
|
||||
v['enum_value_cname'] = xml_enum_value.get('name')
|
||||
valname = strip_leading_linphone(v['enum_value_cname'])
|
||||
|
|
@ -1031,8 +1035,6 @@ class LinphoneModule(object):
|
|||
self.classes = []
|
||||
xml_classes = tree.findall("./classes/class")
|
||||
for xml_class in xml_classes:
|
||||
if xml_class.get('deprecated') == 'true':
|
||||
continue
|
||||
if xml_class.get('name') in blacklisted_classes:
|
||||
continue
|
||||
c = {}
|
||||
|
|
@ -1056,8 +1058,6 @@ class LinphoneModule(object):
|
|||
c['class_object_members_code'] = "\tPyObject *vtable_dict;"
|
||||
xml_events = xml_class.findall("./events/event")
|
||||
for xml_event in xml_events:
|
||||
if xml_event.get('deprecated') == 'true':
|
||||
continue
|
||||
if xml_event.get('name') in blacklisted_events:
|
||||
continue
|
||||
ev = {}
|
||||
|
|
@ -1101,8 +1101,6 @@ class LinphoneModule(object):
|
|||
c['class_hand_written_properties'].append(p)
|
||||
xml_type_methods = xml_class.findall("./classmethods/classmethod")
|
||||
for xml_type_method in xml_type_methods:
|
||||
if xml_type_method.get('deprecated') == 'true':
|
||||
continue
|
||||
method_name = xml_type_method.get('name')
|
||||
if method_name in blacklisted_functions:
|
||||
continue
|
||||
|
|
@ -1115,8 +1113,6 @@ class LinphoneModule(object):
|
|||
c['class_instance_methods'] = []
|
||||
xml_instance_methods = xml_class.findall("./instancemethods/instancemethod")
|
||||
for xml_instance_method in xml_instance_methods:
|
||||
if xml_instance_method.get('deprecated') == 'true':
|
||||
continue
|
||||
method_name = xml_instance_method.get('name')
|
||||
if method_name in blacklisted_functions:
|
||||
continue
|
||||
|
|
@ -1141,10 +1137,10 @@ class LinphoneModule(object):
|
|||
xml_property_getter = xml_property.find("./getter")
|
||||
xml_property_setter = xml_property.find("./setter")
|
||||
if xml_property_getter is not None:
|
||||
if xml_property_getter.get('name') in blacklisted_functions or xml_property_getter.get('name') in hand_written_functions or xml_property_getter.get('deprecated') == 'true':
|
||||
if xml_property_getter.get('name') in blacklisted_functions or xml_property_getter.get('name') in hand_written_functions:
|
||||
continue
|
||||
if xml_property_setter is not None:
|
||||
if xml_property_setter.get('name') in blacklisted_functions or xml_property_setter.get('name') in hand_written_functions or xml_property_setter.get('deprecated') == 'true':
|
||||
if xml_property_setter.get('name') in blacklisted_functions or xml_property_setter.get('name') in hand_written_functions:
|
||||
continue
|
||||
if xml_property_getter is not None:
|
||||
xml_property_getter.set('property_name', property_name)
|
||||
|
|
@ -1170,11 +1166,11 @@ class LinphoneModule(object):
|
|||
self.classes.append(c)
|
||||
# Format events definitions
|
||||
for ev in self.core_events:
|
||||
ev['event_callback_definition'] = EventCallbackMethodDefinition(self, ev, ev['event_xml_node']).format()
|
||||
ev['event_callback_definition'] = EventCallbackMethodDefinition(self, ev, ev['event_name'], ev['event_xml_node']).format()
|
||||
ev['event_vtable_reference'] = "_vtable.{name} = pylinphone_Core_callback_{name};".format(name=ev['event_name'])
|
||||
for c in self.classes:
|
||||
for ev in c['class_events']:
|
||||
ev['event_callback_definition'] = EventCallbackMethodDefinition(self, ev, ev['event_xml_node']).format()
|
||||
ev['event_callback_definition'] = EventCallbackMethodDefinition(self, ev, ev['event_name'], ev['event_xml_node']).format()
|
||||
# Format methods' bodies
|
||||
for c in self.classes:
|
||||
xml_new_method = c['class_xml_node'].find("./classmethods/classmethod[@name='" + c['class_c_function_prefix'] + "new']")
|
||||
|
|
@ -1195,10 +1191,10 @@ class LinphoneModule(object):
|
|||
raise
|
||||
try:
|
||||
for m in c['class_type_methods']:
|
||||
m['method_body'] = MethodDefinition(self, c, m['method_xml_node']).format()
|
||||
m['method_body'] = MethodDefinition(self, c, m['method_name'], m['method_xml_node']).format()
|
||||
m['method_doc'] = self.__format_method_doc(m['method_xml_node'])
|
||||
for m in c['class_instance_methods']:
|
||||
m['method_body'] = MethodDefinition(self, c, m['method_xml_node']).format()
|
||||
m['method_body'] = MethodDefinition(self, c, m['method_name'], m['method_xml_node']).format()
|
||||
m['method_doc'] = self.__format_method_doc(m['method_xml_node'])
|
||||
except Exception, e:
|
||||
e.args += (c['class_name'], m['method_name'])
|
||||
|
|
@ -1207,10 +1203,10 @@ class LinphoneModule(object):
|
|||
for p in c['class_properties']:
|
||||
p['property_doc'] = ''
|
||||
if p.has_key('setter_xml_node'):
|
||||
p['setter_body'] = SetterMethodDefinition(self, c, p['setter_xml_node']).format()
|
||||
p['setter_body'] = SetterMethodDefinition(self, c, p['property_name'], p['setter_xml_node']).format()
|
||||
p['property_doc'] = self.__format_setter_doc(p['setter_xml_node'])
|
||||
if p.has_key('getter_xml_node'):
|
||||
p['getter_body'] = GetterMethodDefinition(self, c, p['getter_xml_node']).format()
|
||||
p['getter_body'] = GetterMethodDefinition(self, c, p['property_name'], p['getter_xml_node']).format()
|
||||
if p['property_doc'] == '':
|
||||
p['property_doc'] = self.__format_getter_doc(p['getter_xml_node'])
|
||||
except Exception, e:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue