[Kde-bindings] KDE/kdebindings/csharp/qyoto
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Mon Apr 16 10:45:16 UTC 2007
SVN commit 654504 by rdale:
* Added a QyotoHash() method for deriving a hash value from the c++
pointer of an instance.
CCMAIL: kde-bindings at kde.org
M +5 -0 ChangeLog
M +8 -1 src/SmokeInvocation.cs
M +14 -0 src/qyoto.cpp
M +1 -15 src/qyoto.h
--- trunk/KDE/kdebindings/csharp/qyoto/ChangeLog #654503:654504
@@ -1,3 +1,8 @@
+2007-04-16 Richard Dale <rdale at foton.es>
+
+ * Added a QyotoHash() method for deriving a hash value from the c++
+ pointer of an instance.
+
2007-04-15 Richard Dale <rdale at foton.es>
* The Qyoto project is built with no symbols visible by default in
--- trunk/KDE/kdebindings/csharp/qyoto/src/SmokeInvocation.cs #654503:654504
@@ -55,6 +55,9 @@
[DllImport("libqyoto", CharSet=CharSet.Ansi)]
static extern void CallSmokeMethod(int methodId, IntPtr target, IntPtr sp, int items);
+ [DllImport("libqyoto", CharSet=CharSet.Ansi)]
+ static extern int QyotoHash(IntPtr obj);
+
// The key is a type name of a class which has overriden one or more
// virtual methods, and the value is a Hashtable of the smoke type
// signatures as keys retrieving a suitable MethodInfo to invoke via
@@ -563,7 +566,11 @@
}
public override int GetHashCode() {
- return instance.GetHashCode();
+#if DEBUG
+ return QyotoHash((IntPtr) DebugGCHandle.Alloc(instance));
+#else
+ return QyotoHash((IntPtr) GCHandle.Alloc(instance));
+#endif
}
}
--- trunk/KDE/kdebindings/csharp/qyoto/src/qyoto.cpp #654503:654504
@@ -1644,6 +1644,20 @@
application_terminated = true;
}
+int
+QyotoHash(void * obj)
+{
+ smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(obj);
+ (*FreeGCHandle)(obj);
+
+ if (sizeof(void*) > sizeof(int)) {
+ qint64 key = (qint64) o->ptr;
+ return (int) ((key >> (8 * sizeof(int) - 1)) ^ key);
+ } else {
+ return (int) o->ptr;
+ }
+}
+
void
CallSmokeMethod(int methodId, void * obj, Smoke::StackItem * sp, int items)
{
--- trunk/KDE/kdebindings/csharp/qyoto/src/qyoto.h #654503:654504
@@ -83,21 +83,6 @@
extern GetInstanceFn GetInstance;
extern GetIntPtr GetSmokeObject;
-/*
-extern Q_DECL_EXPORT void InstallFreeGCHandle(FromIntPtr callback);
-extern Q_DECL_EXPORT void InstallGetSmokeObject(GetIntPtr callback);
-extern Q_DECL_EXPORT void InstallSetSmokeObject(SetIntPtr callback);
-extern Q_DECL_EXPORT void InstallMapPointer(MapPointerFn callback);
-extern Q_DECL_EXPORT void InstallUnmapPointer(FromIntPtr callback);
-extern Q_DECL_EXPORT void InstallGetInstance(GetInstanceFn callback);
-extern Q_DECL_EXPORT void InstallOverridenMethod(OverridenMethodFn callback);
-extern Q_DECL_EXPORT void InstallInvokeMethod(InvokeMethodFn callback);
-extern Q_DECL_EXPORT void InstallCreateInstance(CreateInstanceFn callback);
-extern Q_DECL_EXPORT void InstallInvokeCustomSlot(InvokeCustomSlotFn callback);
-extern Q_DECL_EXPORT void InstallGetProperty(OverridenMethodFn callback);
-extern Q_DECL_EXPORT void InstallSetProperty(SetPropertyFn callback);
-*/
-
extern "C" {
extern Q_DECL_EXPORT void InstallFreeGCHandle(FromIntPtr callback);
extern Q_DECL_EXPORT void InstallGetSmokeObject(GetIntPtr callback);
@@ -146,6 +131,7 @@
extern Q_DECL_EXPORT bool QyotoUnregisterResourceData(int flag, const unsigned char * s, const unsigned char *n, const unsigned char *d);
extern Q_DECL_EXPORT void SetApplicationTerminated();
+extern Q_DECL_EXPORT int QyotoHash(void * obj);
extern Q_DECL_EXPORT void CallSmokeMethod(int methodId, void * obj, Smoke::StackItem * sp, int items);
extern Q_DECL_EXPORT bool SignalEmit(char * signature, char * type, void * obj, Smoke::StackItem * sp, int items);
extern Q_DECL_EXPORT void * make_metaObject( void * obj, void * parentMeta,
More information about the Kde-bindings
mailing list