mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
Finished C# wrapper by adding methods having lists in params
This commit is contained in:
parent
578bfd5f1a
commit
2915732e02
2 changed files with 42 additions and 4 deletions
|
|
@ -138,9 +138,7 @@ class CsharpTranslator(object):
|
|||
elif type(_type) is AbsApi.BaseType:
|
||||
return self.translate_base_type(_type, isArg, dllImport)
|
||||
elif type(_type) is AbsApi.ListType:
|
||||
if isArg:
|
||||
raise AbsApi.Error('Lists as params are not supported yet')
|
||||
elif dllImport:
|
||||
if dllImport:
|
||||
return 'IntPtr'
|
||||
else:
|
||||
if type(_type.containedTypeDesc) is AbsApi.BaseType:
|
||||
|
|
@ -222,6 +220,12 @@ class CsharpTranslator(object):
|
|||
methodDict['impl']['c_args'] += '(int)' + self.translate_argument_name(arg.name)
|
||||
elif self.translate_type(arg.type, False, False) == "bool":
|
||||
methodDict['impl']['c_args'] += self.translate_argument_name(arg.name) + " ? 1 : 0"
|
||||
elif self.get_class_array_type(self.translate_type(arg.type, False, False)) is not None:
|
||||
listtype = self.get_class_array_type(self.translate_type(arg.type, False, False))
|
||||
if listtype == 'string':
|
||||
methodDict['impl']['c_args'] += "StringArrayToBctbxList(" + self.translate_argument_name(arg.name) + ")"
|
||||
else:
|
||||
methodDict['impl']['c_args'] += "ObjectArrayToBctbxList<" + listtype + ">(" + self.translate_argument_name(arg.name) + ")"
|
||||
else:
|
||||
methodDict['impl']['c_args'] += self.translate_argument_name(arg.name)
|
||||
methodDict['impl']['args'] += self.translate_argument(arg, False)
|
||||
|
|
|
|||
|
|
@ -60,6 +60,12 @@ namespace Linphone
|
|||
|
||||
[DllImport(LinphoneWrapper.LIB_NAME)]
|
||||
static extern IntPtr bctbx_list_get_data(IntPtr ptr);
|
||||
|
||||
[DllImport(LinphoneWrapper.LIB_NAME)]
|
||||
static extern IntPtr bctbx_list_append(IntPtr elem, string data);
|
||||
|
||||
[DllImport(LinphoneWrapper.LIB_NAME)]
|
||||
static extern IntPtr bctbx_list_append(IntPtr elem, IntPtr data);
|
||||
|
||||
~LinphoneObject()
|
||||
{
|
||||
|
|
@ -134,6 +140,26 @@ namespace Linphone
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static IntPtr StringArrayToBctbxList(IEnumerable<string> stringlist)
|
||||
{
|
||||
IntPtr bctbx_list = IntPtr.Zero;
|
||||
foreach (string s in stringlist)
|
||||
{
|
||||
bctbx_list = bctbx_list_append(bctbx_list, s);
|
||||
}
|
||||
return bctbx_list;
|
||||
}
|
||||
|
||||
internal static IntPtr ObjectArrayToBctbxList<T>(IEnumerable<T> objlist) where T : LinphoneObject, new()
|
||||
{
|
||||
IntPtr bctbx_list = IntPtr.Zero;
|
||||
foreach (T ptr in objlist)
|
||||
{
|
||||
bctbx_list = bctbx_list_append(bctbx_list, ptr.nativePtr);
|
||||
}
|
||||
return bctbx_list;
|
||||
}
|
||||
}
|
||||
|
||||
public class LinphoneAndroid
|
||||
|
|
@ -294,13 +320,21 @@ namespace Linphone
|
|||
{{#exception}}int exception_result = {{/exception}}{{setter_c_name}}({{setter_nativePtr}}value);
|
||||
{{#exception}}if (exception_result != 0) throw new LinphoneException("{{property_name}} setter returned value " + exception_result);{{/exception}}
|
||||
{{/is_generic}}
|
||||
{{#is_string_list}}
|
||||
{{#exception}}int exception_result = {{/exception}}{{setter_c_name}}({{setter_nativePtr}}StringArrayToBctbxList(value));
|
||||
{{#exception}}if (exception_result != 0) throw new LinphoneException("{{property_name}} setter returned value " + exception_result);{{/exception}}
|
||||
{{/is_string_list}}
|
||||
{{#is_class_list}}
|
||||
{{#exception}}int exception_result = {{/exception}}{{setter_c_name}}({{setter_nativePtr}}ObjectArrayToBctbxList<{{{list_type}}}>(value));
|
||||
{{#exception}}if (exception_result != 0) throw new LinphoneException("{{property_name}} setter returned value " + exception_result);{{/exception}}
|
||||
{{/is_class_list}}
|
||||
}
|
||||
{{/has_setter}}
|
||||
}
|
||||
{{/has_property}}
|
||||
{{#has_impl}}
|
||||
{{#impl}}
|
||||
public {{static}}{{override}}{{{type}}} {{name}}({{args}})
|
||||
public {{static}}{{override}}{{{type}}} {{name}}({{{args}}})
|
||||
{
|
||||
{{#is_string}}
|
||||
IntPtr stringPtr = {{c_name}}({{nativePtr}}{{c_args}});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue