diff --git a/tools/abstractapi.py b/tools/abstractapi.py index d18df60d25134266e650df50afa0e462123c708a..796ec24d5a9bc3179f5b35c29fc76caa2b177e38 100644 --- a/tools/abstractapi.py +++ b/tools/abstractapi.py @@ -825,7 +825,6 @@ class CParser: try: name = metaname.InterfaceName() name.from_camel_case(cclass.name, namespace=self.namespace.name) - name.words[-1] = 'listener' listener = Interface(name) listener.briefDescription = cclass.briefDoc diff --git a/tools/metadoc.py b/tools/metadoc.py index 155bb54ca45284f0528f224d11b0c013a0dbff8c..ad709f05cf4081bf1b519bac6081b47552a2efa4 100644 --- a/tools/metadoc.py +++ b/tools/metadoc.py @@ -162,7 +162,7 @@ class ClassReference(Reference): return docTranslator.translate_class_reference(self, **kargs) def resolve(self, api): - for index in api.enumsIndex, api.enumeratorsIndex, api.classesIndex: + for index in api.enumsIndex, api.enumeratorsIndex, api.classesIndex, api.interfacesIndex: if self.cname in index: self.relatedObject = index[self.cname] break diff --git a/tools/metaname.py b/tools/metaname.py index 961172d953eaec2b1da55e78aea0c7d4154c7417..2f1fc017d0e143e95e094421a582be891e66176b 100644 --- a/tools/metaname.py +++ b/tools/metaname.py @@ -158,13 +158,6 @@ class ClassName(Name): class InterfaceName(ClassName): - def to_c(self, addBrackets=False): - return ClassName.to_c(self)[:-8] + 'Cbs' - - def from_c(self, **kargs): - ClassName.from_c(self, **kargs) - self.words[-1] = 'listener' - def translate(self, translator, **params): return translator.translate_interface_name(self, **params) @@ -284,6 +277,7 @@ class JavaTranslator(Translator): self.keyWordEscapes = {} self.lowerMethodNames = True self.lowerNamespaceNames = True + self.callbackInterfaceSuffix = 'Listener' @property def classMemberSep(self): @@ -301,7 +295,10 @@ class JavaTranslator(Translator): return name.prev.translate(self, **params) + self._get_separator(name.prev) + name.to_camel_case() def translate_interface_name(self, name, **params): - return self.translate_class_name(name, **params) + translatedName = self.translate_class_name(name, **params) + if translatedName.endswith('Cbs'): + translatedName = translatedName[:-len('Cbs')] + self.callbackInterfaceSuffix + return translatedName def translate_enum_name(self, name, **params): return self.translate_class_name(name, **params) @@ -313,6 +310,8 @@ class JavaTranslator(Translator): translatedName = name.to_camel_case(lower=self.lowerMethodNames) translatedName = self._escape_keyword(translatedName) + if translatedName.endswith('Callbacks'): + translatedName = translatedName[:-len('Callbacks')] + self.callbackInterfaceSuffix if name.prev is None or not recursive or name.prev is topAncestor: return translatedName else: @@ -354,6 +353,7 @@ class SwiftTranslator(JavaTranslator): JavaTranslator.__init__(self) self.nsSep = '.' self.keyWordEscapes = {'protocol' : 'proto'} + self.callbackInterfaceSuffix = 'Delegate' def translate_enum_name(self, name, recursive=False, topAncestor=None): camelCaseName = name.to_camel_case() @@ -368,10 +368,6 @@ class SwiftTranslator(JavaTranslator): enumName = name.prev.translate(self, **params) + self.nsSep + camelCaseName return enumName - def translate_interface_name(self, name, **params): - name = self.translate_class_name(name, **params) - return name[0:len(name)-8] + "Delegate" - def translate_class_name(self, name, recursive=False, topAncestor=None): return name.to_camel_case() @@ -396,5 +392,12 @@ class CSharpTranslator(JavaTranslator): self.lowerMethodNames = False self.lowerNamespaceNames = False + def translate_method_name(self, name, recursive=False, topAncestor=None): + translatedName = JavaTranslator.translate_method_name(self, name, recursive, topAncestor) + subnResult = re.subn('(\.AddCallbacks|\.RemoveCallbacks)', '.SetListener' , translatedName) + if subnResult[1] > 0: + return subnResult[0] + return translatedName + def translate_property_name(self, name): return name.to_camel_case() diff --git a/wrappers/cpp/genwrapper.py b/wrappers/cpp/genwrapper.py index 7398f1429900d53bcd7e57c5e272c7969c93bc89..9fe1ce1a79563035172077e5abec860afd57eecb 100755 --- a/wrappers/cpp/genwrapper.py +++ b/wrappers/cpp/genwrapper.py @@ -105,7 +105,7 @@ class CppTranslator: if method.returnType.cDecl == 'void': classDict['wrapperCbs'].append(self._generate_wrapper_callback(_class, method)) classDict['parentClassName'] = 'MultiListenableObject' - classDict['listenerCreator'] = 'linphone_factory_create_' + _class.listenerInterface.name.to_snake_case()[:-len('_listener')] + '_cbs' + classDict['listenerCreator'] = 'linphone_factory_create_' + _class.listenerInterface.name.to_snake_case() classDict['callbacksAdder'] = _class.name.to_snake_case(fullName=True)+ '_add_callbacks' classDict['callbacksRemover'] = _class.name.to_snake_case(fullName=True)+ '_remove_callbacks' classDict['userDataSetter'] = _class.listenerInterface.name.to_snake_case(fullName=True)[:-len('_listener')] + '_cbs_set_user_data' @@ -354,9 +354,13 @@ class ClassHeader: else: self._class = translator.translate_interface(_class) + nameTranslator = metaname.Translator.get('Cpp') + interfaceName = metaname.InterfaceName() + interfaceName.from_camel_case(_class.name.translate(nameTranslator)) + self.rootNs = translator.rootNs - self.define = '_{0}_HH'.format(_class.name.to_snake_case(upper=True, fullName=True)) - self.filename = '{0}.hh'.format(_class.name.to_snake_case()) + self.define = '_{0}_HH'.format(interfaceName.to_snake_case(upper=True, fullName=True)) + self.filename = '{0}.hh'.format(interfaceName.to_snake_case()) self.priorDeclarations = [] self.private_type = _class.name.to_camel_case(fullName=True) self.includes = {'internal': [], 'external': []} @@ -508,8 +512,7 @@ class GenWrapper: def render_header(self, _class): if _class is not None: header = ClassHeader(_class, self.translator) - headerName = _class.name.to_snake_case() + '.hh' - self.mainHeader.add_include(headerName) + self.mainHeader.add_include(header.filename) self.render(header, self.includedir + '/' + header.filename) if type(_class) is not AbsApi.Interface: diff --git a/wrappers/java/genwrapper.py b/wrappers/java/genwrapper.py index 417022688a9d954f24a577a258fa4b4f6d4e4533..6e4e03946e6799365c9ce4d33646693f0c7fc465 100755 --- a/wrappers/java/genwrapper.py +++ b/wrappers/java/genwrapper.py @@ -651,9 +651,10 @@ class JniInterface: class JavaInterface: def __init__(self, package, _interface, translator): + javaNameTranslator = metaname.Translator.get('Java') self._class = translator.translate_interface(_interface) self.packageName = package - self.className = _interface.name.to_camel_case() + self.className = _interface.name.translate(javaNameTranslator) self.filename = self.className + ".java" self.cPrefix = 'linphone_' + _interface.name.to_snake_case() self.imports = []