[Kde-bindings] KDE/kdebindings/csharp/qyoto
Arno Rehn
kde at arnorehn.de
Sun Dec 14 21:05:55 UTC 2008
SVN commit 896955 by arnorehn:
* Don't use StackItem.s_long if we are on a 32 bit platform (i.e. a long isn't
64 bits). Use s_int instead if that's the case, otherwise the value would be
wrong. Is there a better solution than the one I implemented here?
Thanks to Eric Butler for reporting the bug!
CCMAIL: kde-bindings at kde.org
CCMAIL: eric at extremeboredom.net
M +7 -0 ChangeLog
M +20 -10 src/SmokeInvocation.cs
M +5 -0 src/SmokeMarshallers.cs
M +6 -0 src/qyoto.cpp
--- trunk/KDE/kdebindings/csharp/qyoto/ChangeLog #896954:896955
@@ -1,3 +1,10 @@
+2008-12-14 Arno Rehn <arno at arnorehn.de>
+
+ * Don't use StackItem.s_long if we are on a 32 bit platform (i.e. a long isn't
+ 64 bits). Use s_int instead if that's the case, otherwise the value would be
+ wrong. Is there a better solution than the one I implemented here?
+ Thanks to Eric Butler for reporting the bug!
+
2008-12-09 Arno Rehn <arno at arnorehn.de>
* Watch out for itemChange() calls and if necessary, add or remove global refs
--- trunk/KDE/kdebindings/csharp/qyoto/src/SmokeInvocation.cs #896954:896955
@@ -185,9 +185,11 @@
} else if (parameters[i].ParameterType == typeof(uint)) {
args[i] = stackPtr[i+1].s_uint;
} else if (parameters[i].ParameterType == typeof(long)) {
- args[i] = stackPtr[i+1].s_long;
+ // s_long will contain the wrong value on 32 bit platforms
+ // (i.e. where a native C++ 'long' isn't at least 64 bit)
+ args[i] = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stackPtr[i+1].s_int : stackPtr[i+1].s_long;
} else if (parameters[i].ParameterType == typeof(ulong)) {
- args[i] = stackPtr[i+1].s_ulong;
+ args[i] = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stackPtr[i+1].s_uint : stackPtr[i+1].s_ulong;
} else if (parameters[i].ParameterType == typeof(float)) {
args[i] = stackPtr[i+1].s_float;
} else if (parameters[i].ParameterType == typeof(double)) {
@@ -294,9 +296,11 @@
} else if (parameters[i].ParameterType == typeof(uint)) {
args[i] = stackPtr[i].s_uint;
} else if (parameters[i].ParameterType == typeof(long)) {
- args[i] = stackPtr[i].s_long;
+ // s_long will contain the wrong value on 32 bit platforms
+ // (i.e. where a native C++ 'long' isn't at least 64 bit)
+ args[i] = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stackPtr[i+1].s_int : stackPtr[i+1].s_long;
} else if (parameters[i].ParameterType == typeof(ulong)) {
- args[i] = stackPtr[i].s_ulong;
+ args[i] = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stackPtr[i+1].s_uint : stackPtr[i+1].s_ulong;
} else if (parameters[i].ParameterType == typeof(float)) {
args[i] = stackPtr[i].s_float;
} else if (parameters[i].ParameterType == typeof(double)) {
@@ -394,9 +398,11 @@
} else if (parameters[i].ParameterType == typeof(uint)) {
args[i] = stackPtr[i].s_uint;
} else if (parameters[i].ParameterType == typeof(long)) {
- args[i] = stackPtr[i].s_long;
+ // s_long will contain the wrong value on 32 bit platforms
+ // (i.e. where a native C++ 'long' isn't at least 64 bit)
+ args[i] = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stackPtr[i+1].s_int : stackPtr[i+1].s_long;
} else if (parameters[i].ParameterType == typeof(ulong)) {
- args[i] = stackPtr[i].s_ulong;
+ args[i] = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stackPtr[i+1].s_uint : stackPtr[i+1].s_ulong;
} else if (parameters[i].ParameterType == typeof(float)) {
args[i] = stackPtr[i].s_float;
} else if (parameters[i].ParameterType == typeof(double)) {
@@ -628,7 +634,9 @@
} else if (returnType == typeof(double)) {
returnValue = stack[0].s_double;
} else if (returnType == typeof(long)) {
- returnValue = stack[0].s_long;
+ // s_long will contain the wrong value on 32 bit platforms
+ // (i.e. where a native C++ 'long' isn't at least 64 bit)
+ returnValue = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stack[0].s_int : stack[0].s_long;
} else if (returnType == typeof(ushort)) {
returnValue = stack[0].s_ushort;
} else if (returnType == typeof(uint)) {
@@ -636,7 +644,7 @@
} else if (returnType.IsEnum) {
returnValue = Enum.ToObject(returnType, stack[0].s_int);
} else if (returnType == typeof(ulong)) {
- returnValue = stack[0].s_ulong;
+ returnValue = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stack[0].s_uint : stack[0].s_ulong;
} else if (returnType == typeof(sbyte)) {
returnValue = stack[0].s_char;
} else if (returnType == typeof(byte)) {
@@ -778,9 +786,11 @@
} else if (returnType == typeof(uint)) {
returnValue.ReturnValue = stack[0].s_uint;
} else if (returnType == typeof(long)) {
- returnValue.ReturnValue = stack[0].s_long;
+ // s_long will contain the wrong value on 32 bit platforms
+ // (i.e. where a native C++ 'long' isn't at least 64 bit)
+ returnValue.ReturnValue = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stack[0].s_int : stack[0].s_long;
} else if (returnType == typeof(ulong)) {
- returnValue.ReturnValue = stack[0].s_ulong;
+ returnValue.ReturnValue = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stack[0].s_uint : stack[0].s_ulong;
} else if (returnType == typeof(float)) {
returnValue.ReturnValue = stack[0].s_float;
} else if (returnType == typeof(double)) {
--- trunk/KDE/kdebindings/csharp/qyoto/src/SmokeMarshallers.cs #896954:896955
@@ -44,6 +44,9 @@
/** Other functions **/
[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+ public static extern int SizeOfLong();
+
+ [DllImport("libqyoto", CharSet=CharSet.Ansi)]
public static extern IntPtr ConstructPointerList();
[DllImport("libqyoto", CharSet=CharSet.Ansi)]
@@ -239,6 +242,8 @@
#region marshalling functions
+ public static int SizeOfNativeLong = SizeOfLong();
+
public static void FreeGCHandle(IntPtr handle) {
if (handle == IntPtr.Zero) {
Console.WriteLine("In FreeGCHandle(IntPtr): handle == 0 - This should not happen!");
--- trunk/KDE/kdebindings/csharp/qyoto/src/qyoto.cpp #896954:896955
@@ -691,6 +691,12 @@
application_terminated = true;
}
+Q_DECL_EXPORT int
+SizeOfLong()
+{
+ return sizeof(long);
+}
+
/*
Based on this function from QtCore/qhash.h:
More information about the Kde-bindings
mailing list