[Kde-bindings] playground/bindings/kimono

Richard Dale Richard_Dale at tipitina.demon.co.uk
Sun Feb 11 04:37:30 UTC 2007


SVN commit 632420 by rdale:

* Renamed IsInstanceContained() as IsContainedInstance(), and only call
  a destructor for instances where it is false, as the C++ side will
  delete the instance.

CCMAIL:kde-bindings at kde.org



 M  +3 -0      ChangeLog  
 M  +1 -1      handlers.cpp  
 M  +7 -5      qyoto.cpp  
 M  +1 -1      qyoto.h  


--- trunk/playground/bindings/kimono/ChangeLog #632419:632420
@@ -3,6 +3,9 @@
 	* Don't call a destructor is the instance was allocated in the C++ world
 	* If a destructor has been called then set the ptr field on the 
 	  smokeqyoto_object struct to 0, and don't call methods on it again.
+	* Renamed IsInstanceContained() as IsContainedInstance(), and only call
+	  a destructor for instances where it is false, as the C++ side will
+	  delete the instance.
 
 2007-02-10  Arno Rehn  <arno at arnorehn.de>
 
--- trunk/playground/bindings/kimono/handlers.cpp #632419:632420
@@ -226,7 +226,7 @@
 extern void mapPointer(void * obj, smokeqyoto_object *o, Smoke::Index classId, void *lastptr);
 
 bool
-IsInstanceContained(smokeqyoto_object *o)
+IsContainedInstance(smokeqyoto_object *o)
 {
     const char *className = o->smoke->classes[o->classId].className;
 		
--- trunk/playground/bindings/kimono/qyoto.cpp #632419:632420
@@ -361,9 +361,9 @@
 						className, 
 						ptr, 
 						(void*)obj,
-						IsInstanceContained(o) ? "true" : "false" );
+						IsContainedInstance(o) ? "true" : "false" );
 		}
-		(*MapPointer)(ptr, obj, IsInstanceContained(o));
+		(*MapPointer)(ptr, obj, IsContainedInstance(o));
     }
 	
 	for (Smoke::Index *i = o->smoke->inheritanceList + o->smoke->classes[classId].parents; *i; i++) {
@@ -527,13 +527,16 @@
     bool _called;
 public:
     MethodCall(Smoke *smoke, Smoke::Index method, void * target, Smoke::Stack sp, int items) :
-	_cur(-1), _smoke(smoke), _method(method), _target(target), _sp(sp), _items(items), _called(false)
+	_cur(-1), _smoke(smoke), _method(method), _target(target), _o(0), _sp(sp), _items(items), _called(false)
 	{
 		if (_target != 0) {
 	    	_o = value_obj_info(_target);
 			if (_o != 0 && _o->ptr != 0) {
-				if (!_o->allocated && isDestructor()) {
+				if (	isDestructor() 
+						&& (!_o->allocated || IsContainedInstance(_o)) ) 
+				{
 					_called = true;
+					_o->allocated = false;
 				}
 			} else if (!isConstructor() && !isStatic()) {
 				_called = true;
@@ -619,7 +622,6 @@
 		(*fn)(method().method, ptr, _stack);
 		MethodReturnValue r(_smoke, _method, _stack, _retval);
 
-		// A constructor
 		if (isConstructor()) {
 			_o = alloc_smokeqyoto_object(true, _smoke, method().classId, _stack[0].s_voidp);
 			(*SetSmokeObject)(_target, _o);
--- trunk/playground/bindings/kimono/qyoto.h #632419:632420
@@ -58,7 +58,7 @@
 void unmapPointer(smokeqyoto_object *, Smoke::Index, void*);
 smokeqyoto_object *value_obj_info(void * value);
 void * getPointerObject(void *ptr);
-bool IsInstanceContained(smokeqyoto_object *o);
+bool IsContainedInstance(smokeqyoto_object *o);
 
 typedef void* (*NoArgs)();
 typedef void* (*GetIntPtr)(void *);



More information about the Kde-bindings mailing list