comparison qt/QGlobal.d @ 247:27497bbe62a1

Implemented qVersion, qSharedBuild. Fixes #31
author maxter
date Fri, 31 Jul 2009 11:05:22 +0000
parents ba7abb5c9e03
children 7664de4a55e5
comparison
equal deleted inserted replaced
246:7e589f525254 247:27497bbe62a1
180 MV_LEOPARD = MV_10_5 180 MV_LEOPARD = MV_10_5
181 }; 181 };
182 static const MacVersion MacintoshVersion; 182 static const MacVersion MacintoshVersion;
183 }; 183 };
184 184
185 char[] qVersion(); 185
186 bool qSharedBuild(); 186 extern(C) stringz qtd_qVersion();
187 187 ///
188 string qVersion()
189 {
190 return fromStringz(qtd_qVersion);
191 }
192
193 extern(C) bool qtd_qSharedBuild();
194 ///
195 bool qSharedBuild()
196 {
197 return qtd_qSharedBuild;
198 }
199
200 ///
188 int qMacVersion() { return QSysInfo.MacintoshVersion; } 201 int qMacVersion() { return QSysInfo.MacintoshVersion; }
189 202
203 ///
190 void qUnused(T)(T x) { cast(void) x; } 204 void qUnused(T)(T x) { cast(void) x; }
205 ///
191 void Q_UNUSED(T)(T x) { qUnused(x); } 206 void Q_UNUSED(T)(T x) { qUnused(x); }
192 207
193 /* 208 /*
194 Debugging and error handling 209 Debugging and error handling
195 */ 210 */
590 struct Align 605 struct Align
591 { 606 {
592 ubyte a; 607 ubyte a;
593 void* b; 608 void* b;
594 } 609 }
595 610
596 private 611 private
597 const PTR_ALIGN = Align.tupleof[1].alignof; 612 const PTR_ALIGN = Align.tupleof[1].alignof;
598 613
599 private 614 private
600 template AlignPad(size_t base, size_t aligned) 615 template AlignPad(size_t base, size_t aligned)
601 { 616 {
602 static if( aligned == 0 ) 617 static if( aligned == 0 )
603 const AlignPad = base; 618 const AlignPad = base;
604 else 619 else
605 const AlignPad = ((base+PTR_ALIGN-1)/PTR_ALIGN)*PTR_ALIGN 620 const AlignPad = ((base+PTR_ALIGN-1)/PTR_ALIGN)*PTR_ALIGN
606 + aligned; 621 + aligned;
607 } 622 }
608 623
609 template InstanceSize(T) 624 template InstanceSize(T)
610 { 625 {
611 static if( is( T == Object ) ) 626 static if( is( T == Object ) )
612 const InstanceSize = 2*(void*).sizeof; 627 const InstanceSize = 2*(void*).sizeof;
613 else 628 else
614 const InstanceSize = Max!( 629 const InstanceSize = Max!(
615 AlignPad!( 630 AlignPad!(
616 InstanceSize!(Super!(T)), 631 InstanceSize!(Super!(T)),
617 InterfaceCount!(T)*(void*).sizeof), 632 InterfaceCount!(T)*(void*).sizeof),
618 633
619 AlignPad!( 634 AlignPad!(
620 InstanceSizeImpl!(T, 0), 635 InstanceSizeImpl!(T, 0),
621 + InterfaceCount!(T)*(void*).sizeof)); 636 + InterfaceCount!(T)*(void*).sizeof));
622 } 637 }
623 638
624 private 639 private
625 template Super(T) 640 template Super(T)
626 { 641 {
627 static if( is( T S == super ) ) 642 static if( is( T S == super ) )
628 alias First!(S) Super; 643 alias First!(S) Super;
629 else 644 else
630 static assert(false, "Can't get super of "~T.mangleof); 645 static assert(false, "Can't get super of "~T.mangleof);
631 } 646 }
632 647
633 private 648 private
634 template First(T) 649 template First(T)
635 { 650 {
636 alias T First; 651 alias T First;
637 } 652 }
638 653
639 private 654 private
640 template First(T, Ts...) 655 template First(T, Ts...)
641 { 656 {
642 alias T First; 657 alias T First;
643 } 658 }
644 659
645 private 660 private
646 template InstanceSizeImpl(T, size_t i) 661 template InstanceSizeImpl(T, size_t i)
647 { 662 {
648 static if( i < T.tupleof.length ) 663 static if( i < T.tupleof.length )
649 const InstanceSizeImpl = Max!( 664 const InstanceSizeImpl = Max!(
652 else 667 else
653 // This is necessary to account for classes without member 668 // This is necessary to account for classes without member
654 // variables. 669 // variables.
655 const InstanceSizeImpl = 2*(void*).sizeof; 670 const InstanceSizeImpl = 2*(void*).sizeof;
656 } 671 }
657 672
658 private 673 private
659 template Max(size_t a, size_t b) 674 template Max(size_t a, size_t b)
660 { 675 {
661 static if( a > b ) 676 static if( a > b )
662 const Max = a; 677 const Max = a;
663 else 678 else
664 const Max = b; 679 const Max = b;
665 } 680 }
666 681
667 private 682 private
668 template InterfaceCount(T) 683 template InterfaceCount(T)
669 { 684 {
670 static if( is( T == Object ) ) 685 static if( is( T == Object ) )
671 const InterfaceCount = 0u; 686 const InterfaceCount = 0u;
672 else static if( is( T S == super ) ) 687 else static if( is( T S == super ) )
673 const InterfaceCount = InterfaceCountImpl!(S); 688 const InterfaceCount = InterfaceCountImpl!(S);
674 } 689 }
675 690
676 private 691 private
677 template InterfaceCountImpl(TBase, TInterfaces...) 692 template InterfaceCountImpl(TBase, TInterfaces...)
678 { 693 {
679 const InterfaceCountImpl = TInterfaces.length; 694 const InterfaceCountImpl = TInterfaces.length;
680 } 695 }