Commit dd287ef0 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fixed issue with mask enums in C# wrapper

parent d42bc9ac
Pipeline #234 failed with stage
in 0 seconds
......@@ -355,16 +355,20 @@ class CsharpTranslator(object):
enumDict['values'] = []
i = 0
lastValue = None
print 'Enum name is ' + enumDict['enumName']
for enumValue in enum.enumerators:
enumValDict = {}
enumValDict['name'] = enumValue.name.translate(self.nameTranslator)
enumValDict['doc'] = enumValue.briefDescription.translate(self.docTranslator, tagAsBrief=True)
if type(enumValue.value) is int:
if isinstance(enumValue.value, int):
print 'Enum value is int ! ' + str(enumValue.value)
lastValue = enumValue.value
enumValDict['value'] = str(enumValue.value)
elif type(enumValue.value) is AbsApi.Flag:
elif isinstance(enumValue.value, AbsApi.Flag):
print 'Enum value is flag ! ' + '1<<' + str(enumValue.value.position)
enumValDict['value'] = '1<<' + str(enumValue.value.position)
else:
print 'Unknown enum value type !'
if lastValue is not None:
enumValDict['value'] = lastValue + 1
lastValue += 1
......@@ -458,7 +462,8 @@ class InterfaceImpl(object):
self.interface = translator.translate_interface(interface)
class WrapperImpl(object):
def __init__(self, enums, interfaces, classes):
def __init__(self, version, enums, interfaces, classes):
self.version = version
self.enums = enums
self.interfaces = interfaces
self.classes = classes
......@@ -478,6 +483,9 @@ def render(renderer, item, path):
if __name__ == '__main__':
import subprocess
git_version = subprocess.check_output(["git", "describe"]).strip()
argparser = argparse.ArgumentParser(description='Generate source files for the C# wrapper')
argparser.add_argument('xmldir', type=str, help='Directory where the XML documentation of the Linphone\'s API generated by Doxygen is placed')
argparser.add_argument('-o --output', type=str, help='the directory where to generate the source files', dest='outputdir', default='.')
......@@ -521,5 +529,5 @@ if __name__ == '__main__':
enum_impl = EnumImpl(_enum, translator)
enums.append(enum_impl)
wrapper = WrapperImpl(enums, interfaces, classes)
wrapper = WrapperImpl(git_version, enums, interfaces, classes)
render(renderer, wrapper, args.outputdir + "/" + args.outputfile)
......@@ -32,6 +32,7 @@ namespace Linphone
/// </summary>
public class LinphoneWrapper
{
public const string VERSION = "{{version}}";
#if __IOS__
public const string LIB_NAME = "linphone.framework/linphone";
#else
......@@ -297,7 +298,7 @@ namespace Linphone
/// {{{line}}}
{{/lines}}
{{/doc}}
{{name}} = {{value}},
{{name}} = {{{value}}},
{{/values}}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment