mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Support build of Python module for Python 3.
This commit is contained in:
parent
74a3277084
commit
d9932c3e66
7 changed files with 156 additions and 74 deletions
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
import argparse
|
||||
import os
|
||||
import six
|
||||
import string
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
|
@ -399,7 +400,7 @@ class Project:
|
|||
def __parseCStructMember(self, node, structname):
|
||||
name = node.find('./name').text
|
||||
definition = node.find('./definition').text
|
||||
t = definition[0:string.find(definition, structname + "::" + name)]
|
||||
t = definition[0:definition.find(structname + "::" + name)]
|
||||
sm = CStructMember(name, t)
|
||||
deprecatedNode = node.find(".//xrefsect[xreftitle='Deprecated']")
|
||||
if deprecatedNode is not None:
|
||||
|
|
@ -433,7 +434,7 @@ class Project:
|
|||
if definition.startswith('typedef '):
|
||||
definition = definition[8 :]
|
||||
if name.endswith('Cb'):
|
||||
pos = string.find(definition, "(*")
|
||||
pos = definition.find("(*")
|
||||
if pos == -1:
|
||||
return None
|
||||
returntype = definition[0:pos].strip()
|
||||
|
|
@ -448,13 +449,13 @@ class Project:
|
|||
elif returnarg.completeType != 'void':
|
||||
missingDocWarning += "\tReturn value is not documented\n"
|
||||
definition = definition[pos + 2 :]
|
||||
pos = string.find(definition, "(")
|
||||
pos = definition.find("(")
|
||||
definition = definition[pos + 1 : -1]
|
||||
argslist = CArgumentsList()
|
||||
for argdef in definition.split(', '):
|
||||
argType = ''
|
||||
starPos = string.rfind(argdef, '*')
|
||||
spacePos = string.rfind(argdef, ' ')
|
||||
starPos = argdef.rfind('*')
|
||||
spacePos = argdef.rfind(' ')
|
||||
if starPos != -1:
|
||||
argType = argdef[0 : starPos + 1]
|
||||
argName = argdef[starPos + 1 :]
|
||||
|
|
@ -483,7 +484,7 @@ class Project:
|
|||
f.detailedDescription = self.__cleanDescription(node.find('./detaileddescription'))
|
||||
return f
|
||||
else:
|
||||
pos = string.rfind(definition, " " + name)
|
||||
pos = definition.rfind(" " + name)
|
||||
if pos != -1:
|
||||
definition = definition[0 : pos]
|
||||
td = CTypedef(name, definition)
|
||||
|
|
@ -595,7 +596,7 @@ class Project:
|
|||
|
||||
def check(self):
|
||||
for c in self.classes:
|
||||
for name, p in c.properties.iteritems():
|
||||
for name, p in six.iteritems(c.properties):
|
||||
if p.getter is None and p.setter is not None:
|
||||
print("Property '" + name + "' of class '" + c.name + "' has a setter but no getter")
|
||||
|
||||
|
|
@ -734,7 +735,7 @@ class Generator:
|
|||
project.classes.sort(key = lambda c: c.name)
|
||||
for cclass in project.classes:
|
||||
self.__generateClass(cclass, classesNode)
|
||||
s = '<?xml version="1.0" encoding="UTF-8" ?>\n'
|
||||
s = '<?xml version="1.0" encoding="UTF-8" ?>\n'.encode('utf-8')
|
||||
s += ET.tostring(apiNode, 'utf-8')
|
||||
if project.prettyPrint:
|
||||
s = minidom.parseString(s).toprettyxml(indent='\t')
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ typedef struct {
|
|||
LCSipTransports lcst;
|
||||
} pylinphone_SipTransportsObject;
|
||||
|
||||
static bctbx_list_t * pylinphone_bctbx_list_free(bctbx_list_t * elem);
|
||||
PyObject * PyList_FromBctbxListOfString(const bctbx_list_t *msl);
|
||||
bctbx_list_t * PyList_AsBctbxListOfString(PyObject *pyl);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
static bctbx_list_t * pylinphone_bctbx_list_free(bctbx_list_t * elem) {
|
||||
return bctbx_list_free_with_data(elem, bctbx_free);
|
||||
}
|
||||
|
||||
PyObject * PyList_FromBctbxListOfString(const bctbx_list_t *msl) {
|
||||
PyObject *pyl = PyList_New(0);
|
||||
while (msl != NULL) {
|
||||
|
|
@ -15,6 +19,7 @@ bctbx_list_t * PyList_AsBctbxListOfString(PyObject *pyl) {
|
|||
for (idx = 0; idx < size; idx++) {
|
||||
PyObject *item = PyList_GetItem(pyl, idx);
|
||||
char *citem = (char *)PyString_AsString(item);
|
||||
if (citem != NULL) citem = bctbx_strdup_printf(citem);
|
||||
msl = bctbx_list_append(msl, citem);
|
||||
}
|
||||
return msl;
|
||||
|
|
@ -562,8 +567,7 @@ static PyMemberDef pylinphone_VideoSize_members[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject pylinphone_VideoSizeType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"linphone.VideoSize", /* tp_name */
|
||||
sizeof(pylinphone_VideoSizeObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
@ -680,8 +684,7 @@ static PyMemberDef pylinphone_SipTransports_members[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject pylinphone_SipTransportsType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"linphone.SipTransports", /* tp_name */
|
||||
sizeof(pylinphone_SipTransportsObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
|
||||
import re
|
||||
from sets import Set
|
||||
import six
|
||||
import sys
|
||||
|
||||
|
||||
|
|
@ -35,7 +35,9 @@ def remove_useless_enum_prefix(senum, svalue):
|
|||
i = 0
|
||||
while i < len(lenum) and lenum[i] == lvalue[i]:
|
||||
i += 1
|
||||
return ''.join(lvalue[i:])
|
||||
svalue = ''.join(lvalue[i:])
|
||||
if svalue == "None":
|
||||
return "_None"
|
||||
return svalue
|
||||
|
||||
def is_callback(s):
|
||||
|
|
@ -238,7 +240,7 @@ class ArgumentType:
|
|||
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.free_convert_result_func = "pylinphone_bctbx_list_free"
|
||||
self.check_condition = "!PyList_Check({arg_name})"
|
||||
self.fmt_str = 'O'
|
||||
self.cfmt_str = '%p'
|
||||
|
|
@ -1043,7 +1045,7 @@ class LinphoneModule(object):
|
|||
self.known_types = ['char', 'int', 'int8_t', 'int16_t', 'int32_t', 'int64_t', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'bool_t', 'float', 'double', 'size_t', 'time_t', 'MSList', 'bctbx_list_t', 'MSVideoSize', 'LCSipTransports', 'PayloadType']
|
||||
self.internal_instance_method_names = ['destroy', 'ref', 'unref']
|
||||
self.internal_property_names = ['user_data']
|
||||
self.bctbxlist_types = Set([])
|
||||
self.bctbxlist_types = set([])
|
||||
self.enums = []
|
||||
self.enum_names = []
|
||||
self.cfunction2methodmap = {}
|
||||
|
|
@ -1084,6 +1086,7 @@ class LinphoneModule(object):
|
|||
v['enum_value_doc'] = self.__format_doc(xml_enum_value.find('briefdescription'), xml_enum_value.find('detaileddescription'))
|
||||
e['enum_deprecated_values'].append(v)
|
||||
e['enum_doc'] = self.__replace_doc_special_chars(e['enum_doc'])
|
||||
e['enum_doc'] = e['enum_doc'].encode('unicode_escape')
|
||||
self.enums.append(e)
|
||||
self.enum_names.append(e['enum_name'])
|
||||
self.known_types.append(e['enum_cname'])
|
||||
|
|
@ -1099,6 +1102,7 @@ class LinphoneModule(object):
|
|||
c['class_name'] = strip_leading_linphone(c['class_cname'])
|
||||
c['class_c_function_prefix'] = xml_class.get('cfunctionprefix')
|
||||
c['class_doc'] = self.__format_doc(xml_class.find('briefdescription'), xml_class.find('detaileddescription'))
|
||||
c['class_doc'] = c['class_doc'].encode('unicode_escape')
|
||||
c['class_refcountable'] = (xml_class.get('refcountable') == 'true')
|
||||
c['class_destroyable'] = (xml_class.get('destroyable') == 'true')
|
||||
c['class_has_user_data'] = False
|
||||
|
|
@ -1119,6 +1123,7 @@ class LinphoneModule(object):
|
|||
ev['event_cname'] = xml_event.get('name')
|
||||
ev['event_name'] = compute_event_name(ev['event_cname'], c['class_name'])
|
||||
ev['event_doc'] = self.__format_doc(xml_event.find('briefdescription'), xml_event.find('detaileddescription'))
|
||||
ev['event_doc'] = ev['event_doc'].encode('unicode_escape')
|
||||
c['class_events'].append(ev)
|
||||
self.known_types.append(ev['event_cname'])
|
||||
c['class_object_members'].append(ev['event_name'])
|
||||
|
|
@ -1129,11 +1134,13 @@ class LinphoneModule(object):
|
|||
m = {}
|
||||
m['method_name'] = hand_written_code.name
|
||||
m['method_doc'] = self.__replace_doc_special_chars(hand_written_code.doc)
|
||||
m['method_doc'] = m['method_doc'].encode('unicode_escape')
|
||||
c['class_type_hand_written_methods'].append(m)
|
||||
elif isinstance(hand_written_code, HandWrittenInstanceMethod):
|
||||
m = {}
|
||||
m['method_name'] = hand_written_code.name
|
||||
m['method_doc'] = self.__replace_doc_special_chars(hand_written_code.doc)
|
||||
m['method_doc'] = m['method_doc'].encode('unicode_escape')
|
||||
c['class_instance_hand_written_methods'].append(m)
|
||||
elif isinstance(hand_written_code, HandWrittenDeallocMethod):
|
||||
c['class_has_hand_written_dealloc'] = True
|
||||
|
|
@ -1149,6 +1156,7 @@ class LinphoneModule(object):
|
|||
else:
|
||||
p['setter_reference'] = '(setter)pylinphone_' + c['class_name'] + '_set_' + p['property_name']
|
||||
p['property_doc'] = self.__replace_doc_special_chars(hand_written_code.doc)
|
||||
p['property_doc'] = p['property_doc'].encode('unicode_escape')
|
||||
c['class_hand_written_properties'].append(p)
|
||||
xml_type_methods = xml_class.findall("./classmethods/classmethod")
|
||||
for xml_type_method in xml_type_methods:
|
||||
|
|
@ -1225,71 +1233,74 @@ class LinphoneModule(object):
|
|||
xml_new_method = c['class_xml_node'].find("./classmethods/classmethod[@name='" + c['class_c_function_prefix'] + "new']")
|
||||
try:
|
||||
c['new_body'] = NewMethodDefinition(self, c, xml_new_method).format()
|
||||
except UnknownTypeException, e:
|
||||
except (UnknownTypeException) as e:
|
||||
print(e)
|
||||
c['blacklisted'] = True
|
||||
except Exception, e:
|
||||
except (Exception) as e:
|
||||
e.args += (c['class_name'], 'new_body')
|
||||
raise
|
||||
try:
|
||||
c['init_body'] = InitMethodDefinition(self, c, xml_new_method).format()
|
||||
except UnknownTypeException, e:
|
||||
except (UnknownTypeException) as e:
|
||||
print(e)
|
||||
c['blacklisted'] = True
|
||||
except Exception, e:
|
||||
except (Exception) as e:
|
||||
e.args += (c['class_name'], 'init_body')
|
||||
raise
|
||||
try:
|
||||
c['from_native_pointer_body'] = FromNativePointerMethodDefinition(self, c).format()
|
||||
except UnknownTypeException, e:
|
||||
except (UnknownTypeException) as e:
|
||||
print(e)
|
||||
c['blacklisted'] = True
|
||||
except Exception, e:
|
||||
except (Exception) as e:
|
||||
e.args += (c['class_name'], 'from_native_pointer_body')
|
||||
raise
|
||||
for m in c['class_type_methods']:
|
||||
try:
|
||||
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 UnknownTypeException, e:
|
||||
m['method_doc'] = m['method_doc'].encode('unicode_escape')
|
||||
except (UnknownTypeException) as e:
|
||||
print(e)
|
||||
m['blacklisted'] = True
|
||||
except Exception, e:
|
||||
except (Exception) as e:
|
||||
e.args += (c['class_name'], m['method_name'])
|
||||
raise
|
||||
for m in c['class_instance_methods']:
|
||||
try:
|
||||
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 UnknownTypeException, e:
|
||||
m['method_doc'] = m['method_doc'].encode('unicode_escape')
|
||||
except (UnknownTypeException) as e:
|
||||
print(e)
|
||||
m['blacklisted'] = True
|
||||
except Exception, e:
|
||||
except (Exception) as e:
|
||||
e.args += (c['class_name'], m['method_name'])
|
||||
raise
|
||||
for p in c['class_properties']:
|
||||
p['property_doc'] = ''
|
||||
if p.has_key('setter_xml_node'):
|
||||
if 'setter_xml_node' in p:
|
||||
try:
|
||||
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'])
|
||||
except UnknownTypeException, e:
|
||||
except (UnknownTypeException) as e:
|
||||
print(e)
|
||||
p['blacklisted'] = True
|
||||
except Exception, e:
|
||||
except (Exception) as e:
|
||||
e.args += (c['class_name'], p['property_name'])
|
||||
raise
|
||||
if p.has_key('getter_xml_node'):
|
||||
if 'getter_xml_node' in p:
|
||||
try:
|
||||
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 UnknownTypeException, e:
|
||||
except (UnknownTypeException) as e:
|
||||
print(e)
|
||||
p['blacklisted'] = True
|
||||
except Exception, e:
|
||||
except (Exception) as e:
|
||||
e.args += (c['class_name'], p['property_name'])
|
||||
raise
|
||||
p['property_doc'] = p['property_doc'].encode('unicode_escape')
|
||||
if not 'class_has_hand_written_dealloc' in c:
|
||||
try:
|
||||
if c['class_refcountable']:
|
||||
|
|
@ -1300,18 +1311,18 @@ class LinphoneModule(object):
|
|||
c['dealloc_definition'] = DeallocMethodDefinition(self, c, xml_instance_method).format()
|
||||
else:
|
||||
c['dealloc_definition'] = DeallocMethodDefinition(self, c).format()
|
||||
except UnknownTypeException, e:
|
||||
except (UnknownTypeException) as e:
|
||||
print(e)
|
||||
c['blacklisted'] = True
|
||||
except Exception, e:
|
||||
except (Exception) as e:
|
||||
e.args += (c['class_name'], 'dealloc_body')
|
||||
raise
|
||||
# Remove blacklisted classes and methods
|
||||
self.classes = [c for c in self.classes if not c.has_key('blacklisted')]
|
||||
self.classes = [c for c in self.classes if not 'blacklisted' in c]
|
||||
for c in self.classes:
|
||||
c['class_type_methods'] = [m for m in c['class_type_methods'] if not m.has_key('blacklisted')]
|
||||
c['class_instance_methods'] = [m for m in c['class_instance_methods'] if not m.has_key('blacklisted')]
|
||||
c['class_properties'] = [m for m in c['class_properties'] if not m.has_key('blacklisted')]
|
||||
c['class_type_methods'] = [m for m in c['class_type_methods'] if not 'blacklisted' in m]
|
||||
c['class_instance_methods'] = [m for m in c['class_instance_methods'] if not 'blacklisted' in m]
|
||||
c['class_properties'] = [m for m in c['class_properties'] if not 'blacklisted' in m]
|
||||
# Convert bctbxlist_types to a list of dictionaries for the template
|
||||
d = []
|
||||
for bctbxlist_type in self.bctbxlist_types:
|
||||
|
|
@ -1365,12 +1376,12 @@ class LinphoneModule(object):
|
|||
return doc
|
||||
|
||||
def __replace_doc_special_chars(self, doc):
|
||||
return doc.replace('"', '').encode('string-escape')
|
||||
return doc.replace('"', '') #.encode('utf-8') #.encode('unicode_escape')
|
||||
|
||||
def __replace_doc_cfunction_by_method(self, doc):
|
||||
for cfunction, method in self.cfunction2methodmap.iteritems():
|
||||
for cfunction, method in six.iteritems(self.cfunction2methodmap):
|
||||
doc = doc.replace(cfunction + '()', method)
|
||||
for cfunction, method in self.cfunction2methodmap.iteritems():
|
||||
for cfunction, method in six.iteritems(self.cfunction2methodmap):
|
||||
doc = doc.replace(cfunction, method)
|
||||
return doc
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,57 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#define PYLINPHONE_INLINE inline
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Definitions for Python 2 and 3 support.
|
||||
*/
|
||||
|
||||
#ifndef PyVarObject_HEAD_INIT
|
||||
#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
|
||||
#endif
|
||||
|
||||
#ifndef PyInt_Check
|
||||
#define PyInt_Check(p) PyLong_Check(p)
|
||||
#endif
|
||||
|
||||
#ifndef PyInt_AsLong
|
||||
#define PyInt_AsLong(io) PyLong_AsLong(io)
|
||||
#endif
|
||||
|
||||
#ifndef PyInt_AS_LONG
|
||||
static int pylinphone_aslongoverflow;
|
||||
#define PyInt_AS_LONG(io) PyLong_AsLongAndOverflow(io, &pylinphone_aslongoverflow)
|
||||
#endif
|
||||
|
||||
#ifndef PyInt_AsSsize_t
|
||||
#define PyInt_AsSsize_t(io) PyLong_AsSsize_t(io)
|
||||
#endif
|
||||
|
||||
#ifndef PyInt_AsUnsignedLongMask
|
||||
#define PyInt_AsUnsignedLongMask(io) PyLong_AsUnsignedLongMask(io)
|
||||
#endif
|
||||
|
||||
#ifndef PyString_Check
|
||||
#define PyString_Check(io) PyUnicode_Check(io)
|
||||
#endif
|
||||
|
||||
#ifndef PyString_FromString
|
||||
#define PyString_FromString(v) PyUnicode_FromString(v)
|
||||
#endif
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
#define PyString_AsString(s) PyUnicode_AsUTF8(s)
|
||||
#endif
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
#define MOD_DEF(ob, name, methods, doc) \
|
||||
static struct PyModuleDef moduledef_##ob = { \
|
||||
PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \
|
||||
ob = PyModule_Create(&moduledef_##ob);
|
||||
#else
|
||||
#define MOD_DEF(ob, name, methods, doc) \
|
||||
ob = Py_InitModule3(name, methods, doc);
|
||||
#endif
|
||||
|
||||
|
||||
static void pylinphone_dispatch_messages(void);
|
||||
static PYLINPHONE_INLINE void pylinphone_trace(int indent, const char *fmt, ...);
|
||||
|
|
@ -193,8 +244,7 @@ static PyGetSetDef pylinphone_{{class_name}}_getseters[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject pylinphone_{{class_name}}Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"linphone.{{class_name}}", /* tp_name */
|
||||
sizeof(pylinphone_{{class_name}}Object), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
@ -280,54 +330,57 @@ static PyMethodDef pylinphone_{{enum_name}}_ModuleMethods[] = {
|
|||
|
||||
{{> linphone_testing_module}}
|
||||
|
||||
PyMODINIT_FUNC initlinphone(void) {
|
||||
static PyObject * pylinphone_moduleinit(void) {
|
||||
PyObject *m;
|
||||
PyObject *menum;
|
||||
PyObject *menum_PayloadType;
|
||||
|
||||
PyDateTime_IMPORT;
|
||||
PyEval_InitThreads();
|
||||
pylinphone_init_logging();
|
||||
|
||||
{{#classes}}
|
||||
if (PyType_Ready(&pylinphone_{{class_name}}Type) < 0) return;
|
||||
if (PyType_Ready(&pylinphone_{{class_name}}Type) < 0) return NULL;
|
||||
{{/classes}}
|
||||
|
||||
/* Hand-written classes. */
|
||||
if (PyType_Ready(&pylinphone_VideoSizeType) < 0) return;
|
||||
if (PyType_Ready(&pylinphone_SipTransportsType) < 0) return;
|
||||
if (PyType_Ready(&pylinphone_VideoSizeType) < 0) return NULL;
|
||||
if (PyType_Ready(&pylinphone_SipTransportsType) < 0) return NULL;
|
||||
|
||||
m = Py_InitModule3("linphone", pylinphone_ModuleMethods, "Python module giving access to the Linphone library.");
|
||||
if (m == NULL) return;
|
||||
if (PyModule_AddStringConstant(m, "__version__", LINPHONE_GIT_REVISION) < 0) return;
|
||||
MOD_DEF(m, "linphone", pylinphone_ModuleMethods, "Python module giving access to the Linphone library.");
|
||||
if (m == NULL) return NULL;
|
||||
if (PyModule_AddStringConstant(m, "__version__", LINPHONE_GIT_REVISION) < 0) return NULL;
|
||||
|
||||
{{#enums}}
|
||||
menum = Py_InitModule3("{{enum_name}}", pylinphone_{{enum_name}}_ModuleMethods, "{{{enum_doc}}}");
|
||||
if (menum == NULL) return;
|
||||
Py_INCREF(menum);
|
||||
if (PyModule_AddObject(m, "{{enum_name}}", menum) < 0) return;
|
||||
{
|
||||
PyObject *menum_{{enum_name}};
|
||||
MOD_DEF(menum_{{enum_name}}, "{{enum_name}}", pylinphone_{{enum_name}}_ModuleMethods, "{{{enum_doc}}}");
|
||||
if (menum_{{enum_name}} == NULL) return NULL;
|
||||
Py_INCREF(menum_{{enum_name}});
|
||||
if (PyModule_AddObject(m, "{{enum_name}}", menum_{{enum_name}}) < 0) return NULL;
|
||||
{{#enum_values}}
|
||||
if (PyModule_AddIntConstant(menum, "{{enum_value_name}}", {{enum_value_cname}}) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum_{{enum_name}}, "{{enum_value_name}}", {{enum_value_cname}}) < 0) return NULL;
|
||||
{{/enum_values}}
|
||||
{{#enum_deprecated_values}}
|
||||
if (PyModule_AddIntConstant(menum, "{{enum_value_name}}", {{enum_value_cname}}) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum_{{enum_name}}, "{{enum_value_name}}", {{enum_value_cname}}) < 0) return NULL;
|
||||
{{/enum_deprecated_values}}
|
||||
}
|
||||
{{/enums}}
|
||||
|
||||
menum = Py_InitModule3("PayloadTypeType", pylinphone_PayloadTypeType_ModuleMethods, "Type of :py:class:`linphone.PayloadType`.\n\n.. csv-table::\n :delim: |\n :header: Value,Description\n\n AudioContinuous|\n AudioPacketized|\n Video|\n Text|\n Other|\n");
|
||||
if (menum == NULL) return;
|
||||
Py_INCREF(menum);
|
||||
if (PyModule_AddObject(m, "PayloadTypeType", menum) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum, "AudioContinuous", PAYLOAD_AUDIO_CONTINUOUS) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum, "AudioPacketized", PAYLOAD_AUDIO_PACKETIZED) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum, "Video", PAYLOAD_VIDEO) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum, "Text", PAYLOAD_TEXT) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum, "Other", PAYLOAD_OTHER) < 0) return;
|
||||
MOD_DEF(menum_PayloadType, "PayloadTypeType", pylinphone_PayloadTypeType_ModuleMethods, "Type of :py:class:`linphone.PayloadType`.\n\n.. csv-table::\n :delim: |\n :header: Value,Description\n\n AudioContinuous|\n AudioPacketized|\n Video|\n Text|\n Other|\n");
|
||||
if (menum_PayloadType == NULL) return NULL;
|
||||
Py_INCREF(menum_PayloadType);
|
||||
if (PyModule_AddObject(m, "PayloadTypeType", menum_PayloadType) < 0) return NULL;
|
||||
if (PyModule_AddIntConstant(menum_PayloadType, "AudioContinuous", PAYLOAD_AUDIO_CONTINUOUS) < 0) return NULL;
|
||||
if (PyModule_AddIntConstant(menum_PayloadType, "AudioPacketized", PAYLOAD_AUDIO_PACKETIZED) < 0) return NULL;
|
||||
if (PyModule_AddIntConstant(menum_PayloadType, "Video", PAYLOAD_VIDEO) < 0) return NULL;
|
||||
if (PyModule_AddIntConstant(menum_PayloadType, "Text", PAYLOAD_TEXT) < 0) return NULL;
|
||||
if (PyModule_AddIntConstant(menum_PayloadType, "Other", PAYLOAD_OTHER) < 0) return NULL;
|
||||
// TODO: To remove. Deprecated enum values.
|
||||
if (PyModule_AddIntConstant(menum, "PAYLOAD_AUDIO_CONTINUOUS", PAYLOAD_AUDIO_CONTINUOUS) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum, "PAYLOAD_AUDIO_PACKETIZED", PAYLOAD_AUDIO_PACKETIZED) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum, "PAYLOAD_VIDEO", PAYLOAD_VIDEO) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum, "PAYLOAD_TEXT", PAYLOAD_TEXT) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum, "PAYLOAD_OTHER", PAYLOAD_OTHER) < 0) return;
|
||||
if (PyModule_AddIntConstant(menum_PayloadType, "PAYLOAD_AUDIO_CONTINUOUS", PAYLOAD_AUDIO_CONTINUOUS) < 0) return NULL;
|
||||
if (PyModule_AddIntConstant(menum_PayloadType, "PAYLOAD_AUDIO_PACKETIZED", PAYLOAD_AUDIO_PACKETIZED) < 0) return NULL;
|
||||
if (PyModule_AddIntConstant(menum_PayloadType, "PAYLOAD_VIDEO", PAYLOAD_VIDEO) < 0) return NULL;
|
||||
if (PyModule_AddIntConstant(menum_PayloadType, "PAYLOAD_TEXT", PAYLOAD_TEXT) < 0) return NULL;
|
||||
if (PyModule_AddIntConstant(menum_PayloadType, "PAYLOAD_OTHER", PAYLOAD_OTHER) < 0) return NULL;
|
||||
|
||||
{{#classes}}
|
||||
Py_INCREF(&pylinphone_{{class_name}}Type);
|
||||
|
|
@ -341,4 +394,16 @@ PyMODINIT_FUNC initlinphone(void) {
|
|||
PyModule_AddObject(m, "SipTransports", (PyObject *)&pylinphone_SipTransportsType);
|
||||
|
||||
pylinphone_init_testing_module(m);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
PyMODINIT_FUNC initlinphone(void) {
|
||||
pylinphone_moduleinit();
|
||||
}
|
||||
#else
|
||||
PyMODINIT_FUNC PyInit_linphone(void) {
|
||||
return pylinphone_moduleinit();
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ static PyMethodDef pylinphone_TestingModuleMethods[] = {
|
|||
};
|
||||
|
||||
static void pylinphone_init_testing_module(PyObject *linphone_module) {
|
||||
PyObject *mtesting = Py_InitModule3("testing", pylinphone_TestingModuleMethods, "Python module adding some testing features for the Linphone library.");
|
||||
PyObject *mtesting;
|
||||
MOD_DEF(mtesting, "testing", pylinphone_TestingModuleMethods, "Python module adding some testing features for the Linphone library.");
|
||||
Py_INCREF(mtesting);
|
||||
if (PyModule_AddObject(linphone_module, "testing", mtesting) < 0) return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ class CoreManager:
|
|||
lambda callee_manager, caller_manager: (callee_manager.stats.number_of_LinphoneCallStreamsRunning == initial_callee_stats.number_of_LinphoneCallStreamsRunning + 1) and \
|
||||
(caller_manager.stats.number_of_LinphoneCallStreamsRunning == initial_caller_stats.number_of_LinphoneCallStreamsRunning + 1))
|
||||
|
||||
if caller_manager.lc.media_encryption != linphone.MediaEncryption.MediaEncryptionNone and callee_manager.lc.media_encryption != linphone.MediaEncryption.None:
|
||||
if caller_manager.lc.media_encryption != linphone.MediaEncryption.MediaEncryptionNone and callee_manager.lc.media_encryption != linphone.MediaEncryption._None:
|
||||
# Wait for encryption to be on, in case of zrtp, it can take a few seconds
|
||||
if caller_manager.lc.media_encryption == linphone.MediaEncryption.ZRTP:
|
||||
CoreManager.wait_for(callee_manager, caller_manager,
|
||||
|
|
@ -405,7 +405,7 @@ class CoreManager:
|
|||
manager = lc.user_data()
|
||||
linphonetester_logger.info("[TESTER] New registration state {state} for user id [{identity}] at proxy [{addr}]".format(
|
||||
state=linphone.RegistrationState.string(state), identity=cfg.identity_address.as_string(), addr=cfg.server_addr))
|
||||
if state == linphone.RegistrationState.None:
|
||||
if state == linphone.RegistrationState._None:
|
||||
manager.stats.number_of_LinphoneRegistrationNone += 1
|
||||
elif state == linphone.RegistrationState.Progress:
|
||||
manager.stats.number_of_LinphoneRegistrationProgress += 1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue