comparison qt/QGlobal.d @ 188:7dd099050621

initial commit for D2 support
author eldar
date Sun, 12 Jul 2009 18:58:03 +0000
parents 7d9db724ee1d
children a212c97edcd2
comparison
equal deleted inserted replaced
187:34fe79a9915b 188:7dd099050621
7 import tango.io.Stdout; 7 import tango.io.Stdout;
8 void writeln(string s) 8 void writeln(string s)
9 { 9 {
10 Stdout(s).newline; 10 Stdout(s).newline;
11 } 11 }
12 package import tango.stdc.stdlib,
13 tango.core.Memory;
12 } 14 }
13 else 15 else
16 {
14 import std.stdio; 17 import std.stdio;
18 package import std.c.stdlib,
19 core.memory;
20 }
15 21
16 template QT_BEGIN_NAMESPACE() { 22 template QT_BEGIN_NAMESPACE() {
17 } 23 }
18 24
19 template QT_END_NAMESPACE() { 25 template QT_END_NAMESPACE() {
584 const ushort QT_EDITION_EDUCATIONAL = QT_EDITION_DESKTOP; 590 const ushort QT_EDITION_EDUCATIONAL = QT_EDITION_DESKTOP;
585 const ushort QT_EDITION_EVALUATION = QT_EDITION_DESKTOP; 591 const ushort QT_EDITION_EVALUATION = QT_EDITION_DESKTOP;
586 592
587 mixin QT_END_NAMESPACE; 593 mixin QT_END_NAMESPACE;
588 594
589 package import tango.stdc.stdlib,
590 tango.core.Memory;
591
592 private 595 private
593 struct Align 596 struct Align
594 { 597 {
595 ubyte a; 598 ubyte a;
596 void* b; 599 void* b;
597 } 600 }
598 601
599 private 602 private
600 const PTR_ALIGN = Align.tupleof[1].alignof; 603 const PTR_ALIGN = Align.tupleof[1].alignof;
601
602 version( X86 )
603 const MEM_ALIGN = 8u;
604 else
605 static assert(false, "Unknown memory alignment for this platform.");
606 604
607 private 605 private
608 template AlignPad(size_t base, size_t aligned) 606 template AlignPad(size_t base, size_t aligned)
609 { 607 {
610 static if( aligned == 0 ) 608 static if( aligned == 0 )
670 const Max = a; 668 const Max = a;
671 else 669 else
672 const Max = b; 670 const Max = b;
673 } 671 }
674 672
675 template InstanceSizeAligned(T, size_t alignment=MEM_ALIGN)
676 {
677 static if( alignment == 0 )
678 const InstanceSizeAligned = InstanceSize!(T);
679 else
680 const uint InstanceSizeAligned
681 = InstanceSizeAlignImpl!(T, alignment).result;
682 }
683
684 private
685 template InstanceSizeAlignedImpl(T, size_t alignment)
686 {
687 private const base_size = InstanceSize!(T);
688 const result = ((base_size+alignment-1)/alignment)*alignment;
689 }
690
691 private 673 private
692 template InterfaceCount(T) 674 template InterfaceCount(T)
693 { 675 {
694 static if( is( T == Object ) ) 676 static if( is( T == Object ) )
695 const InterfaceCount = 0u; 677 const InterfaceCount = 0u;