[Kde-bindings] playground/bindings/kimono
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Tue Mar 20 19:25:05 UTC 2007
SVN commit 644717 by rdale:
* Changed the name of the debug class from Debug to QDebug as it made
using Debug.Asserts inconvenient
* Added some copyright headers to the source files
* Build the project with debug by default
CCMAIL: kde-bindings at kde.org
M +1 -1 CMakeLists.txt
M +7 -0 ChangeLog
M +20 -21 Qyoto.cs
M +6 -8 SmokeInvocation.cs
M +37 -24 SmokeMarshallers.cs
--- trunk/playground/bindings/kimono/CMakeLists.txt #644716:644717
@@ -47,7 +47,7 @@
ADD_LIBRARY (qyoto MODULE ${SRC_CPP})
TARGET_LINK_LIBRARIES (qyoto smokeqt ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
-ADD_CUSTOM_TARGET (qt-dotnet ALL ${GMCS_PATH} -unsafe -warn:0 -out:qt-dotnet.dll -target:library ${SRC_CS}
+ADD_CUSTOM_TARGET (qt-dotnet ALL ${GMCS_PATH} -debug -define:DEBUG -unsafe -warn:0 -out:qt-dotnet.dll -target:library ${SRC_CS}
COMMENT "Building qt-dotnet.dll")
ADD_DEPENDENCIES (qt-dotnet qyoto)
--- trunk/playground/bindings/kimono/ChangeLog #644716:644717
@@ -1,3 +1,10 @@
+2007-03-18 Richard Dale <rdale at foton.es>
+
+ * Changed the name of the debug class from Debug to QDebug as it made
+ using Debug.Asserts inconvenient
+ * Added some copyright headers to the source files
+ * Build the project with debug by default
+
2007-03-20 Arno Rehn <arno at arnorehn.de>
* Allow 'zero' return types for methods and for args of methods being called
--- trunk/playground/bindings/kimono/Qyoto.cs #644716:644717
@@ -1,5 +1,20 @@
-// #define DEBUG
+/***************************************************************************
+ Qyoto.cs - description
+ -------------------
+ begin : Wed Jun 16 2004
+ copyright : (C) 2004-2007 by Richard Dale, Arno Rehn
+ email : richard.j.dale at gmail.com
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
namespace Qyoto
{
using System;
@@ -10,6 +25,7 @@
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
+#if DEBUG
public enum DebugLevel {
Off,
Minimal,
@@ -28,7 +44,7 @@
QTDB_ALL = QTDB_VERBOSE | QTDB_VIRTUAL | QTDB_GC | QTDB_CALLS | QTDB_TRANSPARENT_PROXY | QTDB_AMBIGUOUS
}
- public class Debug {
+ public class QDebug {
[DllImport("libqyoto", CharSet=CharSet.Ansi)]
public static extern void SetDebug(QtDebugChannel debugChannel);
@@ -44,6 +60,7 @@
}
}
}
+#endif
public class Qyoto : System.Object
{
@@ -82,20 +99,11 @@
public static int GetCPPEnumValue(string c, string value) {
Type t = Type.GetType("Qyoto." + c, false);
if (t == null) {
-#if DEBUG
- Console.WriteLine("NULL");
-#endif
return 0;
}
foreach (Type nt in t.GetNestedTypes()) {
if (nt.IsEnum) {
-#if DEBUG
- Console.WriteLine("ENUM: {0}", nt.ToString());
-#endif
foreach (int i in Enum.GetValues(nt)) {
-#if DEBUG
- Console.WriteLine("MEMBER: {0}", Enum.Format(nt, i, "f"));
-#endif
if (Enum.Format(nt, i, "f") == value) {
return i;
}
@@ -419,9 +427,7 @@
public static QMetaObject MakeMetaObject(Type t, QObject o) {
if (t == null) return null;
-#if DEBUG
- Console.WriteLine("ENTER MakeMetaObject t => {0}", t);
-#endif
+
QMetaObject parentMeta = null;
if ( !IsSmokeClass(t.BaseType)
&& !metaObjects.TryGetValue(t.BaseType.Name, out parentMeta) )
@@ -468,19 +474,12 @@
public static QMetaObject GetMetaObject(QObject o) {
Type t = o.GetType();
-#if DEBUG
- Console.WriteLine("ENTER GetMetaObject t => {0}", t);
-#endif
QMetaObject res;
if (!metaObjects.TryGetValue(t.ToString(), out res)) {
// create QMetaObject
res = MakeMetaObject(t, o);
}
-
-#if DEBUG
- Console.WriteLine("LEAVE GetMetaObject");
-#endif
return res;
}
--- trunk/playground/bindings/kimono/SmokeInvocation.cs #644716:644717
@@ -3,7 +3,7 @@
-------------------
begin : Wed Jun 16 2004
copyright : (C) 2004 by Richard Dale
- email : Richard_Dale at tipitina.demon.co.uk
+ email : richard.j.dale at gmail.com
***************************************************************************/
/***************************************************************************
@@ -15,8 +15,6 @@
* *
***************************************************************************/
-#define DEBUG
-
namespace Qyoto {
using Qyoto;
@@ -152,8 +150,8 @@
object instance = ((GCHandle) instanceHandle).Target;
MethodInfo method = (MethodInfo) ((GCHandle) methodHandle).Target;
#if DEBUG
- if ( (Debug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0
- && (Debug.DebugChannel() & QtDebugChannel.QTDB_VIRTUAL) != 0 )
+ if ( (QDebug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0
+ && (QDebug.DebugChannel() & QtDebugChannel.QTDB_VIRTUAL) != 0 )
{
Console.WriteLine( "ENTER InvokeMethod() {0}.{1}",
instance,
@@ -241,7 +239,7 @@
QObject qobj = (QObject) ((GCHandle)obj).Target;
string className = qobj.GetType().ToString();
#if DEBUG
- if ((Debug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0) {
+ if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0) {
Console.WriteLine( "ENTER InvokeCustomSlot() {0}.{1}",
qobj.GetType(),
slotname );
@@ -366,7 +364,7 @@
IMethodReturnMessage returnMessage = (IMethodReturnMessage) message;
#if DEBUG
- if ((Debug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0) {
+ if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0) {
Console.WriteLine( "ENTER SmokeInvocation.Invoke() MethodName: {0}.{1} Type: {2} ArgCount: {3}",
_className,
callMessage.MethodName,
@@ -510,7 +508,7 @@
StackItem[] stack = new StackItem[callMessage.ArgCount+1];
#if DEBUG
- if ((Debug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0) {
+ if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0) {
Console.WriteLine( "ENTER SignalInvocation.Invoke() MethodName: {0}.{1} Type: {2} ArgCount: {3}",
_className,
callMessage.MethodName,
--- trunk/playground/bindings/kimono/SmokeMarshallers.cs #644716:644717
@@ -1,9 +1,25 @@
-#define DEBUG
+/***************************************************************************
+ SmokeMarshallers.cs - description
+ -------------------
+ begin : Wed Jun 16 2004
+ copyright : (C) 2004-2007 by Richard Dale, Arno Rehn
+ email : richard.j.dale at gmail.com
+ ***************************************************************************/
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
namespace Qyoto {
using System;
using System.Collections;
using System.Collections.Generic;
+ using System.Diagnostics;
using System.Reflection;
using System.Runtime.Remoting.Proxies;
using System.Runtime.InteropServices;
@@ -176,9 +192,7 @@
return (IntPtr) 0;
Object instance = ((GCHandle) instancePtr).Target;
- if (instance == null) {
- return (IntPtr) 0;
- }
+ Debug.Assert(instance != null);
FieldInfo fieldInfo = instance.GetType().GetField( "smokeObject",
BindingFlags.NonPublic
@@ -189,9 +203,7 @@
public static void SetSmokeObject(IntPtr instancePtr, IntPtr smokeObjectPtr) {
Object instance = ((GCHandle) instancePtr).Target;
- if (instance == null) {
- return;
- }
+ Debug.Assert(instance != null);
FieldInfo fieldInfo = instance.GetType().GetField( "smokeObject",
BindingFlags.NonPublic
@@ -256,14 +268,14 @@
WeakReference weakRef = new WeakReference(instance);
pointerMap[ptr] = weakRef;
#if DEBUG
- if ((Debug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0) {
+ if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0) {
Console.WriteLine("MapPointer() Creating weak reference 0x{0:x8} -> {1}", (int) ptr, instance);
}
#endif
if (createStrongReference) {
strongReferenceMap[ptr] = instance;
#if DEBUG
- if ((Debug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0) {
+ if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0) {
Console.WriteLine("MapPointer() Creating strong reference 0x{0:x8} -> {1}", (int) ptr, instance);
}
#endif
@@ -274,7 +286,7 @@
pointerMap.Remove(ptr);
if (strongReferenceMap.ContainsKey(ptr)) {
#if DEBUG
- if ((Debug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0) {
+ if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0) {
object reference;
if (strongReferenceMap.TryGetValue(ptr, out reference)) {
Console.WriteLine("UnmapPointer() Removing strong reference 0x{0:x8} -> {1}", (int) ptr, reference);
@@ -289,8 +301,8 @@
WeakReference weakRef;
if (!pointerMap.TryGetValue(ptr, out weakRef)) {
#if DEBUG
- if ( (Debug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0
- && Debug.debugLevel >= DebugLevel.Extensive )
+ if ( (QDebug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0
+ && QDebug.debugLevel >= DebugLevel.Extensive )
{
Console.WriteLine("GetPointerObject() pointerMap[0x{0:x8}] == null", (int) ptr);
}
@@ -300,8 +312,8 @@
if (weakRef == null) {
#if DEBUG
- if ( (Debug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0
- && Debug.debugLevel >= DebugLevel.Extensive )
+ if ( (QDebug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0
+ && QDebug.debugLevel >= DebugLevel.Extensive )
{
Console.WriteLine("GetPointerObject() weakRef null ptr: 0x{0:x8}", (int) ptr);
}
@@ -309,8 +321,8 @@
return (IntPtr) 0;
} else if (weakRef.IsAlive) {
#if DEBUG
- if ( (Debug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0
- && Debug.debugLevel >= DebugLevel.Extensive )
+ if ( (QDebug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0
+ && QDebug.debugLevel >= DebugLevel.Extensive )
{
Console.WriteLine("GetPointerObject() weakRef.IsAlive 0x{0:x8} -> {1}", (int) ptr, weakRef.Target);
}
@@ -319,8 +331,8 @@
return (IntPtr) instanceHandle;
} else {
#if DEBUG
- if ( (Debug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0
- && Debug.debugLevel >= DebugLevel.Extensive )
+ if ( (QDebug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0
+ && QDebug.debugLevel >= DebugLevel.Extensive )
{
Console.WriteLine("GetPointerObject() weakRef dead ptr: 0x{0:x8}", (int) ptr);
}
@@ -345,13 +357,13 @@
constructorParamTypes[0] = typeof(Type);
ConstructorInfo constructorInfo = klass.GetConstructor(BindingFlags.NonPublic
| BindingFlags.Instance, null, new Type[ ] { typeof( Type ) } , null);
- if (constructorInfo == null) {
- Console.Error.WriteLine("CreateInstance(\"{0}\") constructor method missing {1}", className, constructorParamTypes[0]);
- return (IntPtr) 0;
- }
+
+ Debug.Assert( constructorInfo != null,
+ "CreateInstance(\"" + className + "\") constructor method missing" );
+
object result = constructorInfo.Invoke(new object [] { constructorParamTypes[0] });
#if DEBUG
- if ((Debug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0) {
+ if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0) {
Console.WriteLine("CreateInstance(\"{0}\") constructed {1}", className, result);
}
#endif
@@ -369,7 +381,8 @@
klass = klass.BaseType;
} while (klass != typeof(object));
- Console.Error.WriteLine("CreateInstance(\"{0}\") no CreateProxy() found", className);
+ Debug.Assert( proxyCreator != null,
+ "CreateInstance(\"" + className + "\") no CreateProxy() found" );
return (IntPtr) 0;
}
More information about the Kde-bindings
mailing list