comparison d2/qt/core/QList.d @ 372:a032df77b6ab

Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
author Max Samukha <maxter@spambox.com>
date Thu, 08 Jul 2010 17:19:05 +0300
parents 9784459f0750
children e67ce7c21758
comparison
equal deleted inserted replaced
370:7fd4b69378bf 372:a032df77b6ab
343 return QStringUtil.toNativeString(ptr); 343 return QStringUtil.toNativeString(ptr);
344 } 344 }
345 else static if (isValueType!T) 345 else static if (isValueType!T)
346 { 346 {
347 void* ptr = cast(void*)(isLarge!T() || isStatic!T() ? v : &this); 347 void* ptr = cast(void*)(isLarge!T() || isStatic!T() ? v : &this);
348 return new T(ptr, QtdObjectFlags.nativeOwnership); 348 return new T(ptr, QtdObjectInitFlags.nativeOwnership);
349 } 349 }
350 else 350 else
351 { 351 {
352 return T.__getObject( *cast(void**)(&this) ); 352 return T.__getObject( *cast(void**)(&this) );
353 } 353 }
480 void node_construct(Node *n, const T t) 480 void node_construct(Node *n, const T t)
481 { 481 {
482 static if (isValueType!T) 482 static if (isValueType!T)
483 { 483 {
484 if (isLarge!T() || isStatic!T()) // TODO should be static if 484 if (isLarge!T() || isStatic!T()) // TODO should be static if
485 n.v = T.__constructNativeCopy(t.__nativeId); // n.v = new T(t); 485 n.v = T.__constructNativeCopy(t.qtdNativeId); // n.v = new T(t);
486 else if (isComplex!T()) 486 else if (isComplex!T())
487 T.__constructPlacedNativeCopy(t.__nativeId, n); // new (n) T(t); 487 T.__constructPlacedNativeCopy(t.qtdNativeId, n); // new (n) T(t);
488 else 488 else
489 T.__constructPlacedNativeCopy(t.__nativeId, n); // TODO should be *cast(T*)(n) = cast(T)(t); as it is a primitive type. fix when they are implemented with structs 489 T.__constructPlacedNativeCopy(t.qtdNativeId, n); // TODO should be *cast(T*)(n) = cast(T)(t); as it is a primitive type. fix when they are implemented with structs
490 } 490 }
491 else // in case of QObject or Object Qt types we place a pointer to a native object in the node 491 else // in case of QObject or Object Qt types we place a pointer to a native object in the node
492 n = cast(Node*) t.__nativeId; 492 n = cast(Node*) t.qtdNativeId;
493 } 493 }
494 else static if (is(T == string)) 494 else static if (is(T == string))
495 { 495 {
496 void node_construct(Node *n, T t) 496 void node_construct(Node *n, T t)
497 { 497 {
541 T[] res; 541 T[] res;
542 res.length = this.length; 542 res.length = this.length;
543 for(int i = 0; i < res.length; ++i) 543 for(int i = 0; i < res.length; ++i)
544 { 544 {
545 static if (isValueType!T) 545 static if (isValueType!T)
546 res[i] = new T(T.__constructNativeCopy(this.at(i).__nativeId)); // Node should probably provide a ptr method to directly extract pointer to the native value stored in the list to avoid creating a dummy D object in t() 546 res[i] = new T(T.__constructNativeCopy(this.at(i).qtdNativeId)); // Node should probably provide a ptr method to directly extract pointer to the native value stored in the list to avoid creating a dummy D object in t()
547 else 547 else
548 res[i] = this.opIndex(i); 548 res[i] = this.opIndex(i);
549 } 549 }
550 return res; 550 return res;
551 } 551 }