diff --git a/tools/python/apixml2python/linphone.py b/tools/python/apixml2python/linphone.py index 1de8e97a2..57127d815 100644 --- a/tools/python/apixml2python/linphone.py +++ b/tools/python/apixml2python/linphone.py @@ -199,20 +199,22 @@ class LinphoneModule(object): xml_enums = tree.findall("./enums/enum") for xml_enum in xml_enums: e = {} - e['enum_name'] = xml_enum.get('name') + e['enum_name'] = self.__strip_leading_linphone(xml_enum.get('name')) e['enum_doc'] = self.__format_doc(xml_enum.find('briefdescription'), xml_enum.find('detaileddescription')) e['enum_values'] = [] xml_enum_values = xml_enum.findall("./values/value") for xml_enum_value in xml_enum_values: v = {} - v['enum_value_name'] = xml_enum_value.get('name') + v['enum_value_cname'] = xml_enum_value.get('name') + v['enum_value_name'] = self.__strip_leading_linphone(v['enum_value_cname']) e['enum_values'].append(v) self.enums.append(e) self.classes = [] xml_classes = tree.findall("./classes/class") for xml_class in xml_classes: c = {} - c['class_name'] = xml_class.get('name') + c['class_cname'] = xml_class.get('name') + c['class_name'] = self.__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_type_methods'] = [] @@ -244,6 +246,12 @@ class LinphoneModule(object): c['class_properties'].append(p) self.classes.append(c) + def __strip_leading_linphone(self, s): + if s.lower().startswith('linphone'): + return s[8:] + else: + return s + def __format_method_body(self, method_node, class_): method = MethodDefinition(method_node, class_) method.format_local_variables_definition() diff --git a/tools/python/apixml2python/linphone_module.mustache b/tools/python/apixml2python/linphone_module.mustache index 90cc78b80..682934031 100644 --- a/tools/python/apixml2python/linphone_module.mustache +++ b/tools/python/apixml2python/linphone_module.mustache @@ -66,14 +66,14 @@ static PyTypeObject pylinphone_{{class_name}}Type; typedef struct { PyObject_HEAD - {{class_name}} *native_ptr; + {{class_cname}} *native_ptr; } pylinphone_{{class_name}}Object; -static {{class_name}} * pylinphone_{{class_name}}_get_native_ptr(pylinphone_{{class_name}}Object *self) { +static {{class_cname}} * pylinphone_{{class_name}}_get_native_ptr(pylinphone_{{class_name}}Object *self) { return self->native_ptr; } -static PyObject * pylinphone_{{class_name}}_new_from_native_ptr(PyTypeObject *type, {{class_name}} *native_ptr) { +static PyObject * pylinphone_{{class_name}}_new_from_native_ptr(PyTypeObject *type, {{class_cname}} *native_ptr) { pylinphone_{{class_name}}Object *self; pylinphone_trace(__FUNCTION__); if (native_ptr == NULL) Py_RETURN_NONE; @@ -217,7 +217,7 @@ PyMODINIT_FUNC initlinphone(void) { if (menum == NULL) return; if (PyModule_AddObject(m, "{{enum_name}}", menum) < 0) return; {{#enum_values}} - if (PyModule_AddIntConstant(menum, "{{enum_value_name}}", {{enum_value_name}}) < 0) return; + if (PyModule_AddIntConstant(menum, "{{enum_value_name}}", {{enum_value_cname}}) < 0) return; {{/enum_values}} {{/enums}}