forked from enlightenment/efl
efl_mono: Fix eina_value_set.
Instead of messing around with varargs, create individual wrappers for each type supported. The va_list approach was getting problems with float/double on Windows.
This commit is contained in:
parent
c316a2ef37
commit
3c5efa1e8d
|
@ -46,51 +46,51 @@ static internal class UnsafeNativeMethods {
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports, CharSet=CharSet.Ansi)]
|
[DllImport(efl.Libs.CustomExports, CharSet=CharSet.Ansi)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, string value);
|
internal static extern bool eina_value_set_wrapper_string(IntPtr handle, string value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, byte value);
|
internal static extern bool eina_value_set_wrapper_uchar(IntPtr handle, byte value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, sbyte value);
|
internal static extern bool eina_value_set_wrapper_char(IntPtr handle, sbyte value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, short value);
|
internal static extern bool eina_value_set_wrapper_short(IntPtr handle, short value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, ushort value);
|
internal static extern bool eina_value_set_wrapper_ushort(IntPtr handle, ushort value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, int value);
|
internal static extern bool eina_value_set_wrapper_int(IntPtr handle, int value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, uint value);
|
internal static extern bool eina_value_set_wrapper_uint(IntPtr handle, uint value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, long value);
|
internal static extern bool eina_value_set_wrapper_long(IntPtr handle, long value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, ulong value);
|
internal static extern bool eina_value_set_wrapper_ulong(IntPtr handle, ulong value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, float value);
|
internal static extern bool eina_value_set_wrapper_float(IntPtr handle, float value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, double value);
|
internal static extern bool eina_value_set_wrapper_double(IntPtr handle, double value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
internal static extern bool eina_value_set_wrapper(IntPtr handle, IntPtr value);
|
internal static extern bool eina_value_set_wrapper_ptr(IntPtr handle, IntPtr value);
|
||||||
|
|
||||||
[DllImport(efl.Libs.CustomExports)]
|
[DllImport(efl.Libs.CustomExports)]
|
||||||
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
[return: MarshalAsAttribute(UnmanagedType.U1)]
|
||||||
|
@ -908,7 +908,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
if (!GetValueType().IsNumeric())
|
if (!GetValueType().IsNumeric())
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set numeric value on a non-numeric eina.Value"));
|
"Trying to set numeric value on a non-numeric eina.Value"));
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
return eina_value_set_wrapper_uchar(this.Handle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Set(sbyte value)
|
public bool Set(sbyte value)
|
||||||
|
@ -923,7 +923,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
if (!GetValueType().IsNumeric())
|
if (!GetValueType().IsNumeric())
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set numeric value on a non-numeric eina.Value"));
|
"Trying to set numeric value on a non-numeric eina.Value"));
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
return eina_value_set_wrapper_char(this.Handle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Set(short value)
|
public bool Set(short value)
|
||||||
|
@ -938,7 +938,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
if (!GetValueType().IsNumeric())
|
if (!GetValueType().IsNumeric())
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set numeric value on a non-numeric eina.Value"));
|
"Trying to set numeric value on a non-numeric eina.Value"));
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
return eina_value_set_wrapper_short(this.Handle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Set(ushort value)
|
public bool Set(ushort value)
|
||||||
|
@ -953,7 +953,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
if (!GetValueType().IsNumeric())
|
if (!GetValueType().IsNumeric())
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set numeric value on a non-numeric eina.Value"));
|
"Trying to set numeric value on a non-numeric eina.Value"));
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
return eina_value_set_wrapper_ushort(this.Handle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stores the given uint value.</summary>
|
/// <summary>Stores the given uint value.</summary>
|
||||||
|
@ -969,7 +969,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
if (!GetValueType().IsNumeric())
|
if (!GetValueType().IsNumeric())
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set numeric value on a non-numeric eina.Value"));
|
"Trying to set numeric value on a non-numeric eina.Value"));
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
return eina_value_set_wrapper_uint(this.Handle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stores the given int value.</summary>
|
/// <summary>Stores the given int value.</summary>
|
||||||
|
@ -985,7 +985,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
if (!GetValueType().IsNumeric())
|
if (!GetValueType().IsNumeric())
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set numeric value on a non-numeric eina.Value"));
|
"Trying to set numeric value on a non-numeric eina.Value"));
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
return eina_value_set_wrapper_int(this.Handle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stores the given ulong value.</summary>
|
/// <summary>Stores the given ulong value.</summary>
|
||||||
|
@ -1001,7 +1001,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
if (!GetValueType().IsNumeric())
|
if (!GetValueType().IsNumeric())
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set numeric value on a non-numeric eina.Value"));
|
"Trying to set numeric value on a non-numeric eina.Value"));
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
return eina_value_set_wrapper_ulong(this.Handle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stores the given int value.</summary>
|
/// <summary>Stores the given int value.</summary>
|
||||||
|
@ -1017,7 +1017,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
if (!GetValueType().IsNumeric())
|
if (!GetValueType().IsNumeric())
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set numeric value on a non-numeric eina.Value"));
|
"Trying to set numeric value on a non-numeric eina.Value"));
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
return eina_value_set_wrapper_long(this.Handle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stores the given int value.</summary>
|
/// <summary>Stores the given int value.</summary>
|
||||||
|
@ -1034,8 +1034,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set numeric value on a non-numeric eina.Value"));
|
"Trying to set numeric value on a non-numeric eina.Value"));
|
||||||
|
|
||||||
Console.WriteLine("Wrapper Set({0})", value);
|
return eina_value_set_wrapper_float(this.Handle, value);
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stores the given int value.</summary>
|
/// <summary>Stores the given int value.</summary>
|
||||||
|
@ -1051,7 +1050,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
if (!GetValueType().IsNumeric())
|
if (!GetValueType().IsNumeric())
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set numeric value on a non-numeric eina.Value"));
|
"Trying to set numeric value on a non-numeric eina.Value"));
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
return eina_value_set_wrapper_double(this.Handle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stores the given string value.</summary>
|
/// <summary>Stores the given string value.</summary>
|
||||||
|
@ -1068,7 +1067,7 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
|
||||||
throw (new ArgumentException(
|
throw (new ArgumentException(
|
||||||
"Trying to set non-string value on a string eina.Value"));
|
"Trying to set non-string value on a string eina.Value"));
|
||||||
// No need to worry about ownership as eina_value_set will copy the passed string.
|
// No need to worry about ownership as eina_value_set will copy the passed string.
|
||||||
return eina_value_set_wrapper(this.Handle, value);
|
return eina_value_set_wrapper_string(this.Handle, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stores the given value into this value. The target value must be an optional.</summary>
|
/// <summary>Stores the given value into this value. The target value must be an optional.</summary>
|
||||||
|
|
|
@ -323,15 +323,24 @@ EAPI size_t eina_value_sizeof()
|
||||||
return sizeof(Eina_Value);
|
return sizeof(Eina_Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool eina_value_set_wrapper(Eina_Value *value, ...)
|
#define EINA_SET_WRAPPER(N, T) EAPI Eina_Bool eina_value_set_wrapper_##N(Eina_Value *value, T new_value) \
|
||||||
{
|
{ \
|
||||||
va_list argp;
|
return eina_value_set(value, new_value); \
|
||||||
va_start(argp, value);
|
|
||||||
Eina_Bool ret = eina_value_vset(value, argp);
|
|
||||||
va_end(argp);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EINA_SET_WRAPPER(char, char)
|
||||||
|
EINA_SET_WRAPPER(uchar, unsigned char)
|
||||||
|
EINA_SET_WRAPPER(short, short)
|
||||||
|
EINA_SET_WRAPPER(ushort, unsigned short)
|
||||||
|
EINA_SET_WRAPPER(int, int)
|
||||||
|
EINA_SET_WRAPPER(uint, unsigned int)
|
||||||
|
EINA_SET_WRAPPER(long, long)
|
||||||
|
EINA_SET_WRAPPER(ulong, unsigned long)
|
||||||
|
EINA_SET_WRAPPER(float, float)
|
||||||
|
EINA_SET_WRAPPER(double, double)
|
||||||
|
EINA_SET_WRAPPER(string, const char *)
|
||||||
|
EINA_SET_WRAPPER(ptr, void *)
|
||||||
|
|
||||||
EAPI Eina_Bool eina_value_setup_wrapper(Eina_Value *value,
|
EAPI Eina_Bool eina_value_setup_wrapper(Eina_Value *value,
|
||||||
const Eina_Value_Type *type)
|
const Eina_Value_Type *type)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue