[Kde-bindings] playground/bindings/kimono
Arno Rehn
kde at arnorehn.de
Wed Mar 21 17:39:22 UTC 2007
SVN commit 645114 by arnorehn:
* Moved the check and 'workaround' for instance operators from C# to C++.
Doesn't create any additional overhead like the C# solution.
CCMAIL: kde-bindings at kde.org
M +5 -0 ChangeLog
M +32 -46 SmokeInvocation.cs
M +11 -0 qyoto.cpp
--- trunk/playground/bindings/kimono/ChangeLog #645113:645114
@@ -1,3 +1,8 @@
+2007-03-21 Arno Rehn <arno at arnorehn.de>
+
+ * Moved the check and 'workaround' for instance operators from C# to C++.
+ Doesn't create any additional overhead like the C# solution.
+
2007-03-18 Richard Dale <rdale at foton.es>
* Changed the name of the debug class from Debug to QDebug as it made
--- trunk/playground/bindings/kimono/SmokeInvocation.cs #645113:645114
@@ -399,57 +399,43 @@
StackItem[] stack = new StackItem[callMessage.ArgCount+1];
if (callMessage.MethodSignature != null) {
- if (Qyoto.IsInstanceOperator((MethodInfo) callMessage.MethodBase)) {
- // for instance operators only length of 2 => 1. return type, 2. value to compare
- stack = new StackItem[2];
- // TODO: is it sometimes a primitive value to compare?
- // then change this to check for all possible types as it is done a few lines below
- stack[1].s_class = (IntPtr) GCHandle.Alloc(callMessage.Args[1]);
- } else {
- Type[] types = (Type[]) callMessage.MethodSignature;
- for (int i = 0; i < callMessage.ArgCount; i++) {
- if (callMessage.Args[i] == null) {
- unsafe {
- stack[i+1].s_class = (IntPtr) 0;
- }
- } else if (types[i] == typeof(bool)) {
- stack[i+1].s_bool = (bool) callMessage.Args[i];
- } else if (types[i] == typeof(sbyte)) {
- stack[i+1].s_char = (sbyte) callMessage.Args[i];
- } else if (types[i] == typeof(byte)) {
- stack[i+1].s_uchar = (byte) callMessage.Args[i];
- } else if (types[i] == typeof(short)) {
- stack[i+1].s_short = (short) callMessage.Args[i];
- } else if (types[i] == typeof(ushort)) {
- stack[i+1].s_ushort = (ushort) callMessage.Args[i];
- } else if (types[i] == typeof(int) || types[i].IsEnum) {
- stack[i+1].s_int = (int) callMessage.Args[i];
- } else if (types[i] == typeof(uint)) {
- stack[i+1].s_uint = (uint) callMessage.Args[i];
- } else if (types[i] == typeof(long)) {
- stack[i+1].s_long = (long) callMessage.Args[i];
- } else if (types[i] == typeof(ulong)) {
- stack[i+1].s_ulong = (ulong) callMessage.Args[i];
- } else if (types[i] == typeof(float)) {
- stack[i+1].s_float = (float) callMessage.Args[i];
- } else if (types[i] == typeof(double)) {
- stack[i+1].s_double = (double) callMessage.Args[i];
- } else if (types[i] == typeof(string)) {
- stack[i+1].s_class = (IntPtr) GCHandle.Alloc(callMessage.Args[i]);
- } else {
- stack[i+1].s_class = (IntPtr) GCHandle.Alloc(callMessage.Args[i]);
+ Type[] types = (Type[]) callMessage.MethodSignature;
+ for (int i = 0; i < callMessage.ArgCount; i++) {
+ if (callMessage.Args[i] == null) {
+ unsafe {
+ stack[i+1].s_class = (IntPtr) 0;
}
+ } else if (types[i] == typeof(bool)) {
+ stack[i+1].s_bool = (bool) callMessage.Args[i];
+ } else if (types[i] == typeof(sbyte)) {
+ stack[i+1].s_char = (sbyte) callMessage.Args[i];
+ } else if (types[i] == typeof(byte)) {
+ stack[i+1].s_uchar = (byte) callMessage.Args[i];
+ } else if (types[i] == typeof(short)) {
+ stack[i+1].s_short = (short) callMessage.Args[i];
+ } else if (types[i] == typeof(ushort)) {
+ stack[i+1].s_ushort = (ushort) callMessage.Args[i];
+ } else if (types[i] == typeof(int) || types[i].IsEnum) {
+ stack[i+1].s_int = (int) callMessage.Args[i];
+ } else if (types[i] == typeof(uint)) {
+ stack[i+1].s_uint = (uint) callMessage.Args[i];
+ } else if (types[i] == typeof(long)) {
+ stack[i+1].s_long = (long) callMessage.Args[i];
+ } else if (types[i] == typeof(ulong)) {
+ stack[i+1].s_ulong = (ulong) callMessage.Args[i];
+ } else if (types[i] == typeof(float)) {
+ stack[i+1].s_float = (float) callMessage.Args[i];
+ } else if (types[i] == typeof(double)) {
+ stack[i+1].s_double = (double) callMessage.Args[i];
+ } else if (types[i] == typeof(string)) {
+ stack[i+1].s_class = (IntPtr) GCHandle.Alloc(callMessage.Args[i]);
+ } else {
+ stack[i+1].s_class = (IntPtr) GCHandle.Alloc(callMessage.Args[i]);
}
}
}
- GCHandle instanceHandle;
- if (Qyoto.IsInstanceOperator((MethodInfo) callMessage.MethodBase)) {
- // if it's an instance operator, the instance is the first argument
- instanceHandle = GCHandle.Alloc(callMessage.Args[0]);
- } else {
- instanceHandle = GCHandle.Alloc(_instance);
- }
+ GCHandle instanceHandle = GCHandle.Alloc(_instance);
MethodReturnMessageWrapper returnValue = new MethodReturnMessageWrapper((IMethodReturnMessage) returnMessage);
unsafe {
--- trunk/playground/bindings/kimono/qyoto.cpp #645113:645114
@@ -1425,6 +1425,17 @@
printf("ENTER CallSmokeMethod(methodId: %d target: 0x%8.8x items: %d)\n", methodId, obj, items);
#endif
+ Smoke::Method meth = qt_Smoke->methods[methodId];
+ QString name(qt_Smoke->methodNames[meth.name]);
+ if (name.startsWith("operator") && meth.numArgs == 1) { // instance operator
+#ifdef DEBUG
+ printf("IN CallSmokeMethod() instance operator: %s\n", (const char*) name.toLatin1());
+#endif
+ obj = sp[1].s_class;
+ sp[1] = sp[2];
+ items = 1;
+ }
+
MethodCall c(qt_Smoke, methodId, obj, sp, items);
c.next();
More information about the Kde-bindings
mailing list