diff --git a/tools/python/apixml2python.py b/tools/python/apixml2python.py index 5b6876a34..dd37e2027 100755 --- a/tools/python/apixml2python.py +++ b/tools/python/apixml2python.py @@ -63,7 +63,6 @@ blacklisted_functions = [ 'linphone_core_get_sip_transports_used', # missing LCSipTransports 'linphone_core_get_supported_video_sizes', # missing MSVideoSizeDef 'linphone_core_get_video_codecs', # missing PayloadType and MSList - 'linphone_core_get_video_devices', # returns a list of strings 'linphone_core_get_video_policy', # missing LinphoneVideoPolicy 'linphone_core_get_video_port_range', # to be handwritten because of result via arguments 'linphone_core_publish', # missing LinphoneContent @@ -94,6 +93,7 @@ blacklisted_functions = [ ] hand_written_functions = [ 'linphone_chat_room_send_message2', + 'linphone_core_get_video_devices', 'linphone_core_new', 'linphone_core_new_with_config' ] diff --git a/tools/python/apixml2python/handwritten_declarations.mustache b/tools/python/apixml2python/handwritten_declarations.mustache index 1d27b9963..4a50a848b 100644 --- a/tools/python/apixml2python/handwritten_declarations.mustache +++ b/tools/python/apixml2python/handwritten_declarations.mustache @@ -1,3 +1,5 @@ +static PyObject * pylinphone_Core_get_video_devices(PyObject *self, void *closure); + static PyTypeObject pylinphone_VideoSizeType; typedef struct { diff --git a/tools/python/apixml2python/handwritten_definitions.mustache b/tools/python/apixml2python/handwritten_definitions.mustache index 30ceb33c7..b3d043c32 100644 --- a/tools/python/apixml2python/handwritten_definitions.mustache +++ b/tools/python/apixml2python/handwritten_definitions.mustache @@ -114,6 +114,33 @@ static PyObject * pylinphone_module_method_set_log_handler(PyObject *self, PyObj Py_RETURN_NONE; } + +static PyObject * pylinphone_Core_get_video_devices(PyObject *self, void *closure) { + PyObject *_list; + char **_devices; + char *_device; + LinphoneCore *native_ptr = pylinphone_Core_get_native_ptr(self); + + if (native_ptr == NULL) { + PyErr_SetString(PyExc_TypeError, "Invalid linphone.Core instance"); + return NULL; + } + + pylinphone_trace(1, "[PYLINPHONE] >>> %s(%p [%p])", __FUNCTION__, self, native_ptr); + _devices = linphone_core_get_video_devices(native_ptr); + pylinphone_dispatch_messages(); + + _list = PyList_New(0); + while (*_devices != NULL) { + PyObject *_item = PyString_FromString(*_devices); + PyList_Append(_list, _item); + _devices++; + } + + pylinphone_trace(-1, "[PYLINPHONE] <<< %s -> %p", __FUNCTION__, _list); + return _list; +} + static PyObject * pylinphone_Core_class_method_new(PyObject *cls, PyObject *args) { LinphoneCore * cresult; pylinphone_CoreObject *self; diff --git a/tools/python/apixml2python/linphone.py b/tools/python/apixml2python/linphone.py index 884576a93..38253fd94 100644 --- a/tools/python/apixml2python/linphone.py +++ b/tools/python/apixml2python/linphone.py @@ -734,6 +734,7 @@ class LinphoneModule(object): c['class_type_methods'] = [] c['class_type_hand_written_methods'] = [] c['class_instance_hand_written_methods'] = [] + c['class_hand_written_properties'] = [] c['class_object_members'] = '' if c['class_name'] == 'Core': c['class_object_members'] = "\tPyObject *vtable_dict;" @@ -792,31 +793,45 @@ class LinphoneModule(object): p['property_name'] = property_name xml_property_getter = xml_property.find("./getter") xml_property_setter = xml_property.find("./setter") - if xml_property_getter is not None and ( - xml_property_getter.get('name') in blacklisted_functions or xml_property_getter.get('deprecated') == 'true'): - continue - if xml_property_setter is not None and ( - xml_property_setter.get('name') in blacklisted_functions or xml_property_setter.get('deprecated') == 'true'): - continue + handwritten_property = False if xml_property_getter is not None: - xml_property_getter.set('property_name', property_name) - p['getter_name'] = xml_property_getter.get('name').replace(c['class_c_function_prefix'], '') - p['getter_xml_node'] = xml_property_getter - p['getter_reference'] = "(getter)pylinphone_" + c['class_name'] + "_" + p['getter_name'] - p['getter_definition_begin'] = "static PyObject * pylinphone_" + c['class_name'] + "_" + p['getter_name'] + "(PyObject *self, void *closure) {" - p['getter_definition_end'] = "}" - else: - p['getter_reference'] = "NULL" + if xml_property_getter.get('name') in blacklisted_functions or xml_property_getter.get('deprecated') == 'true': + continue + elif xml_property_getter.get('name') in hand_written_functions: + handwritten_property = True if xml_property_setter is not None: - xml_property_setter.set('property_name', property_name) - p['setter_name'] = xml_property_setter.get('name').replace(c['class_c_function_prefix'], '') - p['setter_xml_node'] = xml_property_setter - p['setter_reference'] = "(setter)pylinphone_" + c['class_name'] + "_" + p['setter_name'] - p['setter_definition_begin'] = "static int pylinphone_" + c['class_name'] + "_" + p['setter_name'] + "(PyObject *self, PyObject *value, void *closure) {" - p['setter_definition_end'] = "}" + if xml_property_setter.get('name') in blacklisted_functions or xml_property_setter.get('deprecated') == 'true': + continue + elif xml_property_setter.get('name') in hand_written_functions: + handwritten_property = True + if handwritten_property: + p['getter_reference'] = 'NULL' + p['setter_reference'] = 'NULL' + if xml_property_getter is not None: + p['getter_reference'] = '(getter)pylinphone_' + c['class_name'] + '_get_' + p['property_name'] + if xml_property_setter is not None: + p['setter_reference'] = '(setter)pylinphone_' + c['class_name'] + '_set_' + p['property_name'] + c['class_hand_written_properties'].append(p) else: - p['setter_reference'] = "NULL" - c['class_properties'].append(p) + if xml_property_getter is not None: + xml_property_getter.set('property_name', property_name) + p['getter_name'] = xml_property_getter.get('name').replace(c['class_c_function_prefix'], '') + p['getter_xml_node'] = xml_property_getter + p['getter_reference'] = "(getter)pylinphone_" + c['class_name'] + "_" + p['getter_name'] + p['getter_definition_begin'] = "static PyObject * pylinphone_" + c['class_name'] + "_" + p['getter_name'] + "(PyObject *self, void *closure) {" + p['getter_definition_end'] = "}" + else: + p['getter_reference'] = "NULL" + if xml_property_setter is not None: + xml_property_setter.set('property_name', property_name) + p['setter_name'] = xml_property_setter.get('name').replace(c['class_c_function_prefix'], '') + p['setter_xml_node'] = xml_property_setter + p['setter_reference'] = "(setter)pylinphone_" + c['class_name'] + "_" + p['setter_name'] + p['setter_definition_begin'] = "static int pylinphone_" + c['class_name'] + "_" + p['setter_name'] + "(PyObject *self, PyObject *value, void *closure) {" + p['setter_definition_end'] = "}" + else: + p['setter_reference'] = "NULL" + c['class_properties'].append(p) self.classes.append(c) # Format events definitions for ev in self.events: diff --git a/tools/python/apixml2python/linphone_module.mustache b/tools/python/apixml2python/linphone_module.mustache index 02f1920ac..005f05edb 100644 --- a/tools/python/apixml2python/linphone_module.mustache +++ b/tools/python/apixml2python/linphone_module.mustache @@ -139,6 +139,9 @@ static PyMethodDef pylinphone_{{class_name}}_methods[] = { {{/class_properties}} static PyGetSetDef pylinphone_{{class_name}}_getseters[] = { +{{#class_hand_written_properties}} + { "{{property_name}}", {{getter_reference}}, {{setter_reference}}, "" }, +{{/class_hand_written_properties}} {{#class_properties}} { "{{property_name}}", {{getter_reference}}, {{setter_reference}}, "{{{property_doc}}}" }, {{/class_properties}}