[Kde-bindings] KDE/kdebindings/csharp/qyoto
Arno Rehn
kde at arnorehn.de
Sun May 27 12:45:35 UTC 2007
SVN commit 668735 by arnorehn:
* Removed the redundant stuff for ref arguments again and implemented them
based on Richard's proposal, which is much simpler.
* Added marshallers for qreal (double) and bool references.
CCMAIL: kde-bindings at kde.org
M +6 -0 ChangeLog
M +5 -5 src/SmokeInvocation.cs
M +64 -0 src/handlers.cpp
M +4 -51 src/qyoto.cpp
M +1 -1 src/qyoto.h
--- trunk/KDE/kdebindings/csharp/qyoto/ChangeLog #668734:668735
@@ -1,3 +1,9 @@
+2007-05-27 Arno Rehn <arno at arnorehn.de>
+
+ * Removed the redundant stuff for ref arguments again and implemented them
+ based on Richard's proposal, which is much simpler.
+ * Added marshallers for qreal (double) and bool references.
+
2007-05-18 Arno Rehn <arno at arnorehn.de>
* Made 'ref' arguments work.
--- trunk/KDE/kdebindings/csharp/qyoto/src/SmokeInvocation.cs #668734:668735
@@ -53,7 +53,7 @@
static extern int FindMethodId(string className, string mungedName, string signature);
[DllImport("libqyoto", CharSet=CharSet.Ansi)]
- static extern void CallSmokeMethod(int methodId, IntPtr target, IntPtr sp, int items, bool refArgs);
+ static extern void CallSmokeMethod(int methodId, IntPtr target, IntPtr sp, int items);
[DllImport("libqyoto", CharSet=CharSet.Ansi)]
static extern int QyotoHash(IntPtr obj);
@@ -420,14 +420,14 @@
unsafe {
fixed(StackItem * stackPtr = stack) {
if (instance == null) {
- CallSmokeMethod((int) methodId, (IntPtr) 0, (IntPtr) stackPtr, stack.Length, true);
+ CallSmokeMethod((int) methodId, (IntPtr) 0, (IntPtr) stackPtr, stack.Length);
} else {
#if DEBUG
GCHandle instanceHandle = DebugGCHandle.Alloc(instance);
#else
GCHandle instanceHandle = GCHandle.Alloc(instance);
#endif
- CallSmokeMethod(methodId, (IntPtr) instanceHandle, (IntPtr) stackPtr, stack.Length, true);
+ CallSmokeMethod(methodId, (IntPtr) instanceHandle, (IntPtr) stackPtr, stack.Length);
#if DEBUG
DebugGCHandle.Free(instanceHandle);
#else
@@ -508,14 +508,14 @@
unsafe {
fixed(StackItem * stackPtr = stack) {
if (instance == null) {
- CallSmokeMethod((int) methodId, (IntPtr) 0, (IntPtr) stackPtr, args.Length / 2, false);
+ CallSmokeMethod((int) methodId, (IntPtr) 0, (IntPtr) stackPtr, args.Length / 2);
} else {
#if DEBUG
GCHandle instanceHandle = DebugGCHandle.Alloc(instance);
#else
GCHandle instanceHandle = GCHandle.Alloc(instance);
#endif
- CallSmokeMethod(methodId, (IntPtr) instanceHandle, (IntPtr) stackPtr, args.Length / 2, false);
+ CallSmokeMethod(methodId, (IntPtr) instanceHandle, (IntPtr) stackPtr, args.Length / 2);
#if DEBUG
DebugGCHandle.Free(instanceHandle);
#else
--- trunk/KDE/kdebindings/csharp/qyoto/src/handlers.cpp #668734:668735
@@ -992,6 +992,7 @@
if(m->cleanup() && m->type().isConst()) {
delete i;
} else {
+ m->var().s_int = *((int *)(m->item().s_voidp));
// m->item().s_voidp = new int((int)NUM2INT(rv));
}
}
@@ -1010,7 +1011,64 @@
}
}
+static void marshall_doubleR(Marshall *m) {
+ switch(m->action()) {
+ case Marshall::FromObject:
+ {
+ double * d = new double;
+ *d = m->var().s_double;
+ m->item().s_voidp = d;
+ m->next();
+ if(m->cleanup() && m->type().isConst()) {
+ delete d;
+ } else {
+ m->var().s_double = *((double *)(m->item().s_voidp));
+ }
+ }
+ break;
+ case Marshall::ToObject:
+ {
+ double *dp = (double*)m->item().s_voidp;
+ m->var().s_double = *dp;
+ }
+ break;
+
+ default:
+ m->unsupported();
+ break;
+ }
+}
+
+static void marshall_boolR(Marshall *m) {
+ switch(m->action()) {
+ case Marshall::FromObject:
+ {
+ bool * b = new bool;
+ *b = m->var().s_bool;
+ m->item().s_voidp = b;
+ m->next();
+ if(m->cleanup() && m->type().isConst()) {
+ delete b;
+ } else {
+ m->var().s_bool = *((bool *)(m->item().s_voidp));
+ }
+ }
+ break;
+
+ case Marshall::ToObject:
+ {
+ bool *bp = (bool*)m->item().s_voidp;
+ m->var().s_bool = *bp;
+ }
+ break;
+
+ default:
+ m->unsupported();
+ break;
+ }
+}
+
static void marshall_charP_array(Marshall *m) {
switch(m->action()) {
@@ -1616,6 +1674,12 @@
{ "QString*", marshall_QString },
{ "int&", marshall_intR },
{ "int*", marshall_intR },
+ { "qreal&", marshall_doubleR },
+ { "qreal*", marshall_doubleR },
+ { "double&", marshall_doubleR },
+ { "double*", marshall_doubleR },
+ { "bool&", marshall_boolR },
+ { "bool*", marshall_boolR },
{ "char*", marshall_charP },
{ "char**", marshall_charP_array },
{ "QDBusVariant", marshall_QDBusVariant },
--- trunk/KDE/kdebindings/csharp/qyoto/src/qyoto.cpp #668734:668735
@@ -491,48 +491,6 @@
bool cleanup() { return false; }
};
-class RefArguments : public Marshall {
- Smoke *_smoke;
- Smoke::Index _method;
- Smoke::StackItem * _retval;
- Smoke::Stack _stack;
- Smoke::Stack _sp;
- Smoke::Index* _args;
- int _items;
- int _cur;
-public:
- RefArguments(Smoke *smoke, Smoke::Index method, Smoke::Stack stack, Smoke::Stack sp, Smoke::Index* args, int items) :
- _cur(0), _smoke(smoke), _method(method), _stack(stack), _sp(sp), _args(args), _items(items) {
- }
-
- const Smoke::Method &method() { return _smoke->methods[_method]; }
- SmokeType type() { return SmokeType(_smoke, _args[_cur]); }
- Marshall::Action action() { return Marshall::ToObject; }
- Smoke::StackItem &item() { return _stack[_cur]; }
- Smoke::StackItem &var() {
- return _sp[_cur];
- }
-
- void unsupported() {
- qFatal( "Cannot handle '%s' as return-type of %s::%s",
- type().name(),
- strcmp(_smoke->className(method().classId), "QGlobalSpace") == 0 ? "" : _smoke->className(method().classId),
- _smoke->methodNames[method().name] );
- }
- Smoke *smoke() { return _smoke; }
- void next() {
- int oldcur = _cur;
- _cur++;
- while(_cur < _items) {
- Marshall::HandlerFn fn = getMarshallFn(type());
- (*fn)(this);
- _cur++;
- }
- _cur = oldcur;
- }
- bool cleanup() { return false; }
-};
-
class MethodCall : public Marshall {
int _cur;
Smoke *_smoke;
@@ -546,10 +504,9 @@
int numItems;
Smoke::StackItem * _retval;
bool _called;
- bool _refArgs;
public:
- MethodCall(Smoke *smoke, Smoke::Index method, void * target, Smoke::Stack sp, int items, bool refArgs) :
- _cur(-1), _smoke(smoke), _method(method), _target(target), _o(0), _sp(sp), _items(items), _refArgs(refArgs), _called(false)
+ MethodCall(Smoke *smoke, Smoke::Index method, void * target, Smoke::Stack sp, int items) :
+ _cur(-1), _smoke(smoke), _method(method), _target(target), _o(0), _sp(sp), _items(items), _called(false)
{
if (!isConstructor() && !isStatic()) {
_o = (smokeqyoto_object*) (*GetSmokeObject)(_target);
@@ -638,10 +595,6 @@
(*SetSmokeObject)(_target, 0);
free_smokeqyoto_object(_o);
} else {
- if (_refArgs) {
- RefArguments ref(_smoke, _method, _stack, _sp, _args, numItems);
- ref.next();
- }
MethodReturnValue r(_smoke, _method, _stack, _retval);
}
@@ -1708,7 +1661,7 @@
}
void
-CallSmokeMethod(int methodId, void * obj, Smoke::StackItem * sp, int items, bool refArgs)
+CallSmokeMethod(int methodId, void * obj, Smoke::StackItem * sp, int items)
{
#ifdef DEBUG
printf("ENTER CallSmokeMethod(methodId: %d target: 0x%8.8x items: %d)\n", methodId, obj, items);
@@ -1730,7 +1683,7 @@
items = 1;
}
- MethodCall c(qt_Smoke, methodId, obj, sp, items, refArgs);
+ MethodCall c(qt_Smoke, methodId, obj, sp, items);
c.next();
#ifdef DEBUG
--- trunk/KDE/kdebindings/csharp/qyoto/src/qyoto.h #668734:668735
@@ -133,7 +133,7 @@
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, bool refArgs);
+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,
const char* stringdata, int stringdata_count,
More information about the Kde-bindings
mailing list